eslint 4.16.0 → 4.18.2
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 +46 -0
- package/conf/environments.js +3 -1
- package/conf/eslint-recommended.js +0 -0
- package/lib/linter.js +368 -366
- 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 +9 -4
- 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/indent.js +0 -1
- package/lib/rules/key-spacing.js +3 -2
- package/lib/rules/keyword-spacing.js +6 -1
- package/lib/rules/max-len.js +2 -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-shorthand.js +9 -7
- package/lib/rules/padding-line-between-statements.js +6 -0
- 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/template-tag-spacing.js +0 -0
- package/lib/util/glob-util.js +17 -4
- package/lib/util/interpolate.js +5 -1
- package/lib/util/npm-util.js +1 -1
- package/package.json +2 -2
- package/conf/default-config-options.js +0 -29
package/lib/rules/eol-last.js
CHANGED
@@ -27,7 +27,11 @@ module.exports = {
|
|
27
27
|
{
|
28
28
|
enum: ["always", "never", "unix", "windows"]
|
29
29
|
}
|
30
|
-
]
|
30
|
+
],
|
31
|
+
messages: {
|
32
|
+
missing: "Newline required at end of file but not found.",
|
33
|
+
unexpected: "Newline not allowed at end of file."
|
34
|
+
}
|
31
35
|
},
|
32
36
|
create(context) {
|
33
37
|
|
@@ -75,7 +79,7 @@ module.exports = {
|
|
75
79
|
context.report({
|
76
80
|
node,
|
77
81
|
loc: location,
|
78
|
-
|
82
|
+
messageId: "missing",
|
79
83
|
fix(fixer) {
|
80
84
|
return fixer.insertTextAfterRange([0, src.length], appendCRLF ? CRLF : LF);
|
81
85
|
}
|
@@ -86,7 +90,7 @@ module.exports = {
|
|
86
90
|
context.report({
|
87
91
|
node,
|
88
92
|
loc: location,
|
89
|
-
|
93
|
+
messageId: "unexpected",
|
90
94
|
fix(fixer) {
|
91
95
|
const finalEOLs = /(?:\r?\n)+$/,
|
92
96
|
match = finalEOLs.exec(sourceCode.text),
|
package/lib/rules/eqeqeq.js
CHANGED
@@ -56,7 +56,11 @@ module.exports = {
|
|
56
56
|
]
|
57
57
|
},
|
58
58
|
|
59
|
-
fixable: "code"
|
59
|
+
fixable: "code",
|
60
|
+
|
61
|
+
messages: {
|
62
|
+
unexpected: "Expected '{{expectedOperator}}' and instead saw '{{actualOperator}}'."
|
63
|
+
}
|
60
64
|
},
|
61
65
|
|
62
66
|
create(context) {
|
@@ -134,7 +138,7 @@ module.exports = {
|
|
134
138
|
context.report({
|
135
139
|
node,
|
136
140
|
loc: getOperatorLocation(node),
|
137
|
-
|
141
|
+
messageId: "unexpected",
|
138
142
|
data: { expectedOperator, actualOperator: node.operator },
|
139
143
|
fix(fixer) {
|
140
144
|
|
package/lib/rules/indent.js
CHANGED
@@ -1043,7 +1043,6 @@ module.exports = {
|
|
1043
1043
|
offsets.ignoreToken(operator);
|
1044
1044
|
offsets.ignoreToken(tokenAfterOperator);
|
1045
1045
|
offsets.setDesiredOffset(tokenAfterOperator, operator, 0);
|
1046
|
-
offsets.setDesiredOffsets([tokenAfterOperator.range[1], node.range[1]], tokenAfterOperator, 1);
|
1047
1046
|
},
|
1048
1047
|
|
1049
1048
|
"BlockStatement, ClassBody"(node) {
|
package/lib/rules/key-spacing.js
CHANGED
@@ -360,9 +360,10 @@ module.exports = {
|
|
360
360
|
*/
|
361
361
|
function isKeyValueProperty(property) {
|
362
362
|
return !(
|
363
|
-
|
363
|
+
property.method ||
|
364
364
|
property.shorthand ||
|
365
|
-
property.kind !== "init" ||
|
365
|
+
property.kind !== "init" ||
|
366
|
+
property.type !== "Property" // Could be "ExperimentalSpreadProperty" or "SpreadElement"
|
366
367
|
);
|
367
368
|
}
|
368
369
|
|
@@ -436,7 +436,12 @@ module.exports = {
|
|
436
436
|
* @returns {void}
|
437
437
|
*/
|
438
438
|
function checkSpacingForForOfStatement(node) {
|
439
|
-
|
439
|
+
if (node.await) {
|
440
|
+
checkSpacingBefore(sourceCode.getFirstToken(node, 0));
|
441
|
+
checkSpacingAfter(sourceCode.getFirstToken(node, 1));
|
442
|
+
} else {
|
443
|
+
checkSpacingAroundFirstToken(node);
|
444
|
+
}
|
440
445
|
checkSpacingAround(sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken));
|
441
446
|
}
|
442
447
|
|
package/lib/rules/max-len.js
CHANGED
@@ -213,7 +213,8 @@ module.exports = {
|
|
213
213
|
* @returns {ASTNode[]} An array of string nodes.
|
214
214
|
*/
|
215
215
|
function getAllStrings() {
|
216
|
-
return sourceCode.ast.tokens.filter(token => token.type === "String"
|
216
|
+
return sourceCode.ast.tokens.filter(token => (token.type === "String" ||
|
217
|
+
(token.type === "JSXText" && sourceCode.getNodeByRangeIndex(token.range[0] - 1).type === "JSXAttribute")));
|
217
218
|
}
|
218
219
|
|
219
220
|
/**
|
package/lib/rules/no-alert.js
CHANGED
@@ -23,17 +23,6 @@ function isProhibitedIdentifier(name) {
|
|
23
23
|
return /^(alert|confirm|prompt)$/.test(name);
|
24
24
|
}
|
25
25
|
|
26
|
-
/**
|
27
|
-
* Reports the given node and identifier name.
|
28
|
-
* @param {RuleContext} context The ESLint rule context.
|
29
|
-
* @param {ASTNode} node The node to report on.
|
30
|
-
* @param {string} identifierName The name of the identifier.
|
31
|
-
* @returns {void}
|
32
|
-
*/
|
33
|
-
function report(context, node, identifierName) {
|
34
|
-
context.report(node, "Unexpected {{name}}.", { name: identifierName });
|
35
|
-
}
|
36
|
-
|
37
26
|
/**
|
38
27
|
* Finds the eslint-scope reference in the given scope.
|
39
28
|
* @param {Object} scope The scope to search.
|
@@ -92,7 +81,11 @@ module.exports = {
|
|
92
81
|
url: "https://eslint.org/docs/rules/no-alert"
|
93
82
|
},
|
94
83
|
|
95
|
-
schema: []
|
84
|
+
schema: [],
|
85
|
+
|
86
|
+
messages: {
|
87
|
+
unexpected: "Unexpected {{name}}."
|
88
|
+
}
|
96
89
|
},
|
97
90
|
|
98
91
|
create(context) {
|
@@ -103,17 +96,25 @@ module.exports = {
|
|
103
96
|
|
104
97
|
// without window.
|
105
98
|
if (callee.type === "Identifier") {
|
106
|
-
const
|
99
|
+
const name = callee.name;
|
107
100
|
|
108
101
|
if (!isShadowed(currentScope, callee) && isProhibitedIdentifier(callee.name)) {
|
109
|
-
report(
|
102
|
+
context.report({
|
103
|
+
node,
|
104
|
+
messageId: "unexpected",
|
105
|
+
data: { name }
|
106
|
+
});
|
110
107
|
}
|
111
108
|
|
112
109
|
} else if (callee.type === "MemberExpression" && isGlobalThisReferenceOrGlobalWindow(currentScope, callee.object)) {
|
113
|
-
const
|
114
|
-
|
115
|
-
if (isProhibitedIdentifier(
|
116
|
-
report(
|
110
|
+
const name = getPropertyName(callee);
|
111
|
+
|
112
|
+
if (isProhibitedIdentifier(name)) {
|
113
|
+
context.report({
|
114
|
+
node,
|
115
|
+
messageId: "unexpected",
|
116
|
+
data: { name }
|
117
|
+
});
|
117
118
|
}
|
118
119
|
}
|
119
120
|
|
@@ -18,7 +18,11 @@ module.exports = {
|
|
18
18
|
url: "https://eslint.org/docs/rules/no-array-constructor"
|
19
19
|
},
|
20
20
|
|
21
|
-
schema: []
|
21
|
+
schema: [],
|
22
|
+
|
23
|
+
messages: {
|
24
|
+
preferLiteral: "The array literal notation [] is preferable."
|
25
|
+
}
|
22
26
|
},
|
23
27
|
|
24
28
|
create(context) {
|
@@ -35,7 +39,7 @@ module.exports = {
|
|
35
39
|
node.callee.type === "Identifier" &&
|
36
40
|
node.callee.name === "Array"
|
37
41
|
) {
|
38
|
-
context.report({ node,
|
42
|
+
context.report({ node, messageId: "preferLiteral" });
|
39
43
|
}
|
40
44
|
}
|
41
45
|
|
@@ -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
|
|