eslint 4.15.0 → 4.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/lib/config/config-validator.js +9 -2
- package/lib/linter.js +38 -19
- package/lib/options.js +7 -7
- package/lib/report-translator.js +28 -37
- package/lib/rules/accessor-pairs.js +7 -3
- package/lib/rules/array-bracket-newline.js +11 -5
- package/lib/rules/array-bracket-spacing.js +11 -5
- package/lib/rules/array-callback-return.js +11 -5
- package/lib/rules/array-element-newline.js +8 -3
- package/lib/rules/arrow-body-style.js +16 -8
- package/lib/rules/arrow-parens.js +13 -9
- package/lib/rules/arrow-spacing.js +13 -5
- package/lib/rules/block-scoped-var.js +6 -2
- package/lib/rules/block-spacing.js +13 -6
- package/lib/rules/brace-style.js +16 -14
- package/lib/rules/callback-return.js +6 -2
- package/lib/rules/camelcase.js +6 -2
- package/lib/rules/capitalized-comments.js +11 -8
- package/lib/rules/class-methods-use-this.js +7 -3
- package/lib/rules/comma-dangle.js +7 -4
- package/lib/rules/comma-spacing.js +13 -10
- package/lib/rules/comma-style.js +16 -5
- package/lib/rules/complexity.js +6 -2
- package/lib/rules/computed-property-spacing.js +13 -5
- package/lib/rules/consistent-return.js +12 -7
- package/lib/rules/consistent-this.js +9 -4
- package/lib/rules/constructor-super.js +17 -8
- package/lib/rules/curly.js +59 -80
- package/lib/rules/default-case.js +6 -2
- package/lib/rules/dot-location.js +8 -3
- package/lib/rules/dot-notation.js +10 -5
- package/lib/rules/eol-last.js +7 -3
- package/lib/rules/eqeqeq.js +6 -2
- package/lib/rules/guard-for-in.js +35 -7
- package/lib/rules/indent.js +4 -4
- package/lib/rules/key-spacing.js +3 -2
- package/lib/rules/keyword-spacing.js +6 -1
- package/lib/rules/no-alert.js +19 -18
- package/lib/rules/no-array-constructor.js +6 -2
- package/lib/rules/no-await-in-loop.js +75 -57
- package/lib/rules/no-bitwise.js +6 -2
- package/lib/rules/no-buffer-constructor.js +6 -3
- package/lib/rules/no-caller.js +6 -2
- package/lib/rules/no-case-declarations.js +6 -2
- package/lib/rules/no-catch-shadow.js +6 -2
- package/lib/rules/no-class-assign.js +6 -2
- package/lib/rules/no-compare-neg-zero.js +5 -2
- package/lib/rules/no-cond-assign.js +10 -4
- package/lib/rules/no-confusing-arrow.js +6 -2
- package/lib/rules/no-console.js +6 -2
- package/lib/rules/no-const-assign.js +6 -2
- package/lib/rules/no-constant-condition.js +6 -3
- package/lib/rules/no-continue.js +6 -2
- package/lib/rules/no-control-regex.js +7 -3
- package/lib/rules/no-debugger.js +5 -2
- package/lib/rules/no-delete-var.js +6 -2
- package/lib/rules/no-div-regex.js +6 -2
- package/lib/rules/no-dupe-args.js +6 -2
- package/lib/rules/no-dupe-class-members.js +6 -2
- package/lib/rules/no-dupe-keys.js +6 -2
- package/lib/rules/no-duplicate-case.js +6 -2
- package/lib/rules/no-else-return.js +7 -2
- package/lib/rules/no-empty-character-class.js +6 -2
- package/lib/rules/no-empty-function.js +6 -2
- package/lib/rules/no-empty-pattern.js +7 -3
- package/lib/rules/no-empty.js +7 -3
- package/lib/rules/no-eq-null.js +6 -2
- package/lib/rules/no-eval.js +6 -2
- package/lib/rules/no-ex-assign.js +6 -2
- package/lib/rules/no-extend-native.js +6 -2
- package/lib/rules/no-extra-bind.js +6 -2
- package/lib/rules/no-extra-boolean-cast.js +8 -3
- package/lib/rules/no-extra-label.js +6 -2
- package/lib/rules/no-extra-parens.js +5 -1
- package/lib/rules/no-extra-semi.js +6 -2
- package/lib/rules/no-self-assign.js +3 -1
- package/lib/rules/no-unused-vars.js +1 -1
- package/lib/rules/object-curly-newline.js +67 -19
- package/lib/rules/object-property-newline.js +8 -2
- package/lib/rules/object-shorthand.js +9 -7
- package/lib/rules/padding-line-between-statements.js +6 -0
- package/lib/rules/prefer-destructuring.js +4 -2
- package/lib/rules/require-await.js +5 -0
- package/lib/rules/rest-spread-spacing.js +6 -0
- package/lib/rules/space-unary-ops.js +1 -10
- package/lib/rules/valid-jsdoc.js +89 -28
- package/lib/util/glob-util.js +17 -4
- package/lib/util/npm-util.js +1 -1
- package/package.json +2 -2
@@ -4,24 +4,54 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
/**
|
8
|
+
* Check whether it should stop traversing ancestors at the given node.
|
9
|
+
* @param {ASTNode} node A node to check.
|
10
|
+
* @returns {boolean} `true` if it should stop traversing.
|
11
|
+
*/
|
12
|
+
function isBoundary(node) {
|
13
|
+
const t = node.type;
|
14
|
+
|
15
|
+
return (
|
16
|
+
t === "FunctionDeclaration" ||
|
17
|
+
t === "FunctionExpression" ||
|
18
|
+
t === "ArrowFunctionExpression" ||
|
19
|
+
|
20
|
+
/*
|
21
|
+
* Don't report the await expressions on for-await-of loop since it's
|
22
|
+
* asynchronous iteration intentionally.
|
23
|
+
*/
|
24
|
+
(t === "ForOfStatement" && node.await === true)
|
25
|
+
);
|
26
|
+
}
|
15
27
|
|
16
|
-
|
17
|
-
*
|
18
|
-
*
|
28
|
+
/**
|
29
|
+
* Check whether the given node is in loop.
|
30
|
+
* @param {ASTNode} node A node to check.
|
31
|
+
* @param {ASTNode} parent A parent node to check.
|
32
|
+
* @returns {boolean} `true` if the node is in loop.
|
19
33
|
*/
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
34
|
+
function isLooped(node, parent) {
|
35
|
+
switch (parent.type) {
|
36
|
+
case "ForStatement":
|
37
|
+
return (
|
38
|
+
node === parent.test ||
|
39
|
+
node === parent.update ||
|
40
|
+
node === parent.body
|
41
|
+
);
|
42
|
+
|
43
|
+
case "ForOfStatement":
|
44
|
+
case "ForInStatement":
|
45
|
+
return node === parent.body;
|
46
|
+
|
47
|
+
case "WhileStatement":
|
48
|
+
case "DoWhileStatement":
|
49
|
+
return node === parent.test || node === parent.body;
|
50
|
+
|
51
|
+
default:
|
52
|
+
return false;
|
53
|
+
}
|
54
|
+
}
|
25
55
|
|
26
56
|
module.exports = {
|
27
57
|
meta: {
|
@@ -31,54 +61,42 @@ module.exports = {
|
|
31
61
|
recommended: false,
|
32
62
|
url: "https://eslint.org/docs/rules/no-await-in-loop"
|
33
63
|
},
|
34
|
-
schema: []
|
64
|
+
schema: [],
|
65
|
+
messages: {
|
66
|
+
unexpectedAwait: "Unexpected `await` inside a loop."
|
67
|
+
}
|
35
68
|
},
|
36
69
|
create(context) {
|
37
|
-
return {
|
38
|
-
AwaitExpression(node) {
|
39
|
-
const ancestors = context.getAncestors();
|
40
|
-
|
41
|
-
// Reverse so that we can traverse from the deepest node upwards.
|
42
|
-
ancestors.reverse();
|
43
|
-
|
44
|
-
/*
|
45
|
-
* Create a set of all the ancestors plus this node so that we can check
|
46
|
-
* if this use of await appears in the body of the loop as opposed to
|
47
|
-
* the right-hand side of a for...of, for example.
|
48
|
-
*/
|
49
|
-
const ancestorSet = new Set(ancestors).add(node);
|
50
70
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
71
|
+
/**
|
72
|
+
* Validate an await expression.
|
73
|
+
* @param {ASTNode} awaitNode An AwaitExpression or ForOfStatement node to validate.
|
74
|
+
* @returns {void}
|
75
|
+
*/
|
76
|
+
function validate(awaitNode) {
|
77
|
+
if (awaitNode.type === "ForOfStatement" && !awaitNode.await) {
|
78
|
+
return;
|
79
|
+
}
|
55
80
|
|
56
|
-
|
57
|
-
|
58
|
-
* this do not matter.
|
59
|
-
*/
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
if (loopTypes.has(ancestor.type)) {
|
81
|
+
let node = awaitNode;
|
82
|
+
let parent = node.parent;
|
63
83
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
ancestorSet.has(ancestor.update)
|
72
|
-
) {
|
73
|
-
context.report({
|
74
|
-
node,
|
75
|
-
message: "Unexpected `await` inside a loop."
|
76
|
-
});
|
77
|
-
return;
|
78
|
-
}
|
79
|
-
}
|
84
|
+
while (parent && !isBoundary(parent)) {
|
85
|
+
if (isLooped(node, parent)) {
|
86
|
+
context.report({
|
87
|
+
node: awaitNode,
|
88
|
+
messageId: "unexpectedAwait"
|
89
|
+
});
|
90
|
+
return;
|
80
91
|
}
|
92
|
+
node = parent;
|
93
|
+
parent = parent.parent;
|
81
94
|
}
|
95
|
+
}
|
96
|
+
|
97
|
+
return {
|
98
|
+
AwaitExpression: validate,
|
99
|
+
ForOfStatement: validate
|
82
100
|
};
|
83
101
|
}
|
84
102
|
};
|
package/lib/rules/no-bitwise.js
CHANGED
@@ -46,7 +46,11 @@ module.exports = {
|
|
46
46
|
},
|
47
47
|
additionalProperties: false
|
48
48
|
}
|
49
|
-
]
|
49
|
+
],
|
50
|
+
|
51
|
+
messages: {
|
52
|
+
unexpected: "Unexpected use of '{{operator}}'."
|
53
|
+
}
|
50
54
|
},
|
51
55
|
|
52
56
|
create(context) {
|
@@ -60,7 +64,7 @@ module.exports = {
|
|
60
64
|
* @returns {void}
|
61
65
|
*/
|
62
66
|
function report(node) {
|
63
|
-
context.report({ node,
|
67
|
+
context.report({ node, messageId: "unexpected", data: { operator: node.operator } });
|
64
68
|
}
|
65
69
|
|
66
70
|
/**
|
@@ -16,7 +16,10 @@ module.exports = {
|
|
16
16
|
recommended: false,
|
17
17
|
url: "https://eslint.org/docs/rules/no-buffer-constructor"
|
18
18
|
},
|
19
|
-
schema: []
|
19
|
+
schema: [],
|
20
|
+
messages: {
|
21
|
+
deprecated: "{{expr}} is deprecated. Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead."
|
22
|
+
}
|
20
23
|
},
|
21
24
|
|
22
25
|
create(context) {
|
@@ -29,8 +32,8 @@ module.exports = {
|
|
29
32
|
"CallExpression[callee.name='Buffer'], NewExpression[callee.name='Buffer']"(node) {
|
30
33
|
context.report({
|
31
34
|
node,
|
32
|
-
|
33
|
-
data: {
|
35
|
+
messageId: "deprecated",
|
36
|
+
data: { expr: node.type === "CallExpression" ? "Buffer()" : "new Buffer()" }
|
34
37
|
});
|
35
38
|
}
|
36
39
|
};
|
package/lib/rules/no-caller.js
CHANGED
@@ -18,7 +18,11 @@ module.exports = {
|
|
18
18
|
url: "https://eslint.org/docs/rules/no-caller"
|
19
19
|
},
|
20
20
|
|
21
|
-
schema: []
|
21
|
+
schema: [],
|
22
|
+
|
23
|
+
messages: {
|
24
|
+
unexpected: "Avoid arguments.{{prop}}."
|
25
|
+
}
|
22
26
|
},
|
23
27
|
|
24
28
|
create(context) {
|
@@ -30,7 +34,7 @@ module.exports = {
|
|
30
34
|
propertyName = node.property.name;
|
31
35
|
|
32
36
|
if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/)) {
|
33
|
-
context.report({ node,
|
37
|
+
context.report({ node, messageId: "unexpected", data: { prop: propertyName } });
|
34
38
|
}
|
35
39
|
|
36
40
|
}
|
@@ -17,7 +17,11 @@ module.exports = {
|
|
17
17
|
url: "https://eslint.org/docs/rules/no-case-declarations"
|
18
18
|
},
|
19
19
|
|
20
|
-
schema: []
|
20
|
+
schema: [],
|
21
|
+
|
22
|
+
messages: {
|
23
|
+
unexpected: "Unexpected lexical declaration in case block."
|
24
|
+
}
|
21
25
|
},
|
22
26
|
|
23
27
|
create(context) {
|
@@ -47,7 +51,7 @@ module.exports = {
|
|
47
51
|
if (isLexicalDeclaration(statement)) {
|
48
52
|
context.report({
|
49
53
|
node,
|
50
|
-
|
54
|
+
messageId: "unexpected"
|
51
55
|
});
|
52
56
|
}
|
53
57
|
}
|
@@ -24,7 +24,11 @@ module.exports = {
|
|
24
24
|
url: "https://eslint.org/docs/rules/no-catch-shadow"
|
25
25
|
},
|
26
26
|
|
27
|
-
schema: []
|
27
|
+
schema: [],
|
28
|
+
|
29
|
+
messages: {
|
30
|
+
mutable: "Value of '{{name}}' may be overwritten in IE 8 and earlier."
|
31
|
+
}
|
28
32
|
},
|
29
33
|
|
30
34
|
create(context) {
|
@@ -61,7 +65,7 @@ module.exports = {
|
|
61
65
|
}
|
62
66
|
|
63
67
|
if (paramIsShadowing(scope, node.param.name)) {
|
64
|
-
context.report({ node,
|
68
|
+
context.report({ node, messageId: "mutable", data: { name: node.param.name } });
|
65
69
|
}
|
66
70
|
}
|
67
71
|
};
|
@@ -20,7 +20,11 @@ module.exports = {
|
|
20
20
|
url: "https://eslint.org/docs/rules/no-class-assign"
|
21
21
|
},
|
22
22
|
|
23
|
-
schema: []
|
23
|
+
schema: [],
|
24
|
+
|
25
|
+
messages: {
|
26
|
+
class: "'{{name}}' is a class."
|
27
|
+
}
|
24
28
|
},
|
25
29
|
|
26
30
|
create(context) {
|
@@ -32,7 +36,7 @@ module.exports = {
|
|
32
36
|
*/
|
33
37
|
function checkVariable(variable) {
|
34
38
|
astUtils.getModifyingReferences(variable.references).forEach(reference => {
|
35
|
-
context.report({ node: reference.identifier,
|
39
|
+
context.report({ node: reference.identifier, messageId: "class", data: { name: reference.identifier.name } });
|
36
40
|
|
37
41
|
});
|
38
42
|
}
|
@@ -17,7 +17,10 @@ module.exports = {
|
|
17
17
|
url: "https://eslint.org/docs/rules/no-compare-neg-zero"
|
18
18
|
},
|
19
19
|
fixable: null,
|
20
|
-
schema: []
|
20
|
+
schema: [],
|
21
|
+
messages: {
|
22
|
+
unexpected: "Do not use the '{{operator}}' operator to compare against -0."
|
23
|
+
}
|
21
24
|
},
|
22
25
|
|
23
26
|
create(context) {
|
@@ -43,7 +46,7 @@ module.exports = {
|
|
43
46
|
if (isNegZero(node.left) || isNegZero(node.right)) {
|
44
47
|
context.report({
|
45
48
|
node,
|
46
|
-
|
49
|
+
messageId: "unexpected",
|
47
50
|
data: { operator: node.operator }
|
48
51
|
});
|
49
52
|
}
|
@@ -30,7 +30,14 @@ module.exports = {
|
|
30
30
|
{
|
31
31
|
enum: ["except-parens", "always"]
|
32
32
|
}
|
33
|
-
]
|
33
|
+
],
|
34
|
+
|
35
|
+
messages: {
|
36
|
+
unexpected: "Unexpected assignment within {{type}}.",
|
37
|
+
|
38
|
+
// must match JSHint's error message
|
39
|
+
missing: "Expected a conditional expression and instead saw an assignment."
|
40
|
+
}
|
34
41
|
},
|
35
42
|
|
36
43
|
create(context) {
|
@@ -95,11 +102,10 @@ module.exports = {
|
|
95
102
|
)
|
96
103
|
) {
|
97
104
|
|
98
|
-
// must match JSHint's error message
|
99
105
|
context.report({
|
100
106
|
node,
|
101
107
|
loc: node.test.loc.start,
|
102
|
-
|
108
|
+
messageId: "missing"
|
103
109
|
});
|
104
110
|
}
|
105
111
|
}
|
@@ -115,7 +121,7 @@ module.exports = {
|
|
115
121
|
if (ancestor) {
|
116
122
|
context.report({
|
117
123
|
node: ancestor,
|
118
|
-
|
124
|
+
messageId: "unexpected",
|
119
125
|
data: {
|
120
126
|
type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type
|
121
127
|
}
|
@@ -42,7 +42,11 @@ module.exports = {
|
|
42
42
|
allowParens: { type: "boolean" }
|
43
43
|
},
|
44
44
|
additionalProperties: false
|
45
|
-
}]
|
45
|
+
}],
|
46
|
+
|
47
|
+
messages: {
|
48
|
+
confusing: "Arrow function used ambiguously with a conditional expression."
|
49
|
+
}
|
46
50
|
},
|
47
51
|
|
48
52
|
create(context) {
|
@@ -60,7 +64,7 @@ module.exports = {
|
|
60
64
|
if (isConditional(body) && !(config.allowParens && astUtils.isParenthesised(sourceCode, body))) {
|
61
65
|
context.report({
|
62
66
|
node,
|
63
|
-
|
67
|
+
messageId: "confusing",
|
64
68
|
fix(fixer) {
|
65
69
|
|
66
70
|
// if `allowParens` is not set to true dont bother wrapping in parens
|
package/lib/rules/no-console.js
CHANGED
@@ -39,7 +39,11 @@ module.exports = {
|
|
39
39
|
},
|
40
40
|
additionalProperties: false
|
41
41
|
}
|
42
|
-
]
|
42
|
+
],
|
43
|
+
|
44
|
+
messages: {
|
45
|
+
unexpected: "Unexpected console statement."
|
46
|
+
}
|
43
47
|
},
|
44
48
|
|
45
49
|
create(context) {
|
@@ -102,7 +106,7 @@ module.exports = {
|
|
102
106
|
context.report({
|
103
107
|
node,
|
104
108
|
loc: node.loc,
|
105
|
-
|
109
|
+
messageId: "unexpected"
|
106
110
|
});
|
107
111
|
}
|
108
112
|
|
@@ -20,7 +20,11 @@ module.exports = {
|
|
20
20
|
url: "https://eslint.org/docs/rules/no-const-assign"
|
21
21
|
},
|
22
22
|
|
23
|
-
schema: []
|
23
|
+
schema: [],
|
24
|
+
|
25
|
+
messages: {
|
26
|
+
const: "'{{name}}' is constant."
|
27
|
+
}
|
24
28
|
},
|
25
29
|
|
26
30
|
create(context) {
|
@@ -32,7 +36,7 @@ module.exports = {
|
|
32
36
|
*/
|
33
37
|
function checkVariable(variable) {
|
34
38
|
astUtils.getModifyingReferences(variable.references).forEach(reference => {
|
35
|
-
context.report({ node: reference.identifier,
|
39
|
+
context.report({ node: reference.identifier, messageId: "const", data: { name: reference.identifier.name } });
|
36
40
|
});
|
37
41
|
}
|
38
42
|
|
@@ -28,8 +28,11 @@ module.exports = {
|
|
28
28
|
},
|
29
29
|
additionalProperties: false
|
30
30
|
}
|
31
|
+
],
|
31
32
|
|
32
|
-
|
33
|
+
messages: {
|
34
|
+
unexpected: "Unexpected constant condition."
|
35
|
+
}
|
33
36
|
},
|
34
37
|
|
35
38
|
create(context) {
|
@@ -139,7 +142,7 @@ module.exports = {
|
|
139
142
|
function checkConstantConditionLoopInSet(node) {
|
140
143
|
if (loopsInCurrentScope.has(node)) {
|
141
144
|
loopsInCurrentScope.delete(node);
|
142
|
-
context.report({ node: node.test,
|
145
|
+
context.report({ node: node.test, messageId: "unexpected" });
|
143
146
|
}
|
144
147
|
}
|
145
148
|
|
@@ -151,7 +154,7 @@ module.exports = {
|
|
151
154
|
*/
|
152
155
|
function reportIfConstant(node) {
|
153
156
|
if (node.test && isConstant(node.test, true)) {
|
154
|
-
context.report({ node: node.test,
|
157
|
+
context.report({ node: node.test, messageId: "unexpected" });
|
155
158
|
}
|
156
159
|
}
|
157
160
|
|
package/lib/rules/no-continue.js
CHANGED
@@ -18,14 +18,18 @@ module.exports = {
|
|
18
18
|
url: "https://eslint.org/docs/rules/no-continue"
|
19
19
|
},
|
20
20
|
|
21
|
-
schema: []
|
21
|
+
schema: [],
|
22
|
+
|
23
|
+
messages: {
|
24
|
+
unexpected: "Unexpected use of continue statement."
|
25
|
+
}
|
22
26
|
},
|
23
27
|
|
24
28
|
create(context) {
|
25
29
|
|
26
30
|
return {
|
27
31
|
ContinueStatement(node) {
|
28
|
-
context.report({ node,
|
32
|
+
context.report({ node, messageId: "unexpected" });
|
29
33
|
}
|
30
34
|
};
|
31
35
|
|
@@ -18,7 +18,11 @@ module.exports = {
|
|
18
18
|
url: "https://eslint.org/docs/rules/no-control-regex"
|
19
19
|
},
|
20
20
|
|
21
|
-
schema: []
|
21
|
+
schema: [],
|
22
|
+
|
23
|
+
messages: {
|
24
|
+
unexpected: "Unexpected control character(s) in regular expression: {{controlChars}}."
|
25
|
+
}
|
22
26
|
},
|
23
27
|
|
24
28
|
create(context) {
|
@@ -26,7 +30,7 @@ module.exports = {
|
|
26
30
|
/**
|
27
31
|
* Get the regex expression
|
28
32
|
* @param {ASTNode} node node to evaluate
|
29
|
-
* @returns {
|
33
|
+
* @returns {RegExp|null} Regex if found else null
|
30
34
|
* @private
|
31
35
|
*/
|
32
36
|
function getRegExp(node) {
|
@@ -114,7 +118,7 @@ module.exports = {
|
|
114
118
|
if (controlCharacters.length > 0) {
|
115
119
|
context.report({
|
116
120
|
node,
|
117
|
-
|
121
|
+
messageId: "unexpected",
|
118
122
|
data: {
|
119
123
|
controlChars: controlCharacters.join(", ")
|
120
124
|
}
|
package/lib/rules/no-debugger.js
CHANGED
@@ -20,7 +20,10 @@ module.exports = {
|
|
20
20
|
url: "https://eslint.org/docs/rules/no-debugger"
|
21
21
|
},
|
22
22
|
fixable: "code",
|
23
|
-
schema: []
|
23
|
+
schema: [],
|
24
|
+
messages: {
|
25
|
+
unexpected: "Unexpected 'debugger' statement."
|
26
|
+
}
|
24
27
|
},
|
25
28
|
|
26
29
|
create(context) {
|
@@ -29,7 +32,7 @@ module.exports = {
|
|
29
32
|
DebuggerStatement(node) {
|
30
33
|
context.report({
|
31
34
|
node,
|
32
|
-
|
35
|
+
messageId: "unexpected",
|
33
36
|
fix(fixer) {
|
34
37
|
if (astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
|
35
38
|
return fixer.remove(node);
|
@@ -18,7 +18,11 @@ module.exports = {
|
|
18
18
|
url: "https://eslint.org/docs/rules/no-delete-var"
|
19
19
|
},
|
20
20
|
|
21
|
-
schema: []
|
21
|
+
schema: [],
|
22
|
+
|
23
|
+
messages: {
|
24
|
+
unexpected: "Variables should not be deleted."
|
25
|
+
}
|
22
26
|
},
|
23
27
|
|
24
28
|
create(context) {
|
@@ -27,7 +31,7 @@ module.exports = {
|
|
27
31
|
|
28
32
|
UnaryExpression(node) {
|
29
33
|
if (node.operator === "delete" && node.argument.type === "Identifier") {
|
30
|
-
context.report({ node,
|
34
|
+
context.report({ node, messageId: "unexpected" });
|
31
35
|
}
|
32
36
|
}
|
33
37
|
};
|
@@ -18,7 +18,11 @@ module.exports = {
|
|
18
18
|
url: "https://eslint.org/docs/rules/no-div-regex"
|
19
19
|
},
|
20
20
|
|
21
|
-
schema: []
|
21
|
+
schema: [],
|
22
|
+
|
23
|
+
messages: {
|
24
|
+
unexpected: "A regular expression literal can be confused with '/='."
|
25
|
+
}
|
22
26
|
},
|
23
27
|
|
24
28
|
create(context) {
|
@@ -30,7 +34,7 @@ module.exports = {
|
|
30
34
|
const token = sourceCode.getFirstToken(node);
|
31
35
|
|
32
36
|
if (token.type === "RegularExpression" && token.value[1] === "=") {
|
33
|
-
context.report({ node,
|
37
|
+
context.report({ node, messageId: "unexpected" });
|
34
38
|
}
|
35
39
|
}
|
36
40
|
};
|
@@ -18,7 +18,11 @@ module.exports = {
|
|
18
18
|
url: "https://eslint.org/docs/rules/no-dupe-args"
|
19
19
|
},
|
20
20
|
|
21
|
-
schema: []
|
21
|
+
schema: [],
|
22
|
+
|
23
|
+
messages: {
|
24
|
+
unexpected: "Duplicate param '{{name}}'."
|
25
|
+
}
|
22
26
|
},
|
23
27
|
|
24
28
|
create(context) {
|
@@ -54,7 +58,7 @@ module.exports = {
|
|
54
58
|
if (defs.length >= 2) {
|
55
59
|
context.report({
|
56
60
|
node,
|
57
|
-
|
61
|
+
messageId: "unexpected",
|
58
62
|
data: { name: variable.name }
|
59
63
|
});
|
60
64
|
}
|
@@ -18,7 +18,11 @@ module.exports = {
|
|
18
18
|
url: "https://eslint.org/docs/rules/no-dupe-class-members"
|
19
19
|
},
|
20
20
|
|
21
|
-
schema: []
|
21
|
+
schema: [],
|
22
|
+
|
23
|
+
messages: {
|
24
|
+
unexpected: "Duplicate name '{{name}}'."
|
25
|
+
}
|
22
26
|
},
|
23
27
|
|
24
28
|
create(context) {
|
@@ -102,7 +106,7 @@ module.exports = {
|
|
102
106
|
}
|
103
107
|
|
104
108
|
if (isDuplicate) {
|
105
|
-
context.report({ node,
|
109
|
+
context.report({ node, messageId: "unexpected", data: { name } });
|
106
110
|
}
|
107
111
|
}
|
108
112
|
};
|
@@ -91,7 +91,11 @@ module.exports = {
|
|
91
91
|
url: "https://eslint.org/docs/rules/no-dupe-keys"
|
92
92
|
},
|
93
93
|
|
94
|
-
schema: []
|
94
|
+
schema: [],
|
95
|
+
|
96
|
+
messages: {
|
97
|
+
unexpected: "Duplicate key '{{name}}'."
|
98
|
+
}
|
95
99
|
},
|
96
100
|
|
97
101
|
create(context) {
|
@@ -123,7 +127,7 @@ module.exports = {
|
|
123
127
|
context.report({
|
124
128
|
node: info.node,
|
125
129
|
loc: node.key.loc,
|
126
|
-
|
130
|
+
messageId: "unexpected",
|
127
131
|
data: { name }
|
128
132
|
});
|
129
133
|
}
|
@@ -19,7 +19,11 @@ module.exports = {
|
|
19
19
|
url: "https://eslint.org/docs/rules/no-duplicate-case"
|
20
20
|
},
|
21
21
|
|
22
|
-
schema: []
|
22
|
+
schema: [],
|
23
|
+
|
24
|
+
messages: {
|
25
|
+
unexpected: "Duplicate case label."
|
26
|
+
}
|
23
27
|
},
|
24
28
|
|
25
29
|
create(context) {
|
@@ -33,7 +37,7 @@ module.exports = {
|
|
33
37
|
const key = sourceCode.getText(switchCase.test);
|
34
38
|
|
35
39
|
if (mapping[key]) {
|
36
|
-
context.report({ node: switchCase,
|
40
|
+
context.report({ node: switchCase, messageId: "unexpected" });
|
37
41
|
} else {
|
38
42
|
mapping[key] = switchCase;
|
39
43
|
}
|