eslint/no-empty-character-class Correctness
作用
禁止在正则表达式中使用空的字符类。
为什么不好?
因为正则表达式中的空字符类无法匹配任何内容,它们可能是输入错误。
示例
此规则 错误 代码示例:
javascript
var foo = /^abc[]/;此规则 正确 代码示例:
javascript
var foo = /^abc/;
var foo2 = /^abc[123]/;如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"no-empty-character-class": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"no-empty-character-class": "error",
},
});bash
oxlint --deny no-empty-character-class版本
该规则在 v0.0.7 中添加。
