eslint 5.12.0 → 5.14.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 +70 -0
- package/README.md +76 -143
- package/conf/eslint-all.js +3 -5
- package/conf/eslint-recommended.js +4 -268
- package/lib/built-in-rules-index.js +277 -0
- package/lib/cli-engine.js +6 -2
- package/lib/config/config-file.js +25 -2
- package/lib/config/config-initializer.js +150 -143
- package/lib/config/config-ops.js +30 -0
- package/lib/config/config-rule.js +2 -4
- package/lib/config/plugins.js +12 -4
- package/lib/config.js +1 -1
- package/lib/formatters/table.js +13 -4
- package/lib/formatters/tap.js +7 -4
- package/lib/linter.js +31 -31
- package/lib/load-rules.js +2 -5
- package/lib/rules/accessor-pairs.js +4 -2
- package/lib/rules/array-bracket-newline.js +4 -2
- package/lib/rules/array-callback-return.js +2 -1
- package/lib/rules/array-element-newline.js +4 -2
- package/lib/rules/arrow-body-style.js +1 -1
- package/lib/rules/arrow-parens.js +2 -1
- package/lib/rules/arrow-spacing.js +7 -6
- package/lib/rules/brace-style.js +2 -1
- package/lib/rules/camelcase.js +3 -2
- package/lib/rules/capitalized-comments.js +15 -14
- package/lib/rules/class-methods-use-this.js +1 -1
- package/lib/rules/comma-spacing.js +10 -4
- package/lib/rules/complexity.js +7 -9
- package/lib/rules/consistent-return.js +2 -1
- package/lib/rules/dot-notation.js +5 -3
- package/lib/rules/eqeqeq.js +2 -1
- package/lib/rules/for-direction.js +30 -17
- package/lib/rules/func-call-spacing.js +2 -1
- package/lib/rules/func-style.js +3 -2
- package/lib/rules/getter-return.js +2 -1
- package/lib/rules/global-require.js +5 -2
- package/lib/rules/guard-for-in.js +5 -2
- package/lib/rules/handle-callback-err.js +5 -2
- package/lib/rules/id-blacklist.js +4 -1
- package/lib/rules/id-length.js +9 -6
- package/lib/rules/id-match.js +11 -5
- package/lib/rules/implicit-arrow-linebreak.js +7 -3
- package/lib/rules/indent-legacy.js +11 -5
- package/lib/rules/indent.js +18 -9
- package/lib/rules/init-declarations.js +13 -13
- package/lib/rules/jsx-quotes.js +5 -2
- package/lib/rules/key-spacing.js +70 -35
- package/lib/rules/keyword-spacing.js +18 -12
- package/lib/rules/line-comment-position.js +15 -8
- package/lib/rules/linebreak-style.js +6 -6
- package/lib/rules/lines-around-comment.js +20 -16
- package/lib/rules/lines-around-directive.js +5 -2
- package/lib/rules/lines-between-class-members.js +8 -6
- package/lib/rules/max-depth.js +11 -9
- package/lib/rules/max-len.js +24 -13
- package/lib/rules/max-lines-per-function.js +17 -18
- package/lib/rules/max-lines.js +14 -10
- package/lib/rules/max-nested-callbacks.js +12 -11
- package/lib/rules/max-params.js +11 -9
- package/lib/rules/max-statements-per-line.js +8 -5
- package/lib/rules/max-statements.js +12 -11
- package/lib/rules/multiline-comment-style.js +18 -17
- package/lib/rules/multiline-ternary.js +8 -6
- package/lib/rules/new-cap.js +18 -11
- package/lib/rules/new-parens.js +5 -2
- package/lib/rules/newline-after-var.js +6 -8
- package/lib/rules/newline-before-return.js +5 -1
- package/lib/rules/newline-per-chained-call.js +7 -3
- package/lib/rules/no-async-promise-executor.js +5 -2
- package/lib/rules/no-bitwise.js +2 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-constant-condition.js +24 -2
- package/lib/rules/no-duplicate-imports.js +17 -11
- package/lib/rules/no-else-return.js +2 -1
- package/lib/rules/no-empty.js +2 -1
- package/lib/rules/no-eval.js +1 -1
- package/lib/rules/no-extra-parens.js +4 -4
- package/lib/rules/no-fallthrough.js +8 -4
- package/lib/rules/no-floating-decimal.js +7 -3
- package/lib/rules/no-implicit-coercion.js +9 -6
- package/lib/rules/no-irregular-whitespace.js +8 -4
- package/lib/rules/no-labels.js +6 -4
- package/lib/rules/no-magic-numbers.js +6 -3
- package/lib/rules/no-mixed-operators.js +5 -4
- package/lib/rules/no-mixed-requires.js +4 -2
- package/lib/rules/no-multi-spaces.js +2 -1
- package/lib/rules/no-param-reassign.js +1 -1
- package/lib/rules/no-plusplus.js +2 -1
- package/lib/rules/no-redeclare.js +2 -2
- package/lib/rules/no-self-assign.js +2 -1
- package/lib/rules/no-shadow-restricted-names.js +16 -2
- package/lib/rules/no-shadow.js +3 -3
- package/lib/rules/no-sync.js +2 -1
- package/lib/rules/no-tabs.js +2 -1
- package/lib/rules/no-trailing-spaces.js +5 -3
- package/lib/rules/no-undef.js +7 -3
- package/lib/rules/no-underscore-dangle.js +6 -3
- package/lib/rules/no-unexpected-multiline.js +14 -13
- package/lib/rules/no-unneeded-ternary.js +2 -1
- package/lib/rules/no-unsafe-negation.js +6 -3
- package/lib/rules/no-unused-expressions.js +6 -3
- package/lib/rules/no-unused-labels.js +7 -2
- package/lib/rules/no-unused-vars.js +8 -4
- package/lib/rules/no-use-before-define.js +3 -3
- package/lib/rules/no-useless-rename.js +3 -3
- package/lib/rules/object-curly-newline.js +6 -4
- package/lib/rules/object-property-newline.js +5 -3
- package/lib/rules/object-shorthand.js +9 -5
- package/lib/rules/one-var.js +24 -38
- package/lib/rules/operator-assignment.js +8 -4
- package/lib/rules/padded-blocks.js +32 -9
- package/lib/rules/prefer-arrow-callback.js +4 -2
- package/lib/rules/prefer-const.js +7 -4
- package/lib/rules/prefer-destructuring.js +70 -12
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-spread.js +2 -13
- package/lib/rules/quote-props.js +10 -5
- package/lib/rules/quotes.js +4 -2
- package/lib/rules/require-jsdoc.js +13 -7
- package/lib/rules/semi-spacing.js +6 -8
- package/lib/rules/semi.js +5 -4
- package/lib/rules/sort-imports.js +6 -3
- package/lib/rules/sort-keys.js +13 -5
- package/lib/rules/sort-vars.js +2 -1
- package/lib/rules/space-before-function-paren.js +6 -3
- package/lib/rules/space-infix-ops.js +2 -1
- package/lib/rules/space-unary-ops.js +20 -10
- package/lib/rules/spaced-comment.js +2 -1
- package/lib/rules/strict.js +34 -35
- package/lib/rules/switch-colon-spacing.js +11 -8
- package/lib/rules/symbol-description.js +6 -3
- package/lib/rules/template-curly-spacing.js +10 -10
- package/lib/rules/template-tag-spacing.js +7 -3
- package/lib/rules/unicode-bom.js +7 -3
- package/lib/rules/use-isnan.js +5 -2
- package/lib/rules/valid-jsdoc.js +40 -19
- package/lib/rules/valid-typeof.js +9 -4
- package/lib/rules/vars-on-top.js +6 -4
- package/lib/rules/wrap-iife.js +12 -6
- package/lib/rules/yield-star-spacing.js +17 -10
- package/lib/rules/yoda.js +9 -4
- package/lib/rules.js +4 -34
- package/lib/util/ajv.js +1 -0
- package/lib/util/config-comment-parser.js +7 -10
- package/package.json +20 -20
package/lib/rules/valid-jsdoc.js
CHANGED
@@ -42,22 +42,27 @@ module.exports = {
|
|
42
42
|
}
|
43
43
|
},
|
44
44
|
requireReturn: {
|
45
|
-
type: "boolean"
|
45
|
+
type: "boolean",
|
46
|
+
default: true
|
46
47
|
},
|
47
48
|
requireParamDescription: {
|
48
|
-
type: "boolean"
|
49
|
+
type: "boolean",
|
50
|
+
default: true
|
49
51
|
},
|
50
52
|
requireReturnDescription: {
|
51
|
-
type: "boolean"
|
53
|
+
type: "boolean",
|
54
|
+
default: true
|
52
55
|
},
|
53
56
|
matchDescription: {
|
54
57
|
type: "string"
|
55
58
|
},
|
56
59
|
requireReturnType: {
|
57
|
-
type: "boolean"
|
60
|
+
type: "boolean",
|
61
|
+
default: true
|
58
62
|
},
|
59
63
|
requireParamType: {
|
60
|
-
type: "boolean"
|
64
|
+
type: "boolean",
|
65
|
+
default: true
|
61
66
|
}
|
62
67
|
},
|
63
68
|
additionalProperties: false
|
@@ -65,6 +70,22 @@ module.exports = {
|
|
65
70
|
],
|
66
71
|
|
67
72
|
fixable: "code",
|
73
|
+
messages: {
|
74
|
+
unexpectedTag: "Unexpected @{{title}} tag; function has no return statement.",
|
75
|
+
expected: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.",
|
76
|
+
use: "Use @{{name}} instead.",
|
77
|
+
useType: "Use '{{expectedTypeName}}' instead of '{{currentTypeName}}'.",
|
78
|
+
syntaxError: "JSDoc syntax error.",
|
79
|
+
missingBrace: "JSDoc type missing brace.",
|
80
|
+
missingParamDesc: "Missing JSDoc parameter description for '{{name}}'.",
|
81
|
+
missingParamType: "Missing JSDoc parameter type for '{{name}}'.",
|
82
|
+
missingReturnType: "Missing JSDoc return type.",
|
83
|
+
missingReturnDesc: "Missing JSDoc return description.",
|
84
|
+
missingReturn: "Missing JSDoc @{{returns}} for function.",
|
85
|
+
missingParam: "Missing JSDoc for parameter '{{name}}'.",
|
86
|
+
duplicateParam: "Duplicate JSDoc parameter '{{name}}'.",
|
87
|
+
unsatisfiedDesc: "JSDoc description does not satisfy the regex pattern."
|
88
|
+
},
|
68
89
|
|
69
90
|
deprecated: true,
|
70
91
|
replacedBy: []
|
@@ -231,7 +252,7 @@ module.exports = {
|
|
231
252
|
typeToCheck.expectedTypeName !== typeToCheck.currentType.name) {
|
232
253
|
context.report({
|
233
254
|
node: jsdocNode,
|
234
|
-
|
255
|
+
messageId: "useType",
|
235
256
|
loc: getAbsoluteRange(jsdocNode, typeToCheck.currentType),
|
236
257
|
data: {
|
237
258
|
currentTypeName: typeToCheck.currentType.name,
|
@@ -280,9 +301,9 @@ module.exports = {
|
|
280
301
|
} catch (ex) {
|
281
302
|
|
282
303
|
if (/braces/i.test(ex.message)) {
|
283
|
-
context.report({ node: jsdocNode,
|
304
|
+
context.report({ node: jsdocNode, messageId: "missingBrace" });
|
284
305
|
} else {
|
285
|
-
context.report({ node: jsdocNode,
|
306
|
+
context.report({ node: jsdocNode, messageId: "syntaxError" });
|
286
307
|
}
|
287
308
|
|
288
309
|
return;
|
@@ -332,7 +353,7 @@ module.exports = {
|
|
332
353
|
|
333
354
|
context.report({
|
334
355
|
node: jsdocNode,
|
335
|
-
|
356
|
+
messageId: "use",
|
336
357
|
loc: {
|
337
358
|
start: entireTagRange.start,
|
338
359
|
end: {
|
@@ -363,7 +384,7 @@ module.exports = {
|
|
363
384
|
if (requireParamType && !param.type) {
|
364
385
|
context.report({
|
365
386
|
node: jsdocNode,
|
366
|
-
|
387
|
+
messageId: "missingParamType",
|
367
388
|
loc: getAbsoluteRange(jsdocNode, param),
|
368
389
|
data: { name: param.name }
|
369
390
|
});
|
@@ -371,7 +392,7 @@ module.exports = {
|
|
371
392
|
if (!param.description && requireParamDescription) {
|
372
393
|
context.report({
|
373
394
|
node: jsdocNode,
|
374
|
-
|
395
|
+
messageId: "missingParamDesc",
|
375
396
|
loc: getAbsoluteRange(jsdocNode, param),
|
376
397
|
data: { name: param.name }
|
377
398
|
});
|
@@ -379,7 +400,7 @@ module.exports = {
|
|
379
400
|
if (paramTagsByName[param.name]) {
|
380
401
|
context.report({
|
381
402
|
node: jsdocNode,
|
382
|
-
|
403
|
+
messageId: "duplicateParam",
|
383
404
|
loc: getAbsoluteRange(jsdocNode, param),
|
384
405
|
data: { name: param.name }
|
385
406
|
});
|
@@ -392,7 +413,7 @@ module.exports = {
|
|
392
413
|
if (!requireReturn && !functionData.returnPresent && (returnsTag.type === null || !isValidReturnType(returnsTag)) && !isAbstract) {
|
393
414
|
context.report({
|
394
415
|
node: jsdocNode,
|
395
|
-
|
416
|
+
messageId: "unexpectedTag",
|
396
417
|
loc: getAbsoluteRange(jsdocNode, returnsTag),
|
397
418
|
data: {
|
398
419
|
title: returnsTag.title
|
@@ -400,11 +421,11 @@ module.exports = {
|
|
400
421
|
});
|
401
422
|
} else {
|
402
423
|
if (requireReturnType && !returnsTag.type) {
|
403
|
-
context.report({ node: jsdocNode,
|
424
|
+
context.report({ node: jsdocNode, messageId: "missingReturnType" });
|
404
425
|
}
|
405
426
|
|
406
427
|
if (!isValidReturnType(returnsTag) && !returnsTag.description && requireReturnDescription) {
|
407
|
-
context.report({ node: jsdocNode,
|
428
|
+
context.report({ node: jsdocNode, messageId: "missingReturnDesc" });
|
408
429
|
}
|
409
430
|
}
|
410
431
|
}
|
@@ -416,7 +437,7 @@ module.exports = {
|
|
416
437
|
if (requireReturn || (functionData.returnPresent && !node.async)) {
|
417
438
|
context.report({
|
418
439
|
node: jsdocNode,
|
419
|
-
|
440
|
+
messageId: "missingReturn",
|
420
441
|
data: {
|
421
442
|
returns: prefer.returns || "returns"
|
422
443
|
}
|
@@ -440,7 +461,7 @@ module.exports = {
|
|
440
461
|
if (jsdocParamNames[paramsIndex] && (name !== jsdocParamNames[paramsIndex])) {
|
441
462
|
context.report({
|
442
463
|
node: jsdocNode,
|
443
|
-
|
464
|
+
messageId: "expected",
|
444
465
|
loc: getAbsoluteRange(jsdocNode, paramTagsByName[jsdocParamNames[paramsIndex]]),
|
445
466
|
data: {
|
446
467
|
name,
|
@@ -450,7 +471,7 @@ module.exports = {
|
|
450
471
|
} else if (!paramTagsByName[name] && !isOverride) {
|
451
472
|
context.report({
|
452
473
|
node: jsdocNode,
|
453
|
-
|
474
|
+
messageId: "missingParam",
|
454
475
|
data: {
|
455
476
|
name
|
456
477
|
}
|
@@ -464,7 +485,7 @@ module.exports = {
|
|
464
485
|
const regex = new RegExp(options.matchDescription);
|
465
486
|
|
466
487
|
if (!regex.test(jsdoc.description)) {
|
467
|
-
context.report({ node: jsdocNode,
|
488
|
+
context.report({ node: jsdocNode, messageId: "unsatisfiedDesc" });
|
468
489
|
}
|
469
490
|
}
|
470
491
|
|
@@ -24,12 +24,17 @@ module.exports = {
|
|
24
24
|
type: "object",
|
25
25
|
properties: {
|
26
26
|
requireStringLiterals: {
|
27
|
-
type: "boolean"
|
27
|
+
type: "boolean",
|
28
|
+
default: false
|
28
29
|
}
|
29
30
|
},
|
30
31
|
additionalProperties: false
|
31
32
|
}
|
32
|
-
]
|
33
|
+
],
|
34
|
+
messages: {
|
35
|
+
invalidValue: "Invalid typeof comparison value.",
|
36
|
+
notString: "Typeof comparisons should be to string literals."
|
37
|
+
}
|
33
38
|
},
|
34
39
|
|
35
40
|
create(context) {
|
@@ -65,10 +70,10 @@ module.exports = {
|
|
65
70
|
const value = sibling.type === "Literal" ? sibling.value : sibling.quasis[0].value.cooked;
|
66
71
|
|
67
72
|
if (VALID_TYPES.indexOf(value) === -1) {
|
68
|
-
context.report({ node: sibling,
|
73
|
+
context.report({ node: sibling, messageId: "invalidValue" });
|
69
74
|
}
|
70
75
|
} else if (requireStringLiterals && !isTypeofExpression(sibling)) {
|
71
|
-
context.report({ node: sibling,
|
76
|
+
context.report({ node: sibling, messageId: "notString" });
|
72
77
|
}
|
73
78
|
}
|
74
79
|
}
|
package/lib/rules/vars-on-top.js
CHANGED
@@ -20,11 +20,13 @@ module.exports = {
|
|
20
20
|
url: "https://eslint.org/docs/rules/vars-on-top"
|
21
21
|
},
|
22
22
|
|
23
|
-
schema: []
|
23
|
+
schema: [],
|
24
|
+
messages: {
|
25
|
+
top: "All 'var' declarations must be at the top of the function scope."
|
26
|
+
}
|
24
27
|
},
|
25
28
|
|
26
29
|
create(context) {
|
27
|
-
const errorMessage = "All 'var' declarations must be at the top of the function scope.";
|
28
30
|
|
29
31
|
//--------------------------------------------------------------------------
|
30
32
|
// Helpers
|
@@ -103,7 +105,7 @@ module.exports = {
|
|
103
105
|
*/
|
104
106
|
function globalVarCheck(node, parent) {
|
105
107
|
if (!isVarOnTop(node, parent.body)) {
|
106
|
-
context.report({ node,
|
108
|
+
context.report({ node, messageId: "top" });
|
107
109
|
}
|
108
110
|
}
|
109
111
|
|
@@ -118,7 +120,7 @@ module.exports = {
|
|
118
120
|
if (!(/Function/.test(grandParent.type) &&
|
119
121
|
parent.type === "BlockStatement" &&
|
120
122
|
isVarOnTop(node, parent.body))) {
|
121
|
-
context.report({ node,
|
123
|
+
context.report({ node, messageId: "top" });
|
122
124
|
}
|
123
125
|
}
|
124
126
|
|
package/lib/rules/wrap-iife.js
CHANGED
@@ -34,20 +34,26 @@ module.exports = {
|
|
34
34
|
type: "object",
|
35
35
|
properties: {
|
36
36
|
functionPrototypeMethods: {
|
37
|
-
type: "boolean"
|
37
|
+
type: "boolean",
|
38
|
+
default: false
|
38
39
|
}
|
39
40
|
},
|
40
41
|
additionalProperties: false
|
41
42
|
}
|
42
43
|
],
|
43
44
|
|
44
|
-
fixable: "code"
|
45
|
+
fixable: "code",
|
46
|
+
messages: {
|
47
|
+
wrapInvocation: "Wrap an immediate function invocation in parentheses.",
|
48
|
+
wrapExpression: "Wrap only the function expression in parens.",
|
49
|
+
moveInvocation: "Move the invocation into the parens that contain the function."
|
50
|
+
}
|
45
51
|
},
|
46
52
|
|
47
53
|
create(context) {
|
48
54
|
|
49
55
|
const style = context.options[0] || "outside";
|
50
|
-
const includeFunctionPrototypeMethods =
|
56
|
+
const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods;
|
51
57
|
|
52
58
|
const sourceCode = context.getSourceCode();
|
53
59
|
|
@@ -99,7 +105,7 @@ module.exports = {
|
|
99
105
|
if (!callExpressionWrapped && !functionExpressionWrapped) {
|
100
106
|
context.report({
|
101
107
|
node,
|
102
|
-
|
108
|
+
messageId: "wrapInvocation",
|
103
109
|
fix(fixer) {
|
104
110
|
const nodeToSurround = style === "inside" ? innerNode : node;
|
105
111
|
|
@@ -109,7 +115,7 @@ module.exports = {
|
|
109
115
|
} else if (style === "inside" && !functionExpressionWrapped) {
|
110
116
|
context.report({
|
111
117
|
node,
|
112
|
-
|
118
|
+
messageId: "wrapExpression",
|
113
119
|
fix(fixer) {
|
114
120
|
|
115
121
|
/*
|
@@ -129,7 +135,7 @@ module.exports = {
|
|
129
135
|
} else if (style === "outside" && !callExpressionWrapped) {
|
130
136
|
context.report({
|
131
137
|
node,
|
132
|
-
|
138
|
+
messageId: "moveInvocation",
|
133
139
|
fix(fixer) {
|
134
140
|
|
135
141
|
/*
|
@@ -31,14 +31,20 @@ module.exports = {
|
|
31
31
|
{
|
32
32
|
type: "object",
|
33
33
|
properties: {
|
34
|
-
before: { type: "boolean" },
|
35
|
-
after: { type: "boolean" }
|
34
|
+
before: { type: "boolean", default: false },
|
35
|
+
after: { type: "boolean", default: true }
|
36
36
|
},
|
37
37
|
additionalProperties: false
|
38
38
|
}
|
39
39
|
]
|
40
40
|
}
|
41
|
-
]
|
41
|
+
],
|
42
|
+
messages: {
|
43
|
+
missingBefore: "Missing space before *.",
|
44
|
+
missingAfter: "Missing space after *.",
|
45
|
+
unexpectedBefore: "Unexpected space before *.",
|
46
|
+
unexpectedAfter: "Unexpected space after *."
|
47
|
+
}
|
42
48
|
},
|
43
49
|
|
44
50
|
create(context) {
|
@@ -70,16 +76,17 @@ module.exports = {
|
|
70
76
|
const after = leftToken.value === "*";
|
71
77
|
const spaceRequired = mode[side];
|
72
78
|
const node = after ? leftToken : rightToken;
|
73
|
-
|
74
|
-
|
79
|
+
let messageId = "";
|
80
|
+
|
81
|
+
if (spaceRequired) {
|
82
|
+
messageId = side === "before" ? "missingBefore" : "missingAfter";
|
83
|
+
} else {
|
84
|
+
messageId = side === "before" ? "unexpectedBefore" : "unexpectedAfter";
|
85
|
+
}
|
75
86
|
|
76
87
|
context.report({
|
77
88
|
node,
|
78
|
-
|
79
|
-
data: {
|
80
|
-
type,
|
81
|
-
side
|
82
|
-
},
|
89
|
+
messageId,
|
83
90
|
fix(fixer) {
|
84
91
|
if (spaceRequired) {
|
85
92
|
if (after) {
|
package/lib/rules/yoda.js
CHANGED
@@ -169,17 +169,22 @@ module.exports = {
|
|
169
169
|
type: "object",
|
170
170
|
properties: {
|
171
171
|
exceptRange: {
|
172
|
-
type: "boolean"
|
172
|
+
type: "boolean",
|
173
|
+
default: false
|
173
174
|
},
|
174
175
|
onlyEquality: {
|
175
|
-
type: "boolean"
|
176
|
+
type: "boolean",
|
177
|
+
default: false
|
176
178
|
}
|
177
179
|
},
|
178
180
|
additionalProperties: false
|
179
181
|
}
|
180
182
|
],
|
181
183
|
|
182
|
-
fixable: "code"
|
184
|
+
fixable: "code",
|
185
|
+
messages: {
|
186
|
+
expected: "Expected literal to be on the {{expectedSide}} side of {{operator}}."
|
187
|
+
}
|
183
188
|
},
|
184
189
|
|
185
190
|
create(context) {
|
@@ -297,7 +302,7 @@ module.exports = {
|
|
297
302
|
) {
|
298
303
|
context.report({
|
299
304
|
node,
|
300
|
-
|
305
|
+
messageId: "expected",
|
301
306
|
data: {
|
302
307
|
operator: node.operator,
|
303
308
|
expectedSide: always ? "left" : "right"
|
package/lib/rules.js
CHANGED
@@ -10,8 +10,8 @@
|
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
12
|
const lodash = require("lodash");
|
13
|
-
const loadRules = require("./load-rules");
|
14
13
|
const ruleReplacements = require("../conf/replacements").rules;
|
14
|
+
const builtInRules = require("./built-in-rules-index");
|
15
15
|
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
// Helpers
|
@@ -59,8 +59,9 @@ function normalizeRule(rule) {
|
|
59
59
|
class Rules {
|
60
60
|
constructor() {
|
61
61
|
this._rules = Object.create(null);
|
62
|
-
|
63
|
-
|
62
|
+
Object.keys(builtInRules).forEach(ruleId => {
|
63
|
+
this.define(ruleId, builtInRules[ruleId]);
|
64
|
+
});
|
64
65
|
}
|
65
66
|
|
66
67
|
/**
|
@@ -73,37 +74,6 @@ class Rules {
|
|
73
74
|
this._rules[ruleId] = normalizeRule(ruleModule);
|
74
75
|
}
|
75
76
|
|
76
|
-
/**
|
77
|
-
* Loads and registers all rules from passed rules directory.
|
78
|
-
* @param {string} [rulesDir] Path to rules directory, may be relative. Defaults to `lib/rules`.
|
79
|
-
* @param {string} cwd Current working directory
|
80
|
-
* @returns {void}
|
81
|
-
*/
|
82
|
-
load(rulesDir, cwd) {
|
83
|
-
const newRules = loadRules(rulesDir, cwd);
|
84
|
-
|
85
|
-
Object.keys(newRules).forEach(ruleId => {
|
86
|
-
this.define(ruleId, newRules[ruleId]);
|
87
|
-
});
|
88
|
-
}
|
89
|
-
|
90
|
-
/**
|
91
|
-
* Registers all given rules of a plugin.
|
92
|
-
* @param {Object} plugin The plugin object to import.
|
93
|
-
* @param {string} pluginName The name of the plugin without prefix (`eslint-plugin-`).
|
94
|
-
* @returns {void}
|
95
|
-
*/
|
96
|
-
importPlugin(plugin, pluginName) {
|
97
|
-
if (plugin.rules) {
|
98
|
-
Object.keys(plugin.rules).forEach(ruleId => {
|
99
|
-
const qualifiedRuleId = `${pluginName}/${ruleId}`,
|
100
|
-
rule = plugin.rules[ruleId];
|
101
|
-
|
102
|
-
this.define(qualifiedRuleId, rule);
|
103
|
-
});
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
77
|
/**
|
108
78
|
* Access rule handler by id (file name).
|
109
79
|
* @param {string} ruleId Rule id (file name).
|
package/lib/util/ajv.js
CHANGED
@@ -26,14 +26,14 @@ const debug = require("debug")("eslint:config-comment-parser");
|
|
26
26
|
module.exports = class ConfigCommentParser {
|
27
27
|
|
28
28
|
/**
|
29
|
-
* Parses a list of "name:
|
29
|
+
* Parses a list of "name:string_value" or/and "name" options divided by comma or
|
30
30
|
* whitespace. Used for "global" and "exported" comments.
|
31
31
|
* @param {string} string The string to parse.
|
32
32
|
* @param {Comment} comment The comment node which has the string.
|
33
|
-
* @returns {Object} Result map object of names and
|
33
|
+
* @returns {Object} Result map object of names and string values, or null values if no value was provided
|
34
34
|
*/
|
35
|
-
|
36
|
-
debug("Parsing
|
35
|
+
parseStringConfig(string, comment) {
|
36
|
+
debug("Parsing String config");
|
37
37
|
|
38
38
|
const items = {};
|
39
39
|
|
@@ -45,13 +45,10 @@ module.exports = class ConfigCommentParser {
|
|
45
45
|
return;
|
46
46
|
}
|
47
47
|
|
48
|
-
// value defaults to
|
49
|
-
const [key, value =
|
48
|
+
// value defaults to null (if not provided), e.g: "foo" => ["foo", null]
|
49
|
+
const [key, value = null] = name.split(":");
|
50
50
|
|
51
|
-
items[key] = {
|
52
|
-
value: value === "true",
|
53
|
-
comment
|
54
|
-
};
|
51
|
+
items[key] = { value, comment };
|
55
52
|
});
|
56
53
|
return items;
|
57
54
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.14.1",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -36,53 +36,53 @@
|
|
36
36
|
"bugs": "https://github.com/eslint/eslint/issues/",
|
37
37
|
"dependencies": {
|
38
38
|
"@babel/code-frame": "^7.0.0",
|
39
|
-
"ajv": "^6.
|
39
|
+
"ajv": "^6.9.1",
|
40
40
|
"chalk": "^2.1.0",
|
41
41
|
"cross-spawn": "^6.0.5",
|
42
42
|
"debug": "^4.0.1",
|
43
|
-
"doctrine": "^
|
43
|
+
"doctrine": "^3.0.0",
|
44
44
|
"eslint-scope": "^4.0.0",
|
45
45
|
"eslint-utils": "^1.3.1",
|
46
46
|
"eslint-visitor-keys": "^1.0.0",
|
47
|
-
"espree": "^5.0.
|
47
|
+
"espree": "^5.0.1",
|
48
48
|
"esquery": "^1.0.1",
|
49
49
|
"esutils": "^2.0.2",
|
50
|
-
"file-entry-cache": "^
|
50
|
+
"file-entry-cache": "^5.0.1",
|
51
51
|
"functional-red-black-tree": "^1.0.1",
|
52
52
|
"glob": "^7.1.2",
|
53
53
|
"globals": "^11.7.0",
|
54
54
|
"ignore": "^4.0.6",
|
55
55
|
"import-fresh": "^3.0.0",
|
56
56
|
"imurmurhash": "^0.1.4",
|
57
|
-
"inquirer": "^6.
|
57
|
+
"inquirer": "^6.2.2",
|
58
58
|
"js-yaml": "^3.12.0",
|
59
59
|
"json-stable-stringify-without-jsonify": "^1.0.1",
|
60
60
|
"levn": "^0.3.0",
|
61
|
-
"lodash": "^4.17.
|
61
|
+
"lodash": "^4.17.11",
|
62
62
|
"minimatch": "^3.0.4",
|
63
63
|
"mkdirp": "^0.5.1",
|
64
64
|
"natural-compare": "^1.4.0",
|
65
65
|
"optionator": "^0.8.2",
|
66
66
|
"path-is-inside": "^1.0.2",
|
67
|
-
"pluralize": "^7.0.0",
|
68
67
|
"progress": "^2.0.0",
|
69
68
|
"regexpp": "^2.0.1",
|
70
69
|
"semver": "^5.5.1",
|
71
70
|
"strip-ansi": "^4.0.0",
|
72
71
|
"strip-json-comments": "^2.0.1",
|
73
|
-
"table": "^5.
|
72
|
+
"table": "^5.2.3",
|
74
73
|
"text-table": "^0.2.0"
|
75
74
|
},
|
76
75
|
"devDependencies": {
|
77
|
-
"babel
|
78
|
-
"babel
|
79
|
-
"babel
|
80
|
-
"babelify": "^
|
76
|
+
"@babel/core": "^7.2.2",
|
77
|
+
"@babel/polyfill": "^7.2.5",
|
78
|
+
"@babel/preset-env": "^7.3.1",
|
79
|
+
"babelify": "^10.0.0",
|
81
80
|
"beefy": "^2.1.8",
|
82
81
|
"brfs": "^2.0.0",
|
83
82
|
"browserify": "^16.2.2",
|
84
83
|
"chai": "^4.0.1",
|
85
84
|
"cheerio": "^0.22.0",
|
85
|
+
"common-tags": "^1.8.0",
|
86
86
|
"coveralls": "^3.0.1",
|
87
87
|
"dateformat": "^3.0.3",
|
88
88
|
"ejs": "^2.6.1",
|
@@ -91,26 +91,26 @@
|
|
91
91
|
"eslint-plugin-rulesdir": "^0.1.0",
|
92
92
|
"eslint-release": "^1.2.0",
|
93
93
|
"eslint-rule-composer": "^0.3.0",
|
94
|
-
"eslump": "^
|
94
|
+
"eslump": "^2.0.0",
|
95
95
|
"esprima": "^4.0.1",
|
96
96
|
"istanbul": "^0.4.5",
|
97
97
|
"jsdoc": "^3.5.5",
|
98
|
-
"karma": "^3.
|
99
|
-
"karma-babel-preprocessor": "^
|
98
|
+
"karma": "^3.1.4",
|
99
|
+
"karma-babel-preprocessor": "^8.0.0",
|
100
100
|
"karma-chrome-launcher": "^2.2.0",
|
101
101
|
"karma-mocha": "^1.3.0",
|
102
102
|
"karma-mocha-reporter": "^2.2.3",
|
103
103
|
"leche": "^2.2.3",
|
104
104
|
"load-perf": "^0.2.0",
|
105
|
-
"markdownlint": "^0.
|
105
|
+
"markdownlint": "^0.12.0",
|
106
106
|
"mocha": "^5.0.5",
|
107
|
-
"mock-fs": "^4.
|
107
|
+
"mock-fs": "^4.8.0",
|
108
108
|
"npm-license": "^0.3.3",
|
109
109
|
"proxyquire": "^2.0.1",
|
110
|
-
"puppeteer": "^1.
|
110
|
+
"puppeteer": "^1.12.2",
|
111
111
|
"shelljs": "^0.8.2",
|
112
112
|
"sinon": "^3.3.0",
|
113
|
-
"temp": "^0.
|
113
|
+
"temp": "^0.9.0",
|
114
114
|
"through": "^2.3.8"
|
115
115
|
},
|
116
116
|
"keywords": [
|