useSimpleNumberKeys
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/complexity/useSimpleNumberKeys¥Diagnostic Category:
lint/complexity/useSimpleNumberKeys -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则包含 safe 修复程序。
¥This rule has a safe fix.
-
此规则的默认严重级别为 warning。
¥The default severity of this rule is warning.
¥How to configure
{ "linter": { "rules": { "complexity": { "useSimpleNumberKeys": "error" } } }}¥Description
禁止使用非十进制或以下划线作为分隔符的数字字面量对象成员名称。
¥Disallow number literal object member names which are not base 10 or use underscore as separator.
¥Examples
¥Invalid
({ 0x1: 1 });code-block.js:1:4 lint/complexity/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Hexadecimal number literal is not allowed here.
> 1 │ ({ 0x1: 1 });
│ ^^^
2 │
ℹ Safe fix: Replace 0x1 with 1
1 │ - ({·0x1:·1·});
1 │ + ({·1:·1·});
2 2 │
({ 11_1.11: "ee" });code-block.js:1:4 lint/complexity/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Number literal with underscore is not allowed here.
> 1 │ ({ 11_1.11: “ee” });
│ ^^^^^^^
2 │
ℹ Safe fix: Replace 11_1.11 with 111.11
1 │ - ({·11_1.11:·“ee”·});
1 │ + ({·111.11:·“ee”·});
2 2 │
({ 0o1: 1 });code-block.js:1:4 lint/complexity/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Octal number literal is not allowed here.
> 1 │ ({ 0o1: 1 });
│ ^^^
2 │
ℹ Safe fix: Replace 0o1 with 1
1 │ - ({·0o1:·1·});
1 │ + ({·1:·1·});
2 2 │
({ 1n: 1 });code-block.js:1:4 lint/complexity/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Bigint is not allowed here.
> 1 │ ({ 1n: 1 });
│ ^^
2 │
ℹ Safe fix: Replace 1n with 1
1 │ - ({·1n:·1·});
1 │ + ({·1:·1·});
2 2 │
({ 11_1.11: "ee" });code-block.js:1:4 lint/complexity/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Number literal with underscore is not allowed here.
> 1 │ ({ 11_1.11: “ee” });
│ ^^^^^^^
2 │
ℹ Safe fix: Replace 11_1.11 with 111.11
1 │ - ({·11_1.11:·“ee”·});
1 │ + ({·111.11:·“ee”·});
2 2 │
¥Valid
({ 0: "zero" });({ 122: "integer" });({ 1.22: "floating point" });({ 3.1e12: "floating point with e" });¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号