W3cubDocs

/ESLint

no-div-regex

Disallow division operators explicitly at the beginning of regular expressions

🔧 Fixable

Some problems reported by this rule are automatically fixable by the --fix command line option

Require regex literals to escape division operators.

function bar() { return /=foo/; }

Rule Details

This is used to disambiguate the division operator to not confuse users.

Examples of incorrect code for this rule:

/*eslint no-div-regex: "error"*/

function bar() { return /=foo/; }

Examples of correct code for this rule:

/*eslint no-div-regex: "error"*/

function bar() { return /[=]foo/; }

Version

This rule was introduced in ESLint v0.1.0.

Resources

© OpenJS Foundation and other contributors
Licensed under the MIT License.
https://eslint.org/docs/latest/rules/no-div-regex