-
-
Notifications
You must be signed in to change notification settings - Fork 814
feat(lint): implement useExhaustiveSwitchCases - typescript-eslint/switch-exhaustiveness-check
#5762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lint): implement useExhaustiveSwitchCases - typescript-eslint/switch-exhaustiveness-check
#5762
Conversation
|
I'm thrilled!!!! 🤩 |
CodSpeed Performance ReportMerging #5762 will not alter performanceComparing Summary
|
b22c4e1 to
7a486b1
Compare
…/switch-exhaustiveness-check`
7a486b1 to
d16049a
Compare
ematipico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. We need to add the second pillar to the diagnostic messages
crates/biome_js_analyze/src/lint/nursery/use_exhaustive_switch_cases.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/use_exhaustive_switch_cases.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/use_exhaustive_switch_cases.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/use_exhaustive_switch_cases.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/use_exhaustive_switch_cases.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/use_exhaustive_switch_cases.rs
Outdated
Show resolved
Hide resolved
# Conflicts: # crates/biome_js_analyze/tests/spec_tests.rs
|
I am going to merge this after #5777, which will change some part that this rule relies on. |
arendjr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it, and well done with the solid test cases!
Thanks for waiting for the refactor too 🙏
# Conflicts: # crates/biome_configuration/src/analyzer/linter/rules.rs # crates/biome_js_analyze/src/lint/nursery.rs # crates/biome_js_type_info/src/flattening.rs # crates/biome_js_type_info/src/type_info.rs
# Conflicts: # crates/biome_configuration/src/analyzer/linter/rules.rs # crates/biome_js_analyze/src/lint/nursery.rs # crates/biome_js_analyze/src/services/typed.rs
37c2fbd to
3af6b6d
Compare
| if let Some(expr) = | ||
| JsExpressionStatement::cast_ref(node).and_then(|node| node.expression().ok()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arendjr This prevented the type of const declarations and reference expressions to be resolved. Is this condition correct? Changing this to AnyJsExpression fixed the issue, but it can occur performance regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had indeed avoided that for performance reasons, and this was all I needed for it to work with noFloatingPromises... but indeed that doesn't scale across the board :(
I'd be happy to relax this to support AnyJsExpression, but I'm afraid we need to resolve the performance issues first. I do have some hope my current PR may help with that 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, registering types for the discriminant and the case expressions is sufficient for the rule: bdfc07b
3af6b6d to
609ed92
Compare
609ed92 to
cc5204d
Compare
# Conflicts: # crates/biome_configuration/src/analyzer/linter/rules.rs # crates/biome_js_analyze/src/lint/nursery.rs # crates/biome_js_type_info/src/flattening.rs
…/switch-exhaustiveness-check` (#5762)
Summary
Initial implementation of a new rule
useExhaustiveSwitchCases, which is an equivalent totypescript-eslint/switch-exhaustiveness-check. I left adding options for future improvement.Test Plan
Added snapshot tests.