Skip to content

feat(no-unsafe-enum-comparison): implement suggestion#910

Merged
graphite-app[bot] merged 1 commit into
mainfrom
codex/no-unsafe-enum-comparison-suggestion-fix
Apr 25, 2026
Merged

feat(no-unsafe-enum-comparison): implement suggestion#910
graphite-app[bot] merged 1 commit into
mainfrom
codex/no-unsafe-enum-comparison-suggestion-fix

Conversation

@camc314

@camc314 camc314 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor
  • add enum member suggestions for unsafe enum comparisons
  • preserve safe enum qualifiers and use ts-go jsnum formatting for folded numbers

part of #668

@camc314 camc314 marked this pull request as ready for review April 25, 2026 10:30
Copilot AI review requested due to automatic review settings April 25, 2026 10:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/jsnum package 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.

Comment thread internal/rules/no_unsafe_enum_comparison/no_unsafe_enum_comparison.go Outdated
Comment thread internal/rules/no_unsafe_enum_comparison/no_unsafe_enum_comparison.go Outdated
@camc314 camc314 changed the title feat(no-unsafe-enum-comparison): implement suggestion/fix feat(no-unsafe-enum-comparison): implement suggestion Apr 25, 2026
@camc314 camc314 self-assigned this Apr 25, 2026

camc314 commented Apr 25, 2026

Copy link
Copy Markdown
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
@graphite-app graphite-app Bot force-pushed the codex/no-unsafe-enum-comparison-suggestion-fix branch from ad5648f to bfa426f Compare April 25, 2026 11:00
@graphite-app graphite-app Bot merged commit bfa426f into main Apr 25, 2026
8 of 9 checks passed
@graphite-app graphite-app Bot removed the 0-merge label Apr 25, 2026
@graphite-app graphite-app Bot deleted the codex/no-unsafe-enum-comparison-suggestion-fix branch April 25, 2026 11:07
graphite-app Bot pushed a commit to oxc-project/oxc that referenced this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants