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.
Files changed (146) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +76 -143
  3. package/conf/eslint-all.js +3 -5
  4. package/conf/eslint-recommended.js +4 -268
  5. package/lib/built-in-rules-index.js +277 -0
  6. package/lib/cli-engine.js +6 -2
  7. package/lib/config/config-file.js +25 -2
  8. package/lib/config/config-initializer.js +150 -143
  9. package/lib/config/config-ops.js +30 -0
  10. package/lib/config/config-rule.js +2 -4
  11. package/lib/config/plugins.js +12 -4
  12. package/lib/config.js +1 -1
  13. package/lib/formatters/table.js +13 -4
  14. package/lib/formatters/tap.js +7 -4
  15. package/lib/linter.js +31 -31
  16. package/lib/load-rules.js +2 -5
  17. package/lib/rules/accessor-pairs.js +4 -2
  18. package/lib/rules/array-bracket-newline.js +4 -2
  19. package/lib/rules/array-callback-return.js +2 -1
  20. package/lib/rules/array-element-newline.js +4 -2
  21. package/lib/rules/arrow-body-style.js +1 -1
  22. package/lib/rules/arrow-parens.js +2 -1
  23. package/lib/rules/arrow-spacing.js +7 -6
  24. package/lib/rules/brace-style.js +2 -1
  25. package/lib/rules/camelcase.js +3 -2
  26. package/lib/rules/capitalized-comments.js +15 -14
  27. package/lib/rules/class-methods-use-this.js +1 -1
  28. package/lib/rules/comma-spacing.js +10 -4
  29. package/lib/rules/complexity.js +7 -9
  30. package/lib/rules/consistent-return.js +2 -1
  31. package/lib/rules/dot-notation.js +5 -3
  32. package/lib/rules/eqeqeq.js +2 -1
  33. package/lib/rules/for-direction.js +30 -17
  34. package/lib/rules/func-call-spacing.js +2 -1
  35. package/lib/rules/func-style.js +3 -2
  36. package/lib/rules/getter-return.js +2 -1
  37. package/lib/rules/global-require.js +5 -2
  38. package/lib/rules/guard-for-in.js +5 -2
  39. package/lib/rules/handle-callback-err.js +5 -2
  40. package/lib/rules/id-blacklist.js +4 -1
  41. package/lib/rules/id-length.js +9 -6
  42. package/lib/rules/id-match.js +11 -5
  43. package/lib/rules/implicit-arrow-linebreak.js +7 -3
  44. package/lib/rules/indent-legacy.js +11 -5
  45. package/lib/rules/indent.js +18 -9
  46. package/lib/rules/init-declarations.js +13 -13
  47. package/lib/rules/jsx-quotes.js +5 -2
  48. package/lib/rules/key-spacing.js +70 -35
  49. package/lib/rules/keyword-spacing.js +18 -12
  50. package/lib/rules/line-comment-position.js +15 -8
  51. package/lib/rules/linebreak-style.js +6 -6
  52. package/lib/rules/lines-around-comment.js +20 -16
  53. package/lib/rules/lines-around-directive.js +5 -2
  54. package/lib/rules/lines-between-class-members.js +8 -6
  55. package/lib/rules/max-depth.js +11 -9
  56. package/lib/rules/max-len.js +24 -13
  57. package/lib/rules/max-lines-per-function.js +17 -18
  58. package/lib/rules/max-lines.js +14 -10
  59. package/lib/rules/max-nested-callbacks.js +12 -11
  60. package/lib/rules/max-params.js +11 -9
  61. package/lib/rules/max-statements-per-line.js +8 -5
  62. package/lib/rules/max-statements.js +12 -11
  63. package/lib/rules/multiline-comment-style.js +18 -17
  64. package/lib/rules/multiline-ternary.js +8 -6
  65. package/lib/rules/new-cap.js +18 -11
  66. package/lib/rules/new-parens.js +5 -2
  67. package/lib/rules/newline-after-var.js +6 -8
  68. package/lib/rules/newline-before-return.js +5 -1
  69. package/lib/rules/newline-per-chained-call.js +7 -3
  70. package/lib/rules/no-async-promise-executor.js +5 -2
  71. package/lib/rules/no-bitwise.js +2 -1
  72. package/lib/rules/no-confusing-arrow.js +1 -1
  73. package/lib/rules/no-constant-condition.js +24 -2
  74. package/lib/rules/no-duplicate-imports.js +17 -11
  75. package/lib/rules/no-else-return.js +2 -1
  76. package/lib/rules/no-empty.js +2 -1
  77. package/lib/rules/no-eval.js +1 -1
  78. package/lib/rules/no-extra-parens.js +4 -4
  79. package/lib/rules/no-fallthrough.js +8 -4
  80. package/lib/rules/no-floating-decimal.js +7 -3
  81. package/lib/rules/no-implicit-coercion.js +9 -6
  82. package/lib/rules/no-irregular-whitespace.js +8 -4
  83. package/lib/rules/no-labels.js +6 -4
  84. package/lib/rules/no-magic-numbers.js +6 -3
  85. package/lib/rules/no-mixed-operators.js +5 -4
  86. package/lib/rules/no-mixed-requires.js +4 -2
  87. package/lib/rules/no-multi-spaces.js +2 -1
  88. package/lib/rules/no-param-reassign.js +1 -1
  89. package/lib/rules/no-plusplus.js +2 -1
  90. package/lib/rules/no-redeclare.js +2 -2
  91. package/lib/rules/no-self-assign.js +2 -1
  92. package/lib/rules/no-shadow-restricted-names.js +16 -2
  93. package/lib/rules/no-shadow.js +3 -3
  94. package/lib/rules/no-sync.js +2 -1
  95. package/lib/rules/no-tabs.js +2 -1
  96. package/lib/rules/no-trailing-spaces.js +5 -3
  97. package/lib/rules/no-undef.js +7 -3
  98. package/lib/rules/no-underscore-dangle.js +6 -3
  99. package/lib/rules/no-unexpected-multiline.js +14 -13
  100. package/lib/rules/no-unneeded-ternary.js +2 -1
  101. package/lib/rules/no-unsafe-negation.js +6 -3
  102. package/lib/rules/no-unused-expressions.js +6 -3
  103. package/lib/rules/no-unused-labels.js +7 -2
  104. package/lib/rules/no-unused-vars.js +8 -4
  105. package/lib/rules/no-use-before-define.js +3 -3
  106. package/lib/rules/no-useless-rename.js +3 -3
  107. package/lib/rules/object-curly-newline.js +6 -4
  108. package/lib/rules/object-property-newline.js +5 -3
  109. package/lib/rules/object-shorthand.js +9 -5
  110. package/lib/rules/one-var.js +24 -38
  111. package/lib/rules/operator-assignment.js +8 -4
  112. package/lib/rules/padded-blocks.js +32 -9
  113. package/lib/rules/prefer-arrow-callback.js +4 -2
  114. package/lib/rules/prefer-const.js +7 -4
  115. package/lib/rules/prefer-destructuring.js +70 -12
  116. package/lib/rules/prefer-promise-reject-errors.js +1 -1
  117. package/lib/rules/prefer-spread.js +2 -13
  118. package/lib/rules/quote-props.js +10 -5
  119. package/lib/rules/quotes.js +4 -2
  120. package/lib/rules/require-jsdoc.js +13 -7
  121. package/lib/rules/semi-spacing.js +6 -8
  122. package/lib/rules/semi.js +5 -4
  123. package/lib/rules/sort-imports.js +6 -3
  124. package/lib/rules/sort-keys.js +13 -5
  125. package/lib/rules/sort-vars.js +2 -1
  126. package/lib/rules/space-before-function-paren.js +6 -3
  127. package/lib/rules/space-infix-ops.js +2 -1
  128. package/lib/rules/space-unary-ops.js +20 -10
  129. package/lib/rules/spaced-comment.js +2 -1
  130. package/lib/rules/strict.js +34 -35
  131. package/lib/rules/switch-colon-spacing.js +11 -8
  132. package/lib/rules/symbol-description.js +6 -3
  133. package/lib/rules/template-curly-spacing.js +10 -10
  134. package/lib/rules/template-tag-spacing.js +7 -3
  135. package/lib/rules/unicode-bom.js +7 -3
  136. package/lib/rules/use-isnan.js +5 -2
  137. package/lib/rules/valid-jsdoc.js +40 -19
  138. package/lib/rules/valid-typeof.js +9 -4
  139. package/lib/rules/vars-on-top.js +6 -4
  140. package/lib/rules/wrap-iife.js +12 -6
  141. package/lib/rules/yield-star-spacing.js +17 -10
  142. package/lib/rules/yoda.js +9 -4
  143. package/lib/rules.js +4 -34
  144. package/lib/util/ajv.js +1 -0
  145. package/lib/util/config-comment-parser.js +7 -10
  146. package/package.json +20 -20
@@ -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
- message: "Use '{{expectedTypeName}}' instead of '{{currentTypeName}}'.",
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, message: "JSDoc type missing brace." });
304
+ context.report({ node: jsdocNode, messageId: "missingBrace" });
284
305
  } else {
285
- context.report({ node: jsdocNode, message: "JSDoc syntax error." });
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
- message: "Use @{{name}} instead.",
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
- message: "Missing JSDoc parameter type for '{{name}}'.",
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
- message: "Missing JSDoc parameter description for '{{name}}'.",
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
- message: "Duplicate JSDoc parameter '{{name}}'.",
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
- message: "Unexpected @{{title}} tag; function has no return statement.",
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, message: "Missing JSDoc return type." });
424
+ context.report({ node: jsdocNode, messageId: "missingReturnType" });
404
425
  }
405
426
 
406
427
  if (!isValidReturnType(returnsTag) && !returnsTag.description && requireReturnDescription) {
407
- context.report({ node: jsdocNode, message: "Missing JSDoc return description." });
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
- message: "Missing JSDoc @{{returns}} for function.",
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
- message: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.",
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
- message: "Missing JSDoc for parameter '{{name}}'.",
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, message: "JSDoc description does not satisfy the regex pattern." });
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, message: "Invalid typeof comparison value." });
73
+ context.report({ node: sibling, messageId: "invalidValue" });
69
74
  }
70
75
  } else if (requireStringLiterals && !isTypeofExpression(sibling)) {
71
- context.report({ node: sibling, message: "Typeof comparisons should be to string literals." });
76
+ context.report({ node: sibling, messageId: "notString" });
72
77
  }
73
78
  }
74
79
  }
@@ -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, message: errorMessage });
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, message: errorMessage });
123
+ context.report({ node, messageId: "top" });
122
124
  }
123
125
  }
124
126
 
@@ -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 = (context.options[1] && context.options[1].functionPrototypeMethods) || false;
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
- message: "Wrap an immediate function invocation in parentheses.",
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
- message: "Wrap only the function expression in parens.",
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
- message: "Move the invocation into the parens that contain the function.",
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
- const type = spaceRequired ? "Missing" : "Unexpected";
74
- const message = "{{type}} space {{side}} *.";
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
- message,
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
- message: "Expected literal to be on the {{expectedSide}} side of {{operator}}.",
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
- this.load();
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
@@ -17,6 +17,7 @@ const Ajv = require("ajv"),
17
17
 
18
18
  const ajv = new Ajv({
19
19
  meta: false,
20
+ useDefaults: true,
20
21
  validateSchema: false,
21
22
  missingRefs: "ignore",
22
23
  verbose: true,
@@ -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:boolean_value" or/and "name" options divided by comma or
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 boolean values
33
+ * @returns {Object} Result map object of names and string values, or null values if no value was provided
34
34
  */
35
- parseBooleanConfig(string, comment) {
36
- debug("Parsing Boolean config");
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 "false" (if not provided), e.g: "foo" => ["foo", "false"]
49
- const [key, value = "false"] = name.split(":");
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.12.0",
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.5.3",
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": "^2.1.0",
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.0",
47
+ "espree": "^5.0.1",
48
48
  "esquery": "^1.0.1",
49
49
  "esutils": "^2.0.2",
50
- "file-entry-cache": "^2.0.0",
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.1.0",
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.5",
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.0.2",
72
+ "table": "^5.2.3",
74
73
  "text-table": "^0.2.0"
75
74
  },
76
75
  "devDependencies": {
77
- "babel-core": "^6.26.3",
78
- "babel-polyfill": "^6.26.0",
79
- "babel-preset-es2015": "^6.24.1",
80
- "babelify": "^8.0.0",
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": "^1.6.2",
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.0.0",
99
- "karma-babel-preprocessor": "^7.0.0",
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.11.0",
105
+ "markdownlint": "^0.12.0",
106
106
  "mocha": "^5.0.5",
107
- "mock-fs": "^4.6.0",
107
+ "mock-fs": "^4.8.0",
108
108
  "npm-license": "^0.3.3",
109
109
  "proxyquire": "^2.0.1",
110
- "puppeteer": "^1.9.0",
110
+ "puppeteer": "^1.12.2",
111
111
  "shelljs": "^0.8.2",
112
112
  "sinon": "^3.3.0",
113
- "temp": "^0.8.3",
113
+ "temp": "^0.9.0",
114
114
  "through": "^2.3.8"
115
115
  },
116
116
  "keywords": [