Versions

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

正则表达式文字开头的字符 /= 可能与除法赋值运算符混淆。

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

规则细节

该规则禁止在正则表达式文字开头的斜线(/)后使用等号(=),因为字符 /= 可能与除法赋值运算符相混淆。

使用此规则的错误示例:

Open in Playground
/*eslint no-div-regex: "error"*/

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

使用此规则的正确示例:

Open in Playground
/*eslint no-div-regex: "error"*/

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

Version

This rule was introduced in ESLint v0.1.0.

Resources

更改语言