tools
tools copied to clipboard
🐛 Rule: useSingleCaseStatement considers break keyword as 2nd statement
Environment information
CLI:
Version: 10.0.1-nightly.00266da
Color support: true
Platform:
CPU Architecture: x86_64
OS: windows
Environment:
ROME_LOG_DIR: unset
NO_COLOR: unset
TERM: "xterm-256color"
Rome Configuration:
Status: loaded
Formatter disabled: false
Linter disabled: false
Workspace:
Open Documents: 0
Discovering running Rome servers...
Incompatible Rome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i Rage discovered this running server using an incompatible version of Rome.
Server:
Version: <=10.0.0
What happened?
The linter wants to insert blocks around any case that has a statement and a break statement:
Expected result
It should not flag <statement> break
as needing blocks.
Code of Conduct
- [X] I agree to follow Rome's Code of Conduct
I ran into this issue as well.
I am wondering why Rome did not choose to implement no-case-declarations?
👋 @rome/staff please triage this issue by adding one of the following labels: S-Bug: confirmed
, S-Planned
, S-Wishlist
or umbrella
I think we could replace this rule with useSwitchClauseBlock
which enforces block for every non-empty switch clauses (including single statement). The new rule could be a stylistic rule and be not recommended. Or we could add an option to useBlock
for covering this.
I think we could replace this rule with
useSwitchClauseBlock
which enforces block for every non-empty switch clauses (including single statement). The new rule could be a stylistic rule and be not recommended. Or we could add an option touseBlock
for covering this.
Since it is a very common use case to have one statement per case, and every non-fall-through case needs a break
, the rule should not flag <statement>; break;
as needing a block. The name of the rule and use case is otherwise fine.
The issue is that I don't see the purpose of this rule. I think it is only for stylistic consistency...
From version 11.0.0
, this rule has been moved to the style
group and is not recommended anymore.