Require newlines between switch cases.
The rule takes a first option of either "always" or "never" as to whether there should be a newline between cases. It also takes an object with the following options:
- fallthrough - "always" or "never" - whether or not to have newlines between cases that fallthrough to each other.
The following patterns are considered problems:
/*eslint switch-case/newline-between-switch-case: ["error", "always"]*/
switch (a) {
case 0:
case 1:
doSomething();
break;
case 2:
doSomething();
break;
}
The following patterns are not considered warnings:
/*eslint switch-case: "error"*/
/*eslint switch-case/newline-between-switch-case: ["error", "always"]*/
switch (a) {
case 0:
case 1:
doSomething();
break;
case 2:
doSomething();
break;
}
The following patterns are considered problems:
/*eslint switch-case/newline-between-switch-case: ["error", "always", { "fallthrough": "never"}]*/
switch (a) {
case 0:
case 1:
doSomething();
break;
}
The following patterns are not considered warnings:
/*eslint switch-case: "error"*/
/*eslint switch-case/newline-between-switch-case: ["error", "always", { "fallthrough": "never"}]*/
switch (a) {
case 0:
case 1:
doSomething();
break;
}
If you don't want to enforce newlines between switch cases.