New rule proposal: no-dupe-else-if
See original GitHub issuePlease describe what the rule should do:
Disallows duplicate test conditions in if-else-if
chains.
What category of rule is this? (place an “X” next to just one item)
[X] Warns about a potential error (problem)
Provide 2-3 code examples that this rule will warn about:
if (a > 1) {
foo();
} else if (a > 1) {
bar();
}
if (a === 1) {
foo();
} else if (a === 2) {
bar();
} else if (a === 3) {
baz();
} else if (a === 2) {
quux();
} else if (a === 5) {
quuux();
}
Why should this rule be included in ESLint (instead of a plugin)?
It’s a possible error. A statement with a duplicate condition can never execute (unless it’s an unusual use case with side effects).
This rule is similar to the existing no-duplicate-case
. The error could be due to a copy & paste and a long chain.
The test nodes would be compared by their tokens.
Are you willing to submit a pull request to implement this rule?
Yes.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7 (7 by maintainers)
Top Results From Across the Web
SEC Proposed Rules
SEC Proposed Rules · Regulation NMS: Minimum Pricing Increments, Access Fees, and Transparency of Better Priced Orders · File No: S7-30-22 · Comments...
Read more >Enhanced Disclosures by Certain Investment Advisers and ...
Proposed rule. SUMMARY: The Securities and Exchange Commission (“Commission”) is proposing to amend rules and forms under both the Investment ...
Read more >eslint | Yarn - Package Manager
A new rule is created. A new option to an existing rule that does not result in ESLint reporting more linting errors by...
Read more >ESLint equivalents in Elm
Comparing ESLint functionality and the equivalents in the Elm ecosystem.
Read more >disallow reassigning exceptions in catch clauses (no-ex- ...
Rule Details. This rule disallows reassigning exceptions in catch clauses. Examples of incorrect code for this rule: /*eslint no-ex-assign: "error"*/ try ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m working on this 😃
Now accepted 🎉