fix(no-unnecessary-condition): use static values for literal comparisons#833
Conversation
How to use the Graphite Merge QueueAdd the label 0-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
Updates no-unnecessary-condition to evaluate literal-to-literal comparisons using computed static values, and improves the diagnostic message to state whether the comparison is always true/false.
Changes:
- Add static value extraction for
numberandbigintliteral types (instead of comparing by string form). - Implement constant-folding logic for
==,===,<,<=,>,>=,!=,!==across static literal values. - Update rule snapshots (unit + e2e) to reflect the new, more specific diagnostic message text.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| internal/rules/no_unnecessary_condition/no_unnecessary_condition.go | Adds static-value extraction and constant-folding for literal comparisons; updates diagnostic message construction. |
| internal/rule_tester/snapshots/no-unnecessary-condition.snap | Updates expected diagnostics text for literal comparison cases. |
| e2e/snapshots/snapshot.test.ts.snap | Updates expected e2e diagnostics JSON for the rule message change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
camc314
left a comment
There was a problem hiding this comment.
This is too complicated for not much value - we are basically re-implementing JS in go which is not sensible
see #833 for reasoning - we may start using this in future. In the mean time it makes sense to keep it to align with the upstream impl

No description provided.