Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Linter · Rules

no-div-regex

Disallow regular expressions that start with =

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

Reported:

const value = line.replace(/=\s*/, "");

Not reported:

const value = line.replace(/[=]\s*/, "");