unicorn/escape-case Pedantic
作用
强制使用大写字符而不是小写字符来定义转义序列值。 这通过使转义值与标识符更易区分来提升可读性。
为什么这不好?
在转义序列中使用小写字符会降低可读性,并使其更难与周围代码区分。 大多数样式指南都建议使用大写以保持一致性和清晰性。
示例
此规则的错误代码示例:
javascript
const foo = "\xa9";
const foo = "\ud834";
const foo = "\u{1d306}";
const foo = "\ca";此规则的正确代码示例:
javascript
const foo = "\xA9";
const foo = "\uD834";
const foo = "\u{1D306}";
const foo = "\cA";如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"unicorn/escape-case": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"unicorn/escape-case": "error",
},
});bash
oxlint --deny unicorn/escape-case版本
此规则在 v0.0.19 中添加。
