Allow disable of SwitchCase indent rule
See original GitHub issueI like my switch case statements to be indented like so:
switch (foo) {
case "bar":
//...
break;
case "xyz":
//...
break;
default:
//....
}
As the current indent rules don’t allow enforcing this, perhaps it would be a good option to allow {“SwitchCase”: “off”} to be an option for the “indent” rule config.
More info:
- What rule do you want to change? indent
- Does this change cause the rule to produce more or fewer warnings? Fewer
- How will the change be implemented? (New option, new default behavior, etc.)? New value for SwitchCase option.
- Please provide some example code that this change will affect:
switch (foo) {
case "bar":
//...
break;
case "xyz":
//...
break;
default:
//....
}
- What does the rule currently do for this code? Produces error/warning about ‘case’ indentation.
- What will the rule do after it’s changed? Produce no error/warning.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Cannot fix eslint rule on indenting case statements in switch ...
I just saw that you made an edit ("EDIT 2") to your answer. Anyway I wanted to advise you exactly that option: "indent":...
Read more >indent - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Apply Eslint rules doesn't work for the switch case statement
I applied the eslint code style rules so that I can use the webstorm formatter to format my code. Unfortunatelly, the switch case...
Read more >Optional Braces - Scala 3 - EPFL
Scala 3 enforces some rules on indentation and allows some occurrences of braces {...} to be optional: ... These changes can be turned...
Read more >indent - Rules - ESLint中文文档
This can also be set to "off" to disable checking for MemberExpression ... Indent of 2 spaces with SwitchCase set to 1 will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get enough support from the team and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after a long time tend to never do it, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.
Hi @jez9999, we can certainly consider a rule enhancement request for this use case. That said, could you please follow the link provided by eslintbot above and edit your post per the instructions on that page? It really helps us to have all the information filled out in your first post.
I also wanted to note that as a workaround, you could disable the indent rule within the switch statement: