-
-
Notifications
You must be signed in to change notification settings - Fork 482
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: add useDefaultSwitchClause
rule
#2605
Conversation
CodSpeed Performance ReportMerging #2605 will not alter performanceComparing Summary
|
Hi @michellocana. Thanks for your contribution :) Next time, please add a comment to Linter rules from other sources to indicate your interest in implementing this rule. After some discussion, we usually open a task issue to implement the rule. I didn't add this rule to the list of rules to implement because I thought it was unhelpful and even problematic. Can you motivate why you need this rule? |
Hey @Conaclos, thanks for the quick review :D, and sorry, I didn't see the linked discussion before, next time I'm gonna take a look on that first. While I completely agree that this rule becomes pretty much useless in a TypeScript environment, I found myself using this rule a lot on a plain Javascript scenario, which is the reality of some of the projects I currently work on: const ORDER_STATUS = {
WAITING_FOR_PAYMENT: 'WAITING_FOR_PAYMENT',
PAID: 'PAID',
CANCELED: 'CANCELED',
}
function getOrderLabel(status) {
switch (status) {
case ORDER_STATUS.WAITING_FOR_PAYMENT:
return 'Waiting for payment.'
case ORDER_STATUS.PAID:
return 'Paid.'
}
} In the function above, |
bf24f08
to
173d410
Compare
useDefaultCase
ruleuseDefaultSwitchClause
rule
03b61f7
to
e249407
Compare
e249407
to
a69de87
Compare
crates/biome_js_analyze/src/lint/nursery/use_default_switch_clause.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/use_default_switch_clause.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/use_default_switch_clause.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/use_default_switch_clause.rs
Outdated
Show resolved
Hide resolved
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.
Thanks for your contribution! I think it is ready for merging :) Waiting for CI status.
cool, thanks for the feedbacks, hopefully I can help more in the project ❤️ |
Implementation of the
default-case
ESLint rule in Biome.Summary
In order to migrate the project I work on from ESLint to biome, there are some rules that still need to be implemented in the Biome Linter, so I decided to give a try on the
default-case
rule. This is my first PR on the repository, so let me know if I'm missing something or can do something in a better way.Test Plan
Added snapshots, for valid and invalid cases according to the
default-case
ESLint tests.