JS.BASE.NO.DIV.REGEX

Disallow division operators explicitly at the beginning of regular expressions

Require regex literals to escape division operators.

Copy
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:

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

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

Examples of correct code for this rule:

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

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

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/