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
@@ -25,7 +25,8 @@ module.exports = {
25
25
  type: "object",
26
26
  properties: {
27
27
  ignoreCase: {
28
- type: "boolean"
28
+ type: "boolean",
29
+ default: false
29
30
  },
30
31
  memberSyntaxSortOrder: {
31
32
  type: "array",
@@ -37,10 +38,12 @@ module.exports = {
37
38
  maxItems: 4
38
39
  },
39
40
  ignoreDeclarationSort: {
40
- type: "boolean"
41
+ type: "boolean",
42
+ default: false
41
43
  },
42
44
  ignoreMemberSort: {
43
- type: "boolean"
45
+ type: "boolean",
46
+ default: false
44
47
  }
45
48
  },
46
49
  additionalProperties: false
@@ -90,10 +90,12 @@ module.exports = {
90
90
  type: "object",
91
91
  properties: {
92
92
  caseSensitive: {
93
- type: "boolean"
93
+ type: "boolean",
94
+ default: true
94
95
  },
95
96
  natural: {
96
- type: "boolean"
97
+ type: "boolean",
98
+ default: false
97
99
  }
98
100
  },
99
101
  additionalProperties: false
@@ -106,8 +108,8 @@ module.exports = {
106
108
  // Parse options.
107
109
  const order = context.options[0] || "asc";
108
110
  const options = context.options[1];
109
- const insensitive = (options && options.caseSensitive) === false;
110
- const natual = Boolean(options && options.natural);
111
+ const insensitive = options && options.caseSensitive === false;
112
+ const natual = options && options.natural;
111
113
  const isValidOrder = isValidOrders[
112
114
  order + (insensitive ? "I" : "") + (natual ? "N" : "")
113
115
  ];
@@ -127,8 +129,14 @@ module.exports = {
127
129
  stack = stack.upper;
128
130
  },
129
131
 
132
+ SpreadElement(node) {
133
+ if (node.parent.type === "ObjectExpression") {
134
+ stack.prevName = null;
135
+ }
136
+ },
137
+
130
138
  Property(node) {
131
- if (node.parent.type === "ObjectPattern" || node.parent.properties.some(n => n.type === "SpreadElement")) {
139
+ if (node.parent.type === "ObjectPattern") {
132
140
  return;
133
141
  }
134
142
 
@@ -25,7 +25,8 @@ module.exports = {
25
25
  type: "object",
26
26
  properties: {
27
27
  ignoreCase: {
28
- type: "boolean"
28
+ type: "boolean",
29
+ default: false
29
30
  }
30
31
  },
31
32
  additionalProperties: false
@@ -37,13 +37,16 @@ module.exports = {
37
37
  type: "object",
38
38
  properties: {
39
39
  anonymous: {
40
- enum: ["always", "never", "ignore"]
40
+ enum: ["always", "never", "ignore"],
41
+ default: "always"
41
42
  },
42
43
  named: {
43
- enum: ["always", "never", "ignore"]
44
+ enum: ["always", "never", "ignore"],
45
+ default: "always"
44
46
  },
45
47
  asyncArrow: {
46
- enum: ["always", "never", "ignore"]
48
+ enum: ["always", "never", "ignore"],
49
+ default: "always"
47
50
  }
48
51
  },
49
52
  additionalProperties: false
@@ -26,7 +26,8 @@ module.exports = {
26
26
  type: "object",
27
27
  properties: {
28
28
  int32Hint: {
29
- type: "boolean"
29
+ type: "boolean",
30
+ default: false
30
31
  }
31
32
  },
32
33
  additionalProperties: false
@@ -32,10 +32,12 @@ module.exports = {
32
32
  type: "object",
33
33
  properties: {
34
34
  words: {
35
- type: "boolean"
35
+ type: "boolean",
36
+ default: true
36
37
  },
37
38
  nonwords: {
38
- type: "boolean"
39
+ type: "boolean",
40
+ default: false
39
41
  },
40
42
  overrides: {
41
43
  type: "object",
@@ -46,11 +48,19 @@ module.exports = {
46
48
  },
47
49
  additionalProperties: false
48
50
  }
49
- ]
51
+ ],
52
+ messages: {
53
+ unexpectedBefore: "Unexpected space before unary operator '{{operator}}'.",
54
+ unexpectedAfter: "Unexpected space after unary operator '{{operator}}'.",
55
+ unexpectedAfterWord: "Unexpected space after unary word operator '{{word}}'.",
56
+ wordOperator: "Unary word operator '{{word}}' must be followed by whitespace.",
57
+ operator: "Unary operator '{{operator}}' must be followed by whitespace.",
58
+ beforeUnaryExpressions: "Space is required before unary expressions '{{token}}'."
59
+ }
50
60
  },
51
61
 
52
62
  create(context) {
53
- const options = context.options && Array.isArray(context.options) && context.options[0] || { words: true, nonwords: false };
63
+ const options = context.options[0] || { words: true, nonwords: false };
54
64
 
55
65
  const sourceCode = context.getSourceCode();
56
66
 
@@ -98,7 +108,7 @@ module.exports = {
98
108
  if (secondToken.range[0] === firstToken.range[1]) {
99
109
  context.report({
100
110
  node,
101
- message: "Unary word operator '{{word}}' must be followed by whitespace.",
111
+ messageId: "wordOperator",
102
112
  data: {
103
113
  word
104
114
  },
@@ -122,7 +132,7 @@ module.exports = {
122
132
  if (secondToken.range[0] > firstToken.range[1]) {
123
133
  context.report({
124
134
  node,
125
- message: "Unexpected space after unary word operator '{{word}}'.",
135
+ messageId: "unexpectedAfterWord",
126
136
  data: {
127
137
  word
128
138
  },
@@ -198,7 +208,7 @@ module.exports = {
198
208
  if (firstToken.range[1] === secondToken.range[0]) {
199
209
  context.report({
200
210
  node,
201
- message: "Unary operator '{{operator}}' must be followed by whitespace.",
211
+ messageId: "operator",
202
212
  data: {
203
213
  operator: firstToken.value
204
214
  },
@@ -211,7 +221,7 @@ module.exports = {
211
221
  if (firstToken.range[1] === secondToken.range[0]) {
212
222
  context.report({
213
223
  node,
214
- message: "Space is required before unary expressions '{{token}}'.",
224
+ messageId: "beforeUnaryExpressions",
215
225
  data: {
216
226
  token: secondToken.value
217
227
  },
@@ -235,7 +245,7 @@ module.exports = {
235
245
  if (secondToken.range[0] > firstToken.range[1]) {
236
246
  context.report({
237
247
  node,
238
- message: "Unexpected space after unary operator '{{operator}}'.",
248
+ messageId: "unexpectedAfter",
239
249
  data: {
240
250
  operator: firstToken.value
241
251
  },
@@ -251,7 +261,7 @@ module.exports = {
251
261
  if (secondToken.range[0] > firstToken.range[1]) {
252
262
  context.report({
253
263
  node,
254
- message: "Unexpected space before unary operator '{{operator}}'.",
264
+ messageId: "unexpectedBefore",
255
265
  data: {
256
266
  operator: secondToken.value
257
267
  },
@@ -215,7 +215,8 @@ module.exports = {
215
215
  }
216
216
  },
217
217
  balanced: {
218
- type: "boolean"
218
+ type: "boolean",
219
+ default: false
219
220
  }
220
221
  },
221
222
  additionalProperties: false
@@ -15,19 +15,6 @@ const astUtils = require("../util/ast-utils");
15
15
  // Helpers
16
16
  //------------------------------------------------------------------------------
17
17
 
18
- const messages = {
19
- function: "Use the function form of 'use strict'.",
20
- global: "Use the global form of 'use strict'.",
21
- multiple: "Multiple 'use strict' directives.",
22
- never: "Strict mode is not permitted.",
23
- unnecessary: "Unnecessary 'use strict' directive.",
24
- module: "'use strict' is unnecessary inside of modules.",
25
- implied: "'use strict' is unnecessary when implied strict mode is enabled.",
26
- unnecessaryInClasses: "'use strict' is unnecessary inside of classes.",
27
- nonSimpleParameterList: "'use strict' directive inside a function with non-simple parameter list throws a syntax error since ES2016.",
28
- wrap: "Wrap {{name}} in a function with 'use strict' directive."
29
- };
30
-
31
18
  /**
32
19
  * Gets all of the Use Strict Directives in the Directive Prologue of a group of
33
20
  * statements.
@@ -95,7 +82,19 @@ module.exports = {
95
82
  }
96
83
  ],
97
84
 
98
- fixable: "code"
85
+ fixable: "code",
86
+ messages: {
87
+ function: "Use the function form of 'use strict'.",
88
+ global: "Use the global form of 'use strict'.",
89
+ multiple: "Multiple 'use strict' directives.",
90
+ never: "Strict mode is not permitted.",
91
+ unnecessary: "Unnecessary 'use strict' directive.",
92
+ module: "'use strict' is unnecessary inside of modules.",
93
+ implied: "'use strict' is unnecessary when implied strict mode is enabled.",
94
+ unnecessaryInClasses: "'use strict' is unnecessary inside of classes.",
95
+ nonSimpleParameterList: "'use strict' directive inside a function with non-simple parameter list throws a syntax error since ES2016.",
96
+ wrap: "Wrap {{name}} in a function with 'use strict' directive."
97
+ }
99
98
  },
100
99
 
101
100
  create(context) {
@@ -134,36 +133,36 @@ module.exports = {
134
133
  * @param {ASTNode[]} nodes Nodes.
135
134
  * @param {string} start Index to start from.
136
135
  * @param {string} end Index to end before.
137
- * @param {string} message Message to display.
136
+ * @param {string} messageId Message to display.
138
137
  * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
139
138
  * @returns {void}
140
139
  */
141
- function reportSlice(nodes, start, end, message, fix) {
140
+ function reportSlice(nodes, start, end, messageId, fix) {
142
141
  nodes.slice(start, end).forEach(node => {
143
- context.report({ node, message, fix: fix ? getFixFunction(node) : null });
142
+ context.report({ node, messageId, fix: fix ? getFixFunction(node) : null });
144
143
  });
145
144
  }
146
145
 
147
146
  /**
148
147
  * Report all nodes in an array with a given message.
149
148
  * @param {ASTNode[]} nodes Nodes.
150
- * @param {string} message Message to display.
149
+ * @param {string} messageId Message id to display.
151
150
  * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
152
151
  * @returns {void}
153
152
  */
154
- function reportAll(nodes, message, fix) {
155
- reportSlice(nodes, 0, nodes.length, message, fix);
153
+ function reportAll(nodes, messageId, fix) {
154
+ reportSlice(nodes, 0, nodes.length, messageId, fix);
156
155
  }
157
156
 
158
157
  /**
159
158
  * Report all nodes in an array, except the first, with a given message.
160
159
  * @param {ASTNode[]} nodes Nodes.
161
- * @param {string} message Message to display.
160
+ * @param {string} messageId Message id to display.
162
161
  * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
163
162
  * @returns {void}
164
163
  */
165
- function reportAllExceptFirst(nodes, message, fix) {
166
- reportSlice(nodes, 1, nodes.length, message, fix);
164
+ function reportAllExceptFirst(nodes, messageId, fix) {
165
+ reportSlice(nodes, 1, nodes.length, messageId, fix);
167
166
  }
168
167
 
169
168
  /**
@@ -181,21 +180,21 @@ module.exports = {
181
180
 
182
181
  if (isStrict) {
183
182
  if (!isSimpleParameterList(node.params)) {
184
- context.report({ node: useStrictDirectives[0], message: messages.nonSimpleParameterList });
183
+ context.report({ node: useStrictDirectives[0], messageId: "nonSimpleParameterList" });
185
184
  } else if (isParentStrict) {
186
- context.report({ node: useStrictDirectives[0], message: messages.unnecessary, fix: getFixFunction(useStrictDirectives[0]) });
185
+ context.report({ node: useStrictDirectives[0], messageId: "unnecessary", fix: getFixFunction(useStrictDirectives[0]) });
187
186
  } else if (isInClass) {
188
- context.report({ node: useStrictDirectives[0], message: messages.unnecessaryInClasses, fix: getFixFunction(useStrictDirectives[0]) });
187
+ context.report({ node: useStrictDirectives[0], messageId: "unnecessaryInClasses", fix: getFixFunction(useStrictDirectives[0]) });
189
188
  }
190
189
 
191
- reportAllExceptFirst(useStrictDirectives, messages.multiple, true);
190
+ reportAllExceptFirst(useStrictDirectives, "multiple", true);
192
191
  } else if (isParentGlobal) {
193
192
  if (isSimpleParameterList(node.params)) {
194
- context.report({ node, message: messages.function });
193
+ context.report({ node, messageId: "function" });
195
194
  } else {
196
195
  context.report({
197
196
  node,
198
- message: messages.wrap,
197
+ messageId: "wrap",
199
198
  data: { name: astUtils.getFunctionNameWithKind(node) }
200
199
  });
201
200
  }
@@ -228,10 +227,10 @@ module.exports = {
228
227
  enterFunctionInFunctionMode(node, useStrictDirectives);
229
228
  } else if (useStrictDirectives.length > 0) {
230
229
  if (isSimpleParameterList(node.params)) {
231
- reportAll(useStrictDirectives, messages[mode], shouldFix(mode));
230
+ reportAll(useStrictDirectives, mode, shouldFix(mode));
232
231
  } else {
233
- context.report({ node: useStrictDirectives[0], message: messages.nonSimpleParameterList });
234
- reportAllExceptFirst(useStrictDirectives, messages.multiple, true);
232
+ context.report({ node: useStrictDirectives[0], messageId: "nonSimpleParameterList" });
233
+ reportAllExceptFirst(useStrictDirectives, "multiple", true);
235
234
  }
236
235
  }
237
236
  }
@@ -246,11 +245,11 @@ module.exports = {
246
245
 
247
246
  if (mode === "global") {
248
247
  if (node.body.length > 0 && useStrictDirectives.length === 0) {
249
- context.report({ node, message: messages.global });
248
+ context.report({ node, messageId: "global" });
250
249
  }
251
- reportAllExceptFirst(useStrictDirectives, messages.multiple, true);
250
+ reportAllExceptFirst(useStrictDirectives, "multiple", true);
252
251
  } else {
253
- reportAll(useStrictDirectives, messages[mode], shouldFix(mode));
252
+ reportAll(useStrictDirectives, mode, shouldFix(mode));
254
253
  }
255
254
  },
256
255
  FunctionDeclaration: enterFunction,
@@ -30,14 +30,19 @@ module.exports = {
30
30
  {
31
31
  type: "object",
32
32
  properties: {
33
- before: { type: "boolean" },
34
- after: { type: "boolean" }
33
+ before: { type: "boolean", default: false },
34
+ after: { type: "boolean", default: true }
35
35
  },
36
36
  additionalProperties: false
37
37
  }
38
38
  ],
39
-
40
- fixable: "whitespace"
39
+ fixable: "whitespace",
40
+ messages: {
41
+ expectedBefore: "Expected space(s) before this colon.",
42
+ expectedAfter: "Expected space(s) after this colon.",
43
+ unexpectedBefore: "Unexpected space(s) before this colon.",
44
+ unexpectedAfter: "Unexpected space(s) after this colon."
45
+ }
41
46
  },
42
47
 
43
48
  create(context) {
@@ -118,8 +123,7 @@ module.exports = {
118
123
  context.report({
119
124
  node,
120
125
  loc: colonToken.loc,
121
- message: "{{verb}} space(s) before this colon.",
122
- data: { verb: beforeSpacing ? "Expected" : "Unexpected" },
126
+ messageId: beforeSpacing ? "expectedBefore" : "unexpectedBefore",
123
127
  fix: fixer => fix(fixer, beforeToken, colonToken, beforeSpacing)
124
128
  });
125
129
  }
@@ -127,8 +131,7 @@ module.exports = {
127
131
  context.report({
128
132
  node,
129
133
  loc: colonToken.loc,
130
- message: "{{verb}} space(s) after this colon.",
131
- data: { verb: afterSpacing ? "Expected" : "Unexpected" },
134
+ messageId: afterSpacing ? "expectedAfter" : "unexpectedAfter",
132
135
  fix: fixer => fix(fixer, colonToken, afterToken, afterSpacing)
133
136
  });
134
137
  }
@@ -26,8 +26,11 @@ module.exports = {
26
26
  recommended: false,
27
27
  url: "https://eslint.org/docs/rules/symbol-description"
28
28
  },
29
-
30
- schema: []
29
+ fixable: null,
30
+ schema: [],
31
+ messages: {
32
+ expected: "Expected Symbol to have a description."
33
+ }
31
34
  },
32
35
 
33
36
  create(context) {
@@ -43,7 +46,7 @@ module.exports = {
43
46
  if (node.arguments.length === 0) {
44
47
  context.report({
45
48
  node,
46
- message: "Expected Symbol to have a description."
49
+ messageId: "expected"
47
50
  });
48
51
  }
49
52
  }
@@ -37,13 +37,19 @@ module.exports = {
37
37
 
38
38
  schema: [
39
39
  { enum: ["always", "never"] }
40
- ]
40
+ ],
41
+ messages: {
42
+ expectedBefore: "Expected space(s) before '}'.",
43
+ expectedAfter: "Expected space(s) after '${'.",
44
+ unexpectedBefore: "Unexpected space(s) before '}'.",
45
+ unexpectedAfter: "Unexpected space(s) after '${'."
46
+ }
41
47
  },
42
48
 
43
49
  create(context) {
44
50
  const sourceCode = context.getSourceCode();
45
51
  const always = context.options[0] === "always";
46
- const prefix = always ? "Expected" : "Unexpected";
52
+ const prefix = always ? "expected" : "unexpected";
47
53
 
48
54
  /**
49
55
  * Checks spacing before `}` of a given token.
@@ -60,10 +66,7 @@ module.exports = {
60
66
  ) {
61
67
  context.report({
62
68
  loc: token.loc.start,
63
- message: "{{prefix}} space(s) before '}'.",
64
- data: {
65
- prefix
66
- },
69
+ messageId: `${prefix}Before`,
67
70
  fix(fixer) {
68
71
  if (always) {
69
72
  return fixer.insertTextBefore(token, " ");
@@ -95,10 +98,7 @@ module.exports = {
95
98
  line: token.loc.end.line,
96
99
  column: token.loc.end.column - 2
97
100
  },
98
- message: "{{prefix}} space(s) after '${'.",
99
- data: {
100
- prefix
101
- },
101
+ messageId: `${prefix}After`,
102
102
  fix(fixer) {
103
103
  if (always) {
104
104
  return fixer.insertTextAfter(token, " ");
@@ -24,7 +24,11 @@ module.exports = {
24
24
 
25
25
  schema: [
26
26
  { enum: ["always", "never"] }
27
- ]
27
+ ],
28
+ messages: {
29
+ unexpected: "Unexpected space between template tag and template literal.",
30
+ missing: "Missing space between template tag and template literal."
31
+ }
28
32
  },
29
33
 
30
34
  create(context) {
@@ -46,7 +50,7 @@ module.exports = {
46
50
  context.report({
47
51
  node,
48
52
  loc: tagToken.loc.start,
49
- message: "Unexpected space between template tag and template literal.",
53
+ messageId: "unexpected",
50
54
  fix(fixer) {
51
55
  const comments = sourceCode.getCommentsBefore(node.quasi);
52
56
 
@@ -65,7 +69,7 @@ module.exports = {
65
69
  context.report({
66
70
  node,
67
71
  loc: tagToken.loc.start,
68
- message: "Missing space between template tag and template literal.",
72
+ messageId: "missing",
69
73
  fix(fixer) {
70
74
  return fixer.insertTextAfter(tagToken, " ");
71
75
  }
@@ -25,7 +25,11 @@ module.exports = {
25
25
  {
26
26
  enum: ["always", "never"]
27
27
  }
28
- ]
28
+ ],
29
+ messages: {
30
+ expected: "Expected Unicode BOM (Byte Order Mark).",
31
+ unexpected: "Unexpected Unicode BOM (Byte Order Mark)."
32
+ }
29
33
  },
30
34
 
31
35
  create(context) {
@@ -46,7 +50,7 @@ module.exports = {
46
50
  context.report({
47
51
  node,
48
52
  loc: location,
49
- message: "Expected Unicode BOM (Byte Order Mark).",
53
+ messageId: "expected",
50
54
  fix(fixer) {
51
55
  return fixer.insertTextBeforeRange([0, 1], "\uFEFF");
52
56
  }
@@ -55,7 +59,7 @@ module.exports = {
55
59
  context.report({
56
60
  node,
57
61
  loc: location,
58
- message: "Unexpected Unicode BOM (Byte Order Mark).",
62
+ messageId: "unexpected",
59
63
  fix(fixer) {
60
64
  return fixer.removeRange([-1, 0]);
61
65
  }
@@ -20,7 +20,10 @@ module.exports = {
20
20
  url: "https://eslint.org/docs/rules/use-isnan"
21
21
  },
22
22
 
23
- schema: []
23
+ schema: [],
24
+ messages: {
25
+ useIsNaN: "Use the isNaN function to compare with NaN."
26
+ }
24
27
  },
25
28
 
26
29
  create(context) {
@@ -28,7 +31,7 @@ module.exports = {
28
31
  return {
29
32
  BinaryExpression(node) {
30
33
  if (/^(?:[<>]|[!=]=)=?$/.test(node.operator) && (node.left.name === "NaN" || node.right.name === "NaN")) {
31
- context.report({ node, message: "Use the isNaN function to compare with NaN." });
34
+ context.report({ node, messageId: "useIsNaN" });
32
35
  }
33
36
  }
34
37
  };