💅 noUselessLoneBlockStatements collides with useSingleCaseStatement when using switch #834
Closed
1 task done
Labels
A-Linter
Area: linter
L-JavaScript
Language: JavaScript and super languages
S-Bug-confirmed
Status: report has been confirmed as a valid bug
S-Help-wanted
Status: you're familiar with the code base and want to help the project
Environment information
Rule name
noUselessLoneBlockStatements
Playground link
https://biomejs.dev/playground/?indentStyle=space"eStyle=single&trailingComma=none&lintRules=all&code=cwB3AGkAdABjAGgAIAAoADEAKQAgAHsACgAgACAALwAvACAAdQBzAGUAUwBpAG4AZwBsAGUAQwBhAHMAZQBTAHQAYQB0AGUAbQBlAG4AdAAgAGkAcwAgAHQAcgBpAGcAZwBlAHIAZQBkAAoAIAAgAGQAZQBmAGEAdQBsAHQAOgAKACAAIAAgACAAYwBvAG4AcwBvAGwAZQAuAGkAbgBmAG8AKAAnADEAJwApADsACgAgACAAIAAgAGMAbwBuAHMAbwBsAGUALgBpAG4AZgBvACgAJwAyACcAKQA7AAoAIAAgACAAIABiAHIAZQBhAGsAOwAKAH0ACgAKAHMAdwBpAHQAYwBoACAAKAAxACkAIAB7AAoAIAAgAC8ALwAgAG4AbwBVAHMAZQBsAGUAcwBzAEwAbwBuAGUAQgBsAG8AYwBrAFMAdABhAHQAZQBtAGUAbgB0AHMAIABpAHMAIAB0AHIAaQBnAGcAZQByAGUAZAAKACAAIABkAGUAZgBhAHUAbAB0ADoAIAB7AAoAIAAgACAAIABjAG8AbgBzAG8AbABlAC4AaQBuAGYAbwAoACcAMQAnACkAOwAKACAAIAAgACAAYwBvAG4AcwBvAGwAZQAuAGkAbgBmAG8AKAAnADIAJwApADsACgAgACAAIAAgAGIAcgBlAGEAawA7AAoAIAAgAH0ACgB9AAoACgBzAHcAaQB0AGMAaAAgACgAMQApACAAewAKACAAIAAvAC8AIABuAG8AIAByAHUAbABlAHMAIABhAHIAZQAgAHQAcgBpAGcAZwBlAHIAZQBkAAoAIAAgAGQAZQBmAGEAdQBsAHQAOgAgAHsACgAgACAAIAAgAGMAbwBuAHMAdAAgAF8AIAA9ACAAJwAnADsACgAgACAAIAAgAGMAbwBuAHMAbwBsAGUALgBpAG4AZgBvACgAJwAxACcAKQA7AAoAIAAgACAAIABjAG8AbgBzAG8AbABlAC4AaQBuAGYAbwAoACcAMgAnACkAOwAKACAAIAAgACAAYgByAGUAYQBrADsACgAgACAAfQAKAH0ACgA%3D
Expected result
When both
noUselessLoneBlockStatements
anduseSingleCaseStatement
are turned on there will be an endless loop of "fixes" since they try to change the fix for each other.The following code triggers the
useSingleCaseStatement
("A switch clause should only have a single statement"):When using the auto-fix the code is turned into the following:
Which then triggers
noUselessLoneBlockStatements
. Using the auto-fix fornoUselessLoneBlockStatements
will turn the code into the first code snippet (again).The
noUselessLoneBlockStatements
rule works as expected when there is a variable declaration:Code of Conduct
The text was updated successfully, but these errors were encountered: