]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/docs/rules/padding-line-between-statements.md
import 7.12.1 upstream release
[pve-eslint.git] / eslint / docs / rules / padding-line-between-statements.md
index 1f2c4ab89508b5fb838ae180c97eaae3209e197b..2f2f67ee07cece632f315204626fbe2aee083010 100644 (file)
@@ -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.
@@ -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]