1 # Enforce spacing around colons of switch statements (switch-colon-spacing)
3 Spacing around colons improves readability of `case`/`default` clauses.
7 This rule controls spacing around colons of `case` and `default` clauses in `switch` statements.
8 This rule does the check only if the consecutive tokens exist on the same line.
10 This rule has 2 options that are boolean value.
14 "switch-colon-spacing": ["error", {"after": true, "before": false}]
18 - `"after": true` (Default) requires one or more spaces after colons.
19 - `"after": false` disallows spaces after colons.
20 - `"before": true` requires one or more spaces before colons.
21 - `"before": false` (Default) disallows before colons.
24 Examples of **incorrect** code for this rule:
27 /*eslint switch-colon-spacing: "error"*/
35 Examples of **correct** code for this rule:
38 /*eslint switch-colon-spacing: "error"*/
51 Examples of **incorrect** code for this rule with `{"after": false, "before": true}` option:
54 /*eslint switch-colon-spacing: ["error", {"after": false, "before": true}]*/
62 Examples of **correct** code for this rule with `{"after": false, "before": true}` option:
65 /*eslint switch-colon-spacing: ["error", {"after": false, "before": true}]*/
80 If you don't want to notify spacing around colons of switch statements, then it's safe to disable this rule.