unicorn/number-literal-case Style
作用
此规则强制数字字面量使用正确的大小写。
为什么这不好?
当标识符和数字字面量都使用小写时, 它们可能很难区分。
示例
以下是此规则的错误代码示例:
javascript
const foo = 0XFF;
const foo = 0xff;
const foo = 0Xff;
const foo = 0Xffn;
const foo = 0B10;
const foo = 0B10n;
const foo = 0O76;
const foo = 0O76n;
const foo = 2E-5;以下是此规则的正确代码示例:
javascript
const foo = 0xFF;
const foo = 0b10;
const foo = 0o76;
const foo = 0xFFn;
const foo = 2e+5;如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"unicorn/number-literal-case": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"unicorn/number-literal-case": "error",
},
});bash
oxlint --deny unicorn/number-literal-case版本
此规则在 v0.0.18 中添加。
