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.
23 Examples of **incorrect** code for this rule:
26 /*eslint switch-colon-spacing: "error"*/
34 Examples of **correct** code for this rule:
37 /*eslint switch-colon-spacing: "error"*/
50 Examples of **incorrect** code for this rule with `{"after": false, "before": true}` option:
53 /*eslint switch-colon-spacing: ["error", {"after": false, "before": true}]*/
61 Examples of **correct** code for this rule with `{"after": false, "before": true}` option:
64 /*eslint switch-colon-spacing: ["error", {"after": false, "before": true}]*/
79 If you don't want to notify spacing around colons of switch statements, then it's safe to disable this rule.