1 | /**
|
2 | * @fileoverview Rule to flag when label is not used for a loop or switch
|
3 | * @author Ilya Volodin
|
4 | */
|
5 |
|
6 | ;
|
7 |
|
8 | //------------------------------------------------------------------------------
|
9 | // Rule Definition
|
10 | //------------------------------------------------------------------------------
|
11 |
|
12 | module.exports = function(context) {
|
13 |
|
14 | return {
|
15 |
|
16 | "LabeledStatement": function(node) {
|
17 | var type = node.body.type;
|
18 |
|
19 | if (type !== "ForStatement" && type !== "WhileStatement" && type !== "DoWhileStatement" && type !== "SwitchStatement" && type !== "ForInStatement" && type !== "ForOfStatement") {
|
20 | context.report(node, "Unexpected label '{{l}}'", {l: node.label.name});
|
21 | }
|
22 | }
|
23 | };
|
24 |
|
25 | };
|
26 |
|
27 | module.exports.schema = [];
|