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
@@ -21,9 +21,9 @@ const ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"];
21
21
  */
22
22
  function parseOptions(options) {
23
23
  return {
24
- boolean: "boolean" in options ? Boolean(options.boolean) : true,
25
- number: "number" in options ? Boolean(options.number) : true,
26
- string: "string" in options ? Boolean(options.string) : true,
24
+ boolean: "boolean" in options ? options.boolean : true,
25
+ number: "number" in options ? options.number : true,
26
+ string: "string" in options ? options.string : true,
27
27
  allow: options.allow || []
28
28
  };
29
29
  }
@@ -167,13 +167,16 @@ module.exports = {
167
167
  type: "object",
168
168
  properties: {
169
169
  boolean: {
170
- type: "boolean"
170
+ type: "boolean",
171
+ default: true
171
172
  },
172
173
  number: {
173
- type: "boolean"
174
+ type: "boolean",
175
+ default: true
174
176
  },
175
177
  string: {
176
- type: "boolean"
178
+ type: "boolean",
179
+ default: true
177
180
  },
178
181
  allow: {
179
182
  type: "array",
@@ -41,16 +41,20 @@ module.exports = {
41
41
  type: "object",
42
42
  properties: {
43
43
  skipComments: {
44
- type: "boolean"
44
+ type: "boolean",
45
+ default: false
45
46
  },
46
47
  skipStrings: {
47
- type: "boolean"
48
+ type: "boolean",
49
+ default: true
48
50
  },
49
51
  skipTemplates: {
50
- type: "boolean"
52
+ type: "boolean",
53
+ default: false
51
54
  },
52
55
  skipRegExps: {
53
- type: "boolean"
56
+ type: "boolean",
57
+ default: false
54
58
  }
55
59
  },
56
60
  additionalProperties: false
@@ -30,10 +30,12 @@ module.exports = {
30
30
  type: "object",
31
31
  properties: {
32
32
  allowLoop: {
33
- type: "boolean"
33
+ type: "boolean",
34
+ default: false
34
35
  },
35
36
  allowSwitch: {
36
- type: "boolean"
37
+ type: "boolean",
38
+ default: false
37
39
  }
38
40
  },
39
41
  additionalProperties: false
@@ -43,8 +45,8 @@ module.exports = {
43
45
 
44
46
  create(context) {
45
47
  const options = context.options[0];
46
- const allowLoop = Boolean(options && options.allowLoop);
47
- const allowSwitch = Boolean(options && options.allowSwitch);
48
+ const allowLoop = options && options.allowLoop;
49
+ const allowSwitch = options && options.allowSwitch;
48
50
  let scopeInfo = null;
49
51
 
50
52
  /**
@@ -24,10 +24,12 @@ module.exports = {
24
24
  type: "object",
25
25
  properties: {
26
26
  detectObjects: {
27
- type: "boolean"
27
+ type: "boolean",
28
+ default: false
28
29
  },
29
30
  enforceConst: {
30
- type: "boolean"
31
+ type: "boolean",
32
+ default: false
31
33
  },
32
34
  ignore: {
33
35
  type: "array",
@@ -37,7 +39,8 @@ module.exports = {
37
39
  uniqueItems: true
38
40
  },
39
41
  ignoreArrayIndexes: {
40
- type: "boolean"
42
+ type: "boolean",
43
+ default: false
41
44
  }
42
45
  },
43
46
  additionalProperties: false
@@ -42,10 +42,10 @@ const TARGET_NODE_TYPE = /^(?:Binary|Logical)Expression$/;
42
42
  * @param {Object|undefined} options - A options object to normalize.
43
43
  * @returns {Object} Normalized option object.
44
44
  */
45
- function normalizeOptions(options) {
46
- const hasGroups = (options && options.groups && options.groups.length > 0);
45
+ function normalizeOptions(options = {}) {
46
+ const hasGroups = options.groups && options.groups.length > 0;
47
47
  const groups = hasGroups ? options.groups : DEFAULT_GROUPS;
48
- const allowSamePrecedence = (options && options.allowSamePrecedence) !== false;
48
+ const allowSamePrecedence = options.allowSamePrecedence !== false;
49
49
 
50
50
  return {
51
51
  groups,
@@ -95,7 +95,8 @@ module.exports = {
95
95
  uniqueItems: true
96
96
  },
97
97
  allowSamePrecedence: {
98
- type: "boolean"
98
+ type: "boolean",
99
+ default: true
99
100
  }
100
101
  },
101
102
  additionalProperties: false
@@ -30,10 +30,12 @@ module.exports = {
30
30
  type: "object",
31
31
  properties: {
32
32
  grouping: {
33
- type: "boolean"
33
+ type: "boolean",
34
+ default: false
34
35
  },
35
36
  allowCall: {
36
- type: "boolean"
37
+ type: "boolean",
38
+ default: false
37
39
  }
38
40
  },
39
41
  additionalProperties: false
@@ -38,7 +38,8 @@ module.exports = {
38
38
  additionalProperties: false
39
39
  },
40
40
  ignoreEOLComments: {
41
- type: "boolean"
41
+ type: "boolean",
42
+ default: false
42
43
  }
43
44
  },
44
45
  additionalProperties: false
@@ -55,7 +55,7 @@ module.exports = {
55
55
  },
56
56
 
57
57
  create(context) {
58
- const props = context.options[0] && Boolean(context.options[0].props);
58
+ const props = context.options[0] && context.options[0].props;
59
59
  const ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || [];
60
60
 
61
61
  /**
@@ -26,7 +26,8 @@ module.exports = {
26
26
  type: "object",
27
27
  properties: {
28
28
  allowForLoopAfterthoughts: {
29
- type: "boolean"
29
+ type: "boolean",
30
+ default: false
30
31
  }
31
32
  },
32
33
  additionalProperties: false
@@ -24,7 +24,7 @@ module.exports = {
24
24
  {
25
25
  type: "object",
26
26
  properties: {
27
- builtinGlobals: { type: "boolean" }
27
+ builtinGlobals: { type: "boolean", default: false }
28
28
  },
29
29
  additionalProperties: false
30
30
  }
@@ -33,7 +33,7 @@ module.exports = {
33
33
 
34
34
  create(context) {
35
35
  const options = {
36
- builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals)
36
+ builtinGlobals: context.options[0] && context.options[0].builtinGlobals
37
37
  };
38
38
 
39
39
  /**
@@ -179,7 +179,8 @@ module.exports = {
179
179
  type: "object",
180
180
  properties: {
181
181
  props: {
182
- type: "boolean"
182
+ type: "boolean",
183
+ default: true
183
184
  }
184
185
  },
185
186
  additionalProperties: false
@@ -4,6 +4,19 @@
4
4
  */
5
5
  "use strict";
6
6
 
7
+ /**
8
+ * Determines if a variable safely shadows undefined.
9
+ * This is the case when a variable named `undefined` is never assigned to a value (i.e. it always shares the same value
10
+ * as the global).
11
+ * @param {eslintScope.Variable} variable The variable to check
12
+ * @returns {boolean} true if this variable safely shadows `undefined`
13
+ */
14
+ function safelyShadowsUndefined(variable) {
15
+ return variable.name === "undefined" &&
16
+ variable.references.every(ref => !ref.isWrite()) &&
17
+ variable.defs.every(def => def.node.type === "VariableDeclarator" && def.node.init === null);
18
+ }
19
+
7
20
  //------------------------------------------------------------------------------
8
21
  // Rule Definition
9
22
  //------------------------------------------------------------------------------
@@ -24,12 +37,13 @@ module.exports = {
24
37
 
25
38
  create(context) {
26
39
 
27
- const RESTRICTED = ["undefined", "NaN", "Infinity", "arguments", "eval"];
40
+
41
+ const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]);
28
42
 
29
43
  return {
30
44
  "VariableDeclaration, :function, CatchClause"(node) {
31
45
  for (const variable of context.getDeclaredVariables(node)) {
32
- if (variable.defs.length > 0 && RESTRICTED.includes(variable.name)) {
46
+ if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) {
33
47
  context.report({
34
48
  node: variable.defs[0].name,
35
49
  message: "Shadowing of global property '{{idName}}'.",
@@ -30,8 +30,8 @@ module.exports = {
30
30
  {
31
31
  type: "object",
32
32
  properties: {
33
- builtinGlobals: { type: "boolean" },
34
- hoist: { enum: ["all", "functions", "never"] },
33
+ builtinGlobals: { type: "boolean", default: false },
34
+ hoist: { enum: ["all", "functions", "never"], default: "functions" },
35
35
  allow: {
36
36
  type: "array",
37
37
  items: {
@@ -47,7 +47,7 @@ module.exports = {
47
47
  create(context) {
48
48
 
49
49
  const options = {
50
- builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals),
50
+ builtinGlobals: context.options[0] && context.options[0].builtinGlobals,
51
51
  hoist: (context.options[0] && context.options[0].hoist) || "functions",
52
52
  allow: (context.options[0] && context.options[0].allow) || []
53
53
  };
@@ -27,7 +27,8 @@ module.exports = {
27
27
  type: "object",
28
28
  properties: {
29
29
  allowAtRootLevel: {
30
- type: "boolean"
30
+ type: "boolean",
31
+ default: false
31
32
  }
32
33
  },
33
34
  additionalProperties: false
@@ -30,7 +30,8 @@ module.exports = {
30
30
  type: "object",
31
31
  properties: {
32
32
  allowIndentationTabs: {
33
- type: "boolean"
33
+ type: "boolean",
34
+ default: false
34
35
  }
35
36
  },
36
37
  additionalProperties: false
@@ -32,10 +32,12 @@ module.exports = {
32
32
  type: "object",
33
33
  properties: {
34
34
  skipBlankLines: {
35
- type: "boolean"
35
+ type: "boolean",
36
+ default: false
36
37
  },
37
38
  ignoreComments: {
38
- type: "boolean"
39
+ type: "boolean",
40
+ default: false
39
41
  }
40
42
  },
41
43
  additionalProperties: false
@@ -52,7 +54,7 @@ module.exports = {
52
54
 
53
55
  const options = context.options[0] || {},
54
56
  skipBlankLines = options.skipBlankLines || false,
55
- ignoreComments = typeof options.ignoreComments === "boolean" && options.ignoreComments;
57
+ ignoreComments = options.ignoreComments || false;
56
58
 
57
59
  /**
58
60
  * Report the error message
@@ -39,12 +39,16 @@ module.exports = {
39
39
  type: "object",
40
40
  properties: {
41
41
  typeof: {
42
- type: "boolean"
42
+ type: "boolean",
43
+ default: false
43
44
  }
44
45
  },
45
46
  additionalProperties: false
46
47
  }
47
- ]
48
+ ],
49
+ messages: {
50
+ undef: "'{{name}}' is not defined."
51
+ }
48
52
  },
49
53
 
50
54
  create(context) {
@@ -64,7 +68,7 @@ module.exports = {
64
68
 
65
69
  context.report({
66
70
  node: identifier,
67
- message: "'{{name}}' is not defined.",
71
+ messageId: "undef",
68
72
  data: identifier
69
73
  });
70
74
  });
@@ -31,13 +31,16 @@ module.exports = {
31
31
  }
32
32
  },
33
33
  allowAfterThis: {
34
- type: "boolean"
34
+ type: "boolean",
35
+ default: false
35
36
  },
36
37
  allowAfterSuper: {
37
- type: "boolean"
38
+ type: "boolean",
39
+ default: false
38
40
  },
39
41
  enforceInMethodNames: {
40
- type: "boolean"
42
+ type: "boolean",
43
+ default: false
41
44
  }
42
45
  },
43
46
  additionalProperties: false
@@ -25,16 +25,17 @@ module.exports = {
25
25
  url: "https://eslint.org/docs/rules/no-unexpected-multiline"
26
26
  },
27
27
 
28
- schema: []
28
+ schema: [],
29
+ messages: {
30
+ function: "Unexpected newline between function and ( of function call.",
31
+ property: "Unexpected newline between object and [ of property access.",
32
+ taggedTemplate: "Unexpected newline between template tag and template literal.",
33
+ division: "Unexpected newline between numerator and division operator."
34
+ }
29
35
  },
30
36
 
31
37
  create(context) {
32
38
 
33
- const FUNCTION_MESSAGE = "Unexpected newline between function and ( of function call.";
34
- const PROPERTY_MESSAGE = "Unexpected newline between object and [ of property access.";
35
- const TAGGED_TEMPLATE_MESSAGE = "Unexpected newline between template tag and template literal.";
36
- const DIVISION_MESSAGE = "Unexpected newline between numerator and division operator.";
37
-
38
39
  const REGEX_FLAG_MATCHER = /^[gimsuy]+$/;
39
40
 
40
41
  const sourceCode = context.getSourceCode();
@@ -43,16 +44,16 @@ module.exports = {
43
44
  * Check to see if there is a newline between the node and the following open bracket
44
45
  * line's expression
45
46
  * @param {ASTNode} node The node to check.
46
- * @param {string} msg The error message to use.
47
+ * @param {string} messageId The error messageId to use.
47
48
  * @returns {void}
48
49
  * @private
49
50
  */
50
- function checkForBreakAfter(node, msg) {
51
+ function checkForBreakAfter(node, messageId) {
51
52
  const openParen = sourceCode.getTokenAfter(node, astUtils.isNotClosingParenToken);
52
53
  const nodeExpressionEnd = sourceCode.getTokenBefore(openParen);
53
54
 
54
55
  if (openParen.loc.start.line !== nodeExpressionEnd.loc.end.line) {
55
- context.report({ node, loc: openParen.loc.start, message: msg, data: { char: openParen.value } });
56
+ context.report({ node, loc: openParen.loc.start, messageId, data: { char: openParen.value } });
56
57
  }
57
58
  }
58
59
 
@@ -66,21 +67,21 @@ module.exports = {
66
67
  if (!node.computed) {
67
68
  return;
68
69
  }
69
- checkForBreakAfter(node.object, PROPERTY_MESSAGE);
70
+ checkForBreakAfter(node.object, "property");
70
71
  },
71
72
 
72
73
  TaggedTemplateExpression(node) {
73
74
  if (node.tag.loc.end.line === node.quasi.loc.start.line) {
74
75
  return;
75
76
  }
76
- context.report({ node, loc: node.loc.start, message: TAGGED_TEMPLATE_MESSAGE });
77
+ context.report({ node, loc: node.loc.start, messageId: "taggedTemplate" });
77
78
  },
78
79
 
79
80
  CallExpression(node) {
80
81
  if (node.arguments.length === 0) {
81
82
  return;
82
83
  }
83
- checkForBreakAfter(node.callee, FUNCTION_MESSAGE);
84
+ checkForBreakAfter(node.callee, "function");
84
85
  },
85
86
 
86
87
  "BinaryExpression[operator='/'] > BinaryExpression[operator='/'].left"(node) {
@@ -92,7 +93,7 @@ module.exports = {
92
93
  REGEX_FLAG_MATCHER.test(tokenAfterOperator.value) &&
93
94
  secondSlash.range[1] === tokenAfterOperator.range[0]
94
95
  ) {
95
- checkForBreakAfter(node.left, DIVISION_MESSAGE);
96
+ checkForBreakAfter(node.left, "division");
96
97
  }
97
98
  }
98
99
  };
@@ -38,7 +38,8 @@ module.exports = {
38
38
  type: "object",
39
39
  properties: {
40
40
  defaultAssignment: {
41
- type: "boolean"
41
+ type: "boolean",
42
+ default: true
42
43
  }
43
44
  },
44
45
  additionalProperties: false
@@ -51,7 +51,10 @@ module.exports = {
51
51
  },
52
52
 
53
53
  schema: [],
54
- fixable: "code"
54
+ fixable: "code",
55
+ messages: {
56
+ unexpected: "Unexpected negating the left operand of '{{operator}}' operator."
57
+ }
55
58
  },
56
59
 
57
60
  create(context) {
@@ -66,8 +69,8 @@ module.exports = {
66
69
  context.report({
67
70
  node,
68
71
  loc: node.left.loc,
69
- message: "Unexpected negating the left operand of '{{operator}}' operator.",
70
- data: node,
72
+ messageId: "unexpected",
73
+ data: { operator: node.operator },
71
74
 
72
75
  fix(fixer) {
73
76
  const negationToken = sourceCode.getFirstToken(node.left);
@@ -24,13 +24,16 @@ module.exports = {
24
24
  type: "object",
25
25
  properties: {
26
26
  allowShortCircuit: {
27
- type: "boolean"
27
+ type: "boolean",
28
+ default: false
28
29
  },
29
30
  allowTernary: {
30
- type: "boolean"
31
+ type: "boolean",
32
+ default: false
31
33
  },
32
34
  allowTaggedTemplates: {
33
- type: "boolean"
35
+ type: "boolean",
36
+ default: false
34
37
  }
35
38
  },
36
39
  additionalProperties: false
@@ -21,7 +21,12 @@ module.exports = {
21
21
  },
22
22
 
23
23
  schema: [],
24
- fixable: "code"
24
+
25
+ fixable: "code",
26
+
27
+ messages: {
28
+ unused: "'{{name}}:' is defined but never used."
29
+ }
25
30
  },
26
31
 
27
32
  create(context) {
@@ -53,7 +58,7 @@ module.exports = {
53
58
  if (!scopeInfo.used) {
54
59
  context.report({
55
60
  node: node.label,
56
- message: "'{{name}}:' is defined but never used.",
61
+ messageId: "unused",
57
62
  data: node.label,
58
63
  fix(fixer) {
59
64
 
@@ -37,22 +37,26 @@ module.exports = {
37
37
  type: "object",
38
38
  properties: {
39
39
  vars: {
40
- enum: ["all", "local"]
40
+ enum: ["all", "local"],
41
+ default: "all"
41
42
  },
42
43
  varsIgnorePattern: {
43
44
  type: "string"
44
45
  },
45
46
  args: {
46
- enum: ["all", "after-used", "none"]
47
+ enum: ["all", "after-used", "none"],
48
+ default: "after-used"
47
49
  },
48
50
  ignoreRestSiblings: {
49
- type: "boolean"
51
+ type: "boolean",
52
+ default: false
50
53
  },
51
54
  argsIgnorePattern: {
52
55
  type: "string"
53
56
  },
54
57
  caughtErrors: {
55
- enum: ["all", "none"]
58
+ enum: ["all", "none"],
59
+ default: "none"
56
60
  },
57
61
  caughtErrorsIgnorePattern: {
58
62
  type: "string"
@@ -154,9 +154,9 @@ module.exports = {
154
154
  {
155
155
  type: "object",
156
156
  properties: {
157
- functions: { type: "boolean" },
158
- classes: { type: "boolean" },
159
- variables: { type: "boolean" }
157
+ functions: { type: "boolean", default: true },
158
+ classes: { type: "boolean", default: true },
159
+ variables: { type: "boolean", default: true }
160
160
  },
161
161
  additionalProperties: false
162
162
  }
@@ -26,9 +26,9 @@ module.exports = {
26
26
  {
27
27
  type: "object",
28
28
  properties: {
29
- ignoreDestructuring: { type: "boolean" },
30
- ignoreImport: { type: "boolean" },
31
- ignoreExport: { type: "boolean" }
29
+ ignoreDestructuring: { type: "boolean", default: false },
30
+ ignoreImport: { type: "boolean", default: false },
31
+ ignoreExport: { type: "boolean", default: false }
32
32
  },
33
33
  additionalProperties: false
34
34
  }
@@ -26,14 +26,16 @@ const OPTION_VALUE = {
26
26
  type: "object",
27
27
  properties: {
28
28
  multiline: {
29
- type: "boolean"
29
+ type: "boolean",
30
+ default: false
30
31
  },
31
32
  minProperties: {
32
33
  type: "integer",
33
34
  minimum: 0
34
35
  },
35
36
  consistent: {
36
- type: "boolean"
37
+ type: "boolean",
38
+ default: false
37
39
  }
38
40
  },
39
41
  additionalProperties: false,
@@ -59,9 +61,9 @@ function normalizeOptionValue(value) {
59
61
  } else if (value === "never") {
60
62
  minProperties = Number.POSITIVE_INFINITY;
61
63
  } else {
62
- multiline = Boolean(value.multiline);
64
+ multiline = value.multiline;
63
65
  minProperties = value.minProperties || Number.POSITIVE_INFINITY;
64
- consistent = Boolean(value.consistent);
66
+ consistent = value.consistent;
65
67
  }
66
68
  } else {
67
69
  consistent = true;
@@ -25,10 +25,12 @@ module.exports = {
25
25
  type: "object",
26
26
  properties: {
27
27
  allowAllPropertiesOnSameLine: {
28
- type: "boolean"
28
+ type: "boolean",
29
+ default: false
29
30
  },
30
31
  allowMultiplePropertiesPerLine: { // Deprecated
31
- type: "boolean"
32
+ type: "boolean",
33
+ default: false
32
34
  }
33
35
  },
34
36
  additionalProperties: false
@@ -40,7 +42,7 @@ module.exports = {
40
42
 
41
43
  create(context) {
42
44
  const allowSameLine = context.options[0] && (
43
- (Boolean(context.options[0].allowAllPropertiesOnSameLine) || Boolean(context.options[0].allowMultiplePropertiesPerLine)) // Deprecated
45
+ (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine /* Deprecated */)
44
46
  );
45
47
  const errorMessage = allowSameLine
46
48
  ? "Object properties must go on a new line if they aren't all on the same line."