no-div-regex
Disallow equal signs explicitly at the beginning of regular expressions
🔧 Fixable
Some problems reported by this rule are automatically fixable by the --fix
command line option
Characters /=
at the beginning of a regular expression literal can be confused with a division assignment operator.
function bar() { return /=foo/; }
Rule Details
This rule forbids equal signs (=
) after the slash (/
) at the beginning of a regular expression literal, because the characters /=
can be confused with a division assignment operator.
Examples of incorrect code for this rule:
Open in Playground
/*eslint no-div-regex: "error"*/
function bar() { return ; }
Examples of correct code for this rule:
Open in Playground
/*eslint no-div-regex: "error"*/
function bar() { return /[=]foo/; }
Related Rules
Version
This rule was introduced in ESLint v0.1.0.