fix(linter): avoid false positive for 3e-308#19995
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes eslint/no-loss-of-precision false positives for very small literals (e.g. 3e-308) by simplifying internal precision-string generation, and updates snapshots/tests to align with ESLint’s current test cases (including TS/TSX coverage).
Changes:
- Replace the custom
toPrecision-like formatting logic with Rust scientific formatting to avoid truncation for very small exponents. - Expand pass/fail test vectors to include additional exponent/TS cases and underflow/subnormal regressions.
- Update the rule snapshot output to reflect the new/expanded test coverage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/oxc_linter/src/rules/eslint/no_loss_of_precision.rs | Simplifies to_precision implementation and updates rule test cases for additional exponent/TS and underflow scenarios. |
| crates/oxc_linter/src/snapshots/eslint_no_loss_of_precision.snap | Updates expected diagnostics to match the expanded test coverage. |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df413b4fd6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed review feedback in
Validation:
|
Summary
eslint/no-loss-of-precisionfalse positive for3e-308by simplifying internal precision formattingno-loss-of-precisiontest cases (including TS cases)Closes #19988
Testing
cargo test -p oxc_linter no_loss_of_precision -- --nocaptureAI usage disclosure
This PR was prepared with AI assistance, and I reviewed and validated the generated changes and test updates.