Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule Change: Add suggestion fixer to no-case-declarations #18349

Closed
1 task done
JoshuaKGoldberg opened this issue Apr 15, 2024 · 4 comments · Fixed by #18388
Closed
1 task done

Rule Change: Add suggestion fixer to no-case-declarations #18349

JoshuaKGoldberg opened this issue Apr 15, 2024 · 4 comments · Fixed by #18388
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@JoshuaKGoldberg
Copy link
Contributor

What rule do you want to change?

no-case-declarations

What change do you want to make?

Implement suggestions

How do you think the change should be implemented?

A new default behavior

Example code

/*eslint no-case-declarations: "error"*/

switch (foo) {
  case 1:
    let x = 1;
    break;
}

What does the rule currently do for this code?

No fixers or suggestions, per #15851.

What will the rule do after it's changed?

Add a suggestion to wrap the case 1's consequent in {}:

/*eslint no-case-declarations: "error"*/

switch (foo) {
  case 1: {
    let x = 1;
    break;
  }
}

Participation

  • I am willing to submit a pull request to implement this change.

Additional comments

The discussion in

@JoshuaKGoldberg JoshuaKGoldberg added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules labels Apr 15, 2024
@mdjermanovic
Copy link
Member

Add a suggestion to wrap the case 1's consequent in {}:

Makes sense to me 👍

This is exactly what the doccumentation for this rule is suggesting - examples of incorrect code are fixed by adding {} in examples of correct code.

@eslint/eslint-team thoughts?

Additional comments

The discussion in

Looks like something is missing here? :)

@aladdin-add
Copy link
Member

👍

@nzakas nzakas added the accepted There is consensus among the team that this change meets the criteria for inclusion label Apr 16, 2024
@nzakas
Copy link
Member

nzakas commented Apr 16, 2024

Makes sense. Go for it @JoshuaKGoldberg. 👍

@JoshuaKGoldberg
Copy link
Contributor Author

Looks like something is missing here? :)

Blurgh, just noticed this. It's a very annoying GitHub bug (https://twitter.com/JoshuaKGoldberg/status/1765397127675498870).

There was some discussion somewhere and I ... don't remember where. Blugh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
Status: Complete
Development

Successfully merging a pull request may close this issue.

4 participants