oxc
oxc copied to clipboard
`unicorn/no-zero-fractions` suggests subpar fixes
This rule fails 3 kinds of fixer tests. We should either stop suggesting them or correct their behavior.
- Spacing(Invalid code) For:
function foo(){return.0}
We generate:
function foo(){return0}
Where it should be:
function foo(){return 0}
- Parenthesized expressions(dangerous):
For:
1.00.toFixed(2)
We generate:
1.toFixed(2)
Where it should be:
(1).toFixed(2)
- Exponential numbers(Inconvenient):
For:
const foo = 1.e10
We generate:
const foo = 110
Where it should be:
const foo = 1e10
Tests are introduced in #4783
https://github.com/oxc-project/oxc/blob/4dd29dbc2beac49df28ccf15ea433ffbaf3e9fd4/crates/oxc_linter/src/rules/unicorn/no_zero_fractions.rs#L149-L164