eslint/no-useless-concat Suspicious
它的作用
禁止对字面量或模板字面量进行不必要的拼接。
这为什么不好?
当两个字符串可以合并为一个单一字面量时,将它们拼接在一起是没有必要的。
示例
此规则的错误代码示例:
javascript
var foo = "a" + "b";javascript
var foo = "a" + "b" + "c";此规则的正确代码示例:
javascript
var foo = "a" + bar;
// 当字符串拼接为多行时
var foo = "a" + "b" + "c";如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"no-useless-concat": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"no-useless-concat": "error",
},
});bash
oxlint --deny no-useless-concat版本
此规则于 v0.4.2 中添加。
