]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-empty-label.md
6666960c03c6db3db5fc613c28e7caa9339863d2
[pve-eslint.git] / eslint / docs / src / rules / no-empty-label.md
1 ---
2 title: no-empty-label
3 layout: doc
4
5 related_rules:
6 - no-labels
7 - no-label-var
8 - no-unused-labels
9 ---
10
11 Disallows labels for anything other than loops and switches.
12
13 (removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [no-labels](no-labels) rule.
14
15 Labeled statements are only used in conjunction with labeled break and continue statements. ECMAScript has no goto statement.
16
17 ## Rule Details
18
19 This error occurs when a label is used to mark a statement that is not an iteration or switch
20
21 Example of **incorrect** code for this rule:
22
23 ::: incorrect
24
25 ```js
26 /*eslint no-empty-label: "error"*/
27
28 labeled:
29 var x = 10;
30 ```
31
32 :::
33
34 Example of **correct** code for this rule:
35
36 ::: correct
37
38 ```js
39 /*eslint no-empty-label: "error"*/
40
41 labeled:
42 for (var i=10; i; i--) {
43 // ...
44 }
45 ```
46
47 :::
48
49 ## When Not To Use It
50
51 If you don't want to be notified about usage of labels, then it's safe to disable this rule.