eslint/no-regex-spaces 限制
作用
禁止在正则表达式中出现连续 2 个及以上的空格。
为什么这不好?
在正则表达式中,很难判断要匹配多少个空格。 最好只使用一个空格,然后用量词来指定预期的空格数量。
javascript
var re = /foo {3}bar/;示例
以下是此规则的错误代码示例:
javascript
var re = /foo bar/;如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"no-regex-spaces": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"no-regex-spaces": "error",
},
});bash
oxlint --deny no-regex-spaces版本
此规则于 v0.0.18 中添加。
