newline-before-case
- Group
- Style
- Path
lint/style/newline-before-case- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 274 of 512
Requires a blank line between successive switch statement case clauses.
The first clause is exempt, and grouped labels need no blank line between them. Nested switches are checked independently, including default clauses. Blank lines above attached comments count.
Invalid
void select(int value) {
switch (value) {
case 0:
print(0);
break;
case 1:
switch (value) {
case 1:
break;
default:
break;
}
break;
default:
break;
}
}
void commented(int value) {
switch (value) {
case 0:
break;
// No separating blank line.
default:
break;
}
} break; case 1: break; default: break; default: // No separating blank line. default:Valid
void select(int value) {
switch (value) {
case 0:
print(0);
break;
case 1:
switch (value) {
case 1:
break;
default:
break;
}
break;
default:
break;
}
}
void single(int value) {
switch (value) {
default:
break;
}
}
void grouped(int value) {
switch (value) {
case 0:
case 1:
print(value);
break;
// These labels share a body.
case 2:
case 3:
break;
/* The blank line precedes this comment. */
default:
break;
}
}Configure newline-before-case
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"newline-before-case": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/newline-before-case: <reason>More style rules
- newline-before-constructor
Requires a blank line before constructors following another member.
- newline-before-continue
Requires a blank line before a continue that follows another statement.
- newline-before-method
Requires a blank line before method declarations following another member.
- newline-before-return
newline-before-returnFlags
returnstatements that are not preceded by a blank line. - newline-before-throw
Requires a blank line before a throw that follows another statement.
- no-default-cases
no_default_casesFlags
default:in switch statements over enums and enum-like classes. - no-leading-underscores-for-library-prefixes
no_leading_underscores_for_library_prefixesrecommendedFlags import prefixes that begin with an underscore.
- no-leading-underscores-for-local-identifiers
no_leading_underscores_for_local_identifiersrecommendedFlags local variables and parameters whose names begin with an underscore.