sonarjs/no-nested-switch
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/no-nested-switch": "error",
},
},
];function foo(n, m) {
switch (n) {
case 0:
switch (m) { // Noncompliant; nested switch
// ...
}
case 1:
// ...
default:
// ...
}
}function foo(n, m) {
switch (n) {
case 0:
bar(m);
case 1:
// ...
default:
// ...
}
}
function bar(m) {
switch(m) {
// ...
}
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
sonarjs/no-nested-switch
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-nested-switch": "error",
},
},
];Oxlint does not have this rule.
nursery/noNestedSwitch
nursery · since 2.6.0
{
"linter": {
"rules": {
"nursery": {
"noNestedSwitch": "error"
}
}
}
}Braces and parentheses should be used consistently with arrow functions
IAM policies should not grant access to all account resources
Optional boolean parameters should have default value
Class methods should be used instead of "prototype" assignments