Closed hougesen closed 11 months ago
Can I take this issue.
Also which rule is better to address this problem, check condition in useSingleCaseStatement
when there is no declaration in it or to check noUselessLoneBlockStatements
.
Also which rule is better to address this problem, check condition in useSingleCaseStatement when there is no declaration in it or to check noUselessLoneBlockStatements.
Assigned :)
noUselessLoneBlockStatements
should ignore a block statement on a case.
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