Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Docs: clarify "case" specifier in padding-line-between-statements (#1…
  • Loading branch information
mdjermanovic committed Aug 14, 2020
1 parent 082891c commit 26aa245
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions docs/rules/padding-line-between-statements.md
Expand Up @@ -48,14 +48,14 @@ You can supply any number of configurations. If a statement pair matches multipl
- `"block"` is lonely blocks.
- `"block-like"` is block like statements. This matches statements that the last token is the closing brace of blocks; e.g. `{ }`, `if (a) { }`, and `while (a) { }`. Also matches immediately invoked function expression statements.
- `"break"` is `break` statements.
- `"case"` is `case` labels.
- `"case"` is `case` clauses in `switch` statements.
- `"cjs-export"` is `export` statements of CommonJS; e.g. `module.exports = 0`, `module.exports.foo = 1`, and `exports.foo = 2`. This is a special case of assignment.
- `"cjs-import"` is `import` statements of CommonJS; e.g. `const foo = require("foo")`. This is a special case of variable declarations.
- `"class"` is `class` declarations.
- `"const"` is `const` variable declarations, both single-line and multiline.
- `"continue"` is `continue` statements.
- `"debugger"` is `debugger` statements.
- `"default"` is `default` labels.
- `"default"` is `default` clauses in `switch` statements.
- `"directive"` is directive prologues. This matches directives; e.g. `"use strict"`.
- `"do"` is `do-while` statements. This matches all statements that the first token is `do` keyword.
- `"empty"` is empty statements.
Expand Down Expand Up @@ -212,6 +212,55 @@ Examples of **correct** code for the `[{ blankLine: "always", prev: "directive",
foo();
```

----

This configuration would require blank lines between clauses in `switch` statements.

Examples of **incorrect** code for the `[{ blankLine: "always", prev: ["case", "default"], next: "*" }]` configuration:

```js
/*eslint padding-line-between-statements: [
"error",
{ blankLine: "always", prev: ["case", "default"], next: "*" }
]*/

switch (foo) {
case 1:
bar();
break;
case 2:
case 3:
baz();
break;
default:
quux();
}
```

Examples of **correct** code for the `[{ blankLine: "always", prev: ["case", "default"], next: "*" }]` configuration:

```js
/*eslint padding-line-between-statements: [
"error",
{ blankLine: "always", prev: ["case", "default"], next: "*" }
]*/

switch (foo) {
case 1:
bar();
break;

case 2:

case 3:
baz();
break;

default:
quux();
}
```

## Compatibility

- **JSCS:** [requirePaddingNewLineAfterVariableDeclaration]
Expand Down

0 comments on commit 26aa245

Please sign in to comment.