eslint/no-div-regex Restriction
作用
禁止在正则表达式开头显式使用等号。
为什么不好?
正则表达式字面量开头的字符 /= 可能会被混淆为除法赋值运算符。
示例
此规则的 错误 代码示例:
javascript
function bar() {
return /=foo/;
}此规则的 正确 代码示例:
javascript
function bar() {
return /[=]foo/;
}如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"no-div-regex": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"no-div-regex": "error",
},
});bash
oxlint --deny no-div-regex版本
此规则是在 v0.4.2 中添加的。
