noZeroFractions (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noZeroFractions - This rule has a safe fix.
- The default severity of this rule is information.
- Sources:
- Same as
unicorn/no-zero-fractions
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noZeroFractions": "error" } } }}Description
Section titled “Description”Disallow number literals with zero fractions or dangling dots.
There is no difference in JavaScript between, for example, 1, 1.0, and 1..
This rule suggests the shorter form for consistency and brevity.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”const foo = 1.0;code-block.js:1:13 lint/nursery/noZeroFractions FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This number literal has a zero fraction.
> 1 │ const foo = 1.0;
│ ^^^
2 │
ℹ The fractional part is redundant. It has the same runtime value and makes the literal longer than it needs to be.
ℹ This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/9829 for more information or to report possible bugs.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Remove the redundant zero fraction.
1 │ - const·foo·=·1.0;
1 │ + const·foo·=·1;
2 2 │
const foo = 1.;code-block.js:1:13 lint/nursery/noZeroFractions FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This number literal has a dangling dot.
> 1 │ const foo = 1.;
│ ^^
2 │
ℹ The fractional part is redundant. It has the same runtime value and makes the literal longer than it needs to be.
ℹ This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/9829 for more information or to report possible bugs.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Remove the dangling dot.
1 │ const·foo·=·1.;
│ -
const foo = 123.00e20;code-block.js:1:13 lint/nursery/noZeroFractions FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This number literal has a zero fraction.
> 1 │ const foo = 123.00e20;
│ ^^^^^^^^^
2 │
ℹ The fractional part is redundant. It has the same runtime value and makes the literal longer than it needs to be.
ℹ This rule is still being actively worked on, so it may be missing features or have rough edges. Visit https://github.com/biomejs/biome/issues/9829 for more information or to report possible bugs.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Remove the redundant zero fraction.
1 │ - const·foo·=·123.00e20;
1 │ + const·foo·=·123e20;
2 2 │
const foo = 1;const bar = -1.1;const baz = 123.456;const qux = 1e3;Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.