no-div-regex

Disallow regular expressions that start with =

fixable

A regular expression literal that starts with = begins with /=, which is also the division assignment operator. You have to look twice to see which one it is.

--fix rewrites the = to [=], which matches the same text.

Configure#

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"no-div-regex" = "error" # or "warn"

Examples#

example.js1 problem
const value = line.replace(/=\s*/, "");
example.jsNo problems
const value = line.replace(/[=]\s*/, "");