Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

🐛 Rule: useSingleCaseStatement considers break keyword as 2nd statement #3781

Closed
1 task done
ysageev opened this issue Nov 17, 2022 · 7 comments
Closed
1 task done
Labels
S-To triage Status: user report of a possible bug that needs to be triaged

Comments

@ysageev
Copy link

ysageev commented Nov 17, 2022

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:

image

Expected result

It should not flag <statement> break as needing blocks.

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@ysageev ysageev added the S-To triage Status: user report of a possible bug that needs to be triaged label Nov 17, 2022
@sebmellen
Copy link

I ran into this issue as well.

@Conaclos
Copy link
Contributor

I am wondering why Rome did not choose to implement no-case-declarations?

@github-actions
Copy link

github-actions bot commented Dec 2, 2022

👋 @rome/staff please triage this issue by adding one of the following labels: S-Bug: confirmed, S-Planned , S-Wishlist or umbrella

@Conaclos
Copy link
Contributor

Conaclos commented Dec 2, 2022

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.

@ysageev
Copy link
Author

ysageev commented Dec 2, 2022

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.

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.

@Conaclos
Copy link
Contributor

Conaclos commented Dec 2, 2022

The issue is that I don't see the purpose of this rule. I think it is only for stylistic consistency...

@ematipico
Copy link
Contributor

ematipico commented Dec 7, 2022

From version 11.0.0, this rule has been moved to the style group and is not recommended anymore.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-To triage Status: user report of a possible bug that needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants