-
-
Notifications
You must be signed in to change notification settings - Fork 930
Closed
Labels
A-linterArea - LinterArea - LinterC-bugCategory - BugCategory - Buggood first issueExperience Level - Good for newcomersExperience Level - Good for newcomers
Description
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.e10We generate:
const foo = 110Where it should be:
const foo = 1e10Tests are introduced in #4783
oxc/crates/oxc_linter/src/rules/unicorn/no_zero_fractions.rs
Lines 149 to 164 in 4dd29db
| // maybe todo | |
| // In the following tests, the comments did not pass the fixer. | |
| // (r"const foo = 1.e10", r"const foo = 1e10"), | |
| // (r"const foo = +1.e-10", r"const foo = +1e-10"), | |
| // (r"const foo = -1.e+10", r"const foo = -1e+10"), | |
| (r"const foo = (1.).toString()", r"const foo = (1).toString()"), | |
| // (r"1.00.toFixed(2)", r"(1).toFixed(2)"), | |
| // (r"1.00 .toFixed(2)", r"(1) .toFixed(2)"), | |
| (r"(1.00).toFixed(2)", r"(1).toFixed(2)"), | |
| // (r"1.00?.toFixed(2)", r"(1)?.toFixed(2)"), | |
| (r"a = .0;", r"a = 0;"), | |
| // (r"a = .0.toString()", r"a = (0).toString()"), | |
| // (r"function foo(){return.0}", r"function foo(){return 0}"), | |
| // (r"function foo(){return.0.toString()}", r"function foo(){return (0).toString()}"), | |
| // (r"function foo(){return.0+.1}", r"function foo(){return 0+.1}"), |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - LinterC-bugCategory - BugCategory - Buggood first issueExperience Level - Good for newcomersExperience Level - Good for newcomers
Type
Fields
Give feedbackPriority
None yet