This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
🐛 Linter js/noNegationElse becomes unreadable with else if blocks #2999
Labels
A-Linter
Area: linter
L-JavaScript
Langauge: JavaScript
S-Bug: confirmed
Status: report has been confirmed as a valid bug
Milestone
Environment information
What happened?
When applying the "fix" for noNegationElse, the code becomes more unreadable and takes several distinct "fix" actions to fix it.
Becomes
Which prompts for wrapping it in a block statement (which is definitely needed to be readable), and then prompts for another noNegationElse fix to finally a very nested mess:
This set of chaining fixes will continue on for every not condition in a chain, so if you have more conditions it will end up becoming more nested
Expected result
When working with chains of if/else if values, I believe that this linter rule should ignore them given how much harder it is to read with only 1
else if
. Potentially a fix for this issue would be to make it so that only if/else pairs withoutelse if
blocks values are considered for this lint rule.With even more sets in the chain, it becomes nearly impossible to read the end result.
For example this set of if/else if/else blocks takes 7 individual refactor fix commands
and becomes this mess:
Code of Conduct
The text was updated successfully, but these errors were encountered: