title | rule_type | related_rules | ||
---|---|---|---|---|
no-div-regex |
suggestion |
|
Characters /=
at the beginning of a regular expression literal can be confused with a division assignment operator.
function bar() { return /=foo/; }
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:
:::incorrect
/*eslint no-div-regex: "error"*/
function bar() { return /=foo/; }
:::
Examples of correct code for this rule:
:::correct
/*eslint no-div-regex: "error"*/
function bar() { return /[=]foo/; }
:::