feat(no-unsafe-enum-comparison): implement suggestion#910
Merged
graphite-app[bot] merged 1 commit intoApr 25, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
Implements suggestions/fix output for no-unsafe-enum-comparison by mapping comparable literal values back to their corresponding enum members, and adds jsnum shims to preserve TypeScript/JS numeric stringification when folding numeric expressions.
Changes:
- Add suggestion generation (
replaceValueWithEnum) for unsafe enum comparisons, including static evaluation of simple expressions (e.g.'' + -0,'' + 1e20). - Introduce a new
shim/jsnumpackage and wire it into shim generation and module replacement. - Update rule tests and snapshots to assert the new suggestions.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/gen_shims/main.go | Adds internal/jsnum to the list of TypeScript-Go internal packages that are shimmed. |
| shim/jsnum/shim.go | New generated shim exposing jsnum APIs/types needed for JS number formatting and parsing. |
| shim/jsnum/go.mod | New module definition for the shim/jsnum package. |
| go.mod | Adds replace/require entries so the repo can import shim/jsnum. |
| internal/rules/no_unsafe_enum_comparison/no_unsafe_enum_comparison.go | Implements static-value extraction + enum-member lookup and reports diagnostics with suggestions. |
| internal/rules/no_unsafe_enum_comparison/no_unsafe_enum_comparison_test.go | Updates/extends rule tests to include suggestion outputs and new edge cases. |
| internal/rule_tester/snapshots/no-unsafe-enum-comparison.snap | Snapshot updates reflecting the new suggestion text and new test cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
Merge activity
|
- add enum member suggestions for unsafe enum comparisons - preserve safe enum qualifiers and use ts-go jsnum formatting for folded numbers part of #668
ad5648f to
bfa426f
Compare
graphite-app Bot
pushed a commit
to oxc-project/oxc
that referenced
this pull request
Apr 26, 2026
…ion fix (#21783) upstream PR: oxc-project/tsgolint#910
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
part of #668