Disallow Regular Expressions That Look Like Division (no-div-regex)

禁止使用看起来像除法的正则表达式 (no-div-regex)

The --fix option on the command line can automatically fix some of the problems reported by this rule.

命令行中的 --fix 选项可以自动修复一些该规则报告的问题。

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/; }


This rule was introduced in ESLint 0.1.0.

该规则在 ESLint 0.1.0 中被引入。