eslint 4.16.0 → 4.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/conf/environments.js +3 -1
  3. package/conf/eslint-recommended.js +0 -0
  4. package/lib/linter.js +368 -366
  5. package/lib/rules/accessor-pairs.js +7 -3
  6. package/lib/rules/array-bracket-newline.js +11 -5
  7. package/lib/rules/array-bracket-spacing.js +11 -5
  8. package/lib/rules/array-callback-return.js +11 -5
  9. package/lib/rules/array-element-newline.js +8 -3
  10. package/lib/rules/arrow-body-style.js +16 -8
  11. package/lib/rules/arrow-parens.js +13 -9
  12. package/lib/rules/arrow-spacing.js +13 -5
  13. package/lib/rules/block-scoped-var.js +6 -2
  14. package/lib/rules/block-spacing.js +13 -6
  15. package/lib/rules/brace-style.js +16 -14
  16. package/lib/rules/callback-return.js +6 -2
  17. package/lib/rules/camelcase.js +6 -2
  18. package/lib/rules/capitalized-comments.js +11 -8
  19. package/lib/rules/class-methods-use-this.js +7 -3
  20. package/lib/rules/comma-dangle.js +7 -4
  21. package/lib/rules/comma-spacing.js +13 -10
  22. package/lib/rules/comma-style.js +9 -4
  23. package/lib/rules/complexity.js +6 -2
  24. package/lib/rules/computed-property-spacing.js +13 -5
  25. package/lib/rules/consistent-return.js +12 -7
  26. package/lib/rules/consistent-this.js +9 -4
  27. package/lib/rules/constructor-super.js +17 -8
  28. package/lib/rules/curly.js +59 -80
  29. package/lib/rules/default-case.js +6 -2
  30. package/lib/rules/dot-location.js +8 -3
  31. package/lib/rules/dot-notation.js +10 -5
  32. package/lib/rules/eol-last.js +7 -3
  33. package/lib/rules/eqeqeq.js +6 -2
  34. package/lib/rules/indent.js +0 -1
  35. package/lib/rules/key-spacing.js +3 -2
  36. package/lib/rules/keyword-spacing.js +6 -1
  37. package/lib/rules/max-len.js +2 -1
  38. package/lib/rules/no-alert.js +19 -18
  39. package/lib/rules/no-array-constructor.js +6 -2
  40. package/lib/rules/no-await-in-loop.js +75 -57
  41. package/lib/rules/no-bitwise.js +6 -2
  42. package/lib/rules/no-buffer-constructor.js +6 -3
  43. package/lib/rules/no-caller.js +6 -2
  44. package/lib/rules/no-case-declarations.js +6 -2
  45. package/lib/rules/no-catch-shadow.js +6 -2
  46. package/lib/rules/no-class-assign.js +6 -2
  47. package/lib/rules/no-compare-neg-zero.js +5 -2
  48. package/lib/rules/no-cond-assign.js +10 -4
  49. package/lib/rules/no-confusing-arrow.js +6 -2
  50. package/lib/rules/no-console.js +6 -2
  51. package/lib/rules/no-const-assign.js +6 -2
  52. package/lib/rules/no-constant-condition.js +6 -3
  53. package/lib/rules/no-continue.js +6 -2
  54. package/lib/rules/no-control-regex.js +7 -3
  55. package/lib/rules/no-debugger.js +5 -2
  56. package/lib/rules/no-delete-var.js +6 -2
  57. package/lib/rules/no-div-regex.js +6 -2
  58. package/lib/rules/no-dupe-args.js +6 -2
  59. package/lib/rules/no-dupe-class-members.js +6 -2
  60. package/lib/rules/no-dupe-keys.js +6 -2
  61. package/lib/rules/no-duplicate-case.js +6 -2
  62. package/lib/rules/no-else-return.js +7 -2
  63. package/lib/rules/no-empty-character-class.js +6 -2
  64. package/lib/rules/no-empty-function.js +6 -2
  65. package/lib/rules/no-empty-pattern.js +7 -3
  66. package/lib/rules/no-empty.js +7 -3
  67. package/lib/rules/no-eq-null.js +6 -2
  68. package/lib/rules/no-eval.js +6 -2
  69. package/lib/rules/no-ex-assign.js +6 -2
  70. package/lib/rules/no-extend-native.js +6 -2
  71. package/lib/rules/no-extra-bind.js +6 -2
  72. package/lib/rules/no-extra-boolean-cast.js +8 -3
  73. package/lib/rules/no-extra-label.js +6 -2
  74. package/lib/rules/no-extra-parens.js +5 -1
  75. package/lib/rules/no-extra-semi.js +6 -2
  76. package/lib/rules/no-self-assign.js +3 -1
  77. package/lib/rules/no-unused-vars.js +1 -1
  78. package/lib/rules/object-curly-newline.js +67 -19
  79. package/lib/rules/object-shorthand.js +9 -7
  80. package/lib/rules/padding-line-between-statements.js +6 -0
  81. package/lib/rules/require-await.js +5 -0
  82. package/lib/rules/rest-spread-spacing.js +6 -0
  83. package/lib/rules/space-unary-ops.js +1 -10
  84. package/lib/rules/template-tag-spacing.js +0 -0
  85. package/lib/util/glob-util.js +17 -4
  86. package/lib/util/interpolate.js +5 -1
  87. package/lib/util/npm-util.js +1 -1
  88. package/package.json +2 -2
  89. package/conf/default-config-options.js +0 -29
@@ -89,7 +89,11 @@ module.exports = {
89
89
  }
90
90
  },
91
91
  additionalProperties: false
92
- }]
92
+ }],
93
+ messages: {
94
+ getter: "Getter is not present.",
95
+ setter: "Setter is not present."
96
+ }
93
97
  },
94
98
  create(context) {
95
99
  const config = context.options[0] || {};
@@ -140,9 +144,9 @@ module.exports = {
140
144
  }
141
145
 
142
146
  if (checkSetWithoutGet && isSetPresent && !isGetPresent) {
143
- context.report({ node, message: "Getter is not present." });
147
+ context.report({ node, messageId: "getter" });
144
148
  } else if (checkGetWithoutSet && isGetPresent && !isSetPresent) {
145
- context.report({ node, message: "Setter is not present." });
149
+ context.report({ node, messageId: "setter" });
146
150
  }
147
151
  }
148
152
 
@@ -41,7 +41,13 @@ module.exports = {
41
41
  }
42
42
  ]
43
43
  }
44
- ]
44
+ ],
45
+ messages: {
46
+ unexpectedOpeningLinebreak: "There should be no linebreak after '['.",
47
+ unexpectedClosingLinebreak: "There should be no linebreak before ']'.",
48
+ missingOpeningLinebreak: "A linebreak is required after '['.",
49
+ missingClosingLinebreak: "A linebreak is required before ']'."
50
+ }
45
51
  },
46
52
 
47
53
  create(context) {
@@ -106,7 +112,7 @@ module.exports = {
106
112
  context.report({
107
113
  node,
108
114
  loc: token.loc,
109
- message: "There should be no linebreak after '['.",
115
+ messageId: "unexpectedOpeningLinebreak",
110
116
  fix(fixer) {
111
117
  const nextToken = sourceCode.getTokenAfter(token, { includeComments: true });
112
118
 
@@ -129,7 +135,7 @@ module.exports = {
129
135
  context.report({
130
136
  node,
131
137
  loc: token.loc,
132
- message: "There should be no linebreak before ']'.",
138
+ messageId: "unexpectedClosingLinebreak",
133
139
  fix(fixer) {
134
140
  const previousToken = sourceCode.getTokenBefore(token, { includeComments: true });
135
141
 
@@ -152,7 +158,7 @@ module.exports = {
152
158
  context.report({
153
159
  node,
154
160
  loc: token.loc,
155
- message: "A linebreak is required after '['.",
161
+ messageId: "missingOpeningLinebreak",
156
162
  fix(fixer) {
157
163
  return fixer.insertTextAfter(token, "\n");
158
164
  }
@@ -169,7 +175,7 @@ module.exports = {
169
175
  context.report({
170
176
  node,
171
177
  loc: token.loc,
172
- message: "A linebreak is required before ']'.",
178
+ messageId: "missingClosingLinebreak",
173
179
  fix(fixer) {
174
180
  return fixer.insertTextBefore(token, "\n");
175
181
  }
@@ -38,7 +38,13 @@ module.exports = {
38
38
  },
39
39
  additionalProperties: false
40
40
  }
41
- ]
41
+ ],
42
+ messages: {
43
+ unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
44
+ unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
45
+ missingSpaceAfter: "A space is required after '{{tokenValue}}'.",
46
+ missingSpaceBefore: "A space is required before '{{tokenValue}}'."
47
+ }
42
48
  },
43
49
  create(context) {
44
50
  const spaced = context.options[0] === "always",
@@ -76,7 +82,7 @@ module.exports = {
76
82
  context.report({
77
83
  node,
78
84
  loc: token.loc.start,
79
- message: "There should be no space after '{{tokenValue}}'.",
85
+ messageId: "unexpectedSpaceAfter",
80
86
  data: {
81
87
  tokenValue: token.value
82
88
  },
@@ -98,7 +104,7 @@ module.exports = {
98
104
  context.report({
99
105
  node,
100
106
  loc: token.loc.start,
101
- message: "There should be no space before '{{tokenValue}}'.",
107
+ messageId: "unexpectedSpaceBefore",
102
108
  data: {
103
109
  tokenValue: token.value
104
110
  },
@@ -120,7 +126,7 @@ module.exports = {
120
126
  context.report({
121
127
  node,
122
128
  loc: token.loc.start,
123
- message: "A space is required after '{{tokenValue}}'.",
129
+ messageId: "missingSpaceAfter",
124
130
  data: {
125
131
  tokenValue: token.value
126
132
  },
@@ -140,7 +146,7 @@ module.exports = {
140
146
  context.report({
141
147
  node,
142
148
  loc: token.loc.start,
143
- message: "A space is required before '{{tokenValue}}'.",
149
+ messageId: "missingSpaceBefore",
144
150
  data: {
145
151
  tokenValue: token.value
146
152
  },
@@ -156,7 +156,13 @@ module.exports = {
156
156
  },
157
157
  additionalProperties: false
158
158
  }
159
- ]
159
+ ],
160
+
161
+ messages: {
162
+ expectedAtEnd: "Expected to return a value at the end of {{name}}.",
163
+ expectedInside: "Expected to return a value in {{name}}.",
164
+ expectedReturnValue: "{{name}} expected a return value."
165
+ }
160
166
  },
161
167
 
162
168
  create(context) {
@@ -188,9 +194,9 @@ module.exports = {
188
194
  context.report({
189
195
  node,
190
196
  loc: getLocation(node, context.getSourceCode()).loc.start,
191
- message: funcInfo.hasReturn
192
- ? "Expected to return a value at the end of {{name}}."
193
- : "Expected to return a value in {{name}}.",
197
+ messageId: funcInfo.hasReturn
198
+ ? "expectedAtEnd"
199
+ : "expectedInside",
194
200
  data: {
195
201
  name: astUtils.getFunctionNameWithKind(funcInfo.node)
196
202
  }
@@ -230,7 +236,7 @@ module.exports = {
230
236
  if (!options.allowImplicit && !node.argument) {
231
237
  context.report({
232
238
  node,
233
- message: "{{name}} expected a return value.",
239
+ messageId: "expectedReturnValue",
234
240
  data: {
235
241
  name: lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node))
236
242
  }
@@ -41,7 +41,12 @@ module.exports = {
41
41
  }
42
42
  ]
43
43
  }
44
- ]
44
+ ],
45
+
46
+ messages: {
47
+ unexpectedLineBreak: "There should be no linebreak here.",
48
+ missingLineBreak: "There should be a linebreak after this element."
49
+ }
45
50
  },
46
51
 
47
52
  create(context) {
@@ -100,7 +105,7 @@ module.exports = {
100
105
  start: tokenBefore.loc.end,
101
106
  end: token.loc.start
102
107
  },
103
- message: "There should be no linebreak here.",
108
+ messageId: "unexpectedLineBreak",
104
109
  fix(fixer) {
105
110
  if (astUtils.isCommentToken(tokenBefore)) {
106
111
  return null;
@@ -149,7 +154,7 @@ module.exports = {
149
154
  start: tokenBefore.loc.end,
150
155
  end: token.loc.start
151
156
  },
152
- message: "There should be a linebreak after this element.",
157
+ messageId: "missingLineBreak",
153
158
  fix(fixer) {
154
159
  return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n");
155
160
  }
@@ -55,7 +55,15 @@ module.exports = {
55
55
  ]
56
56
  },
57
57
 
58
- fixable: "code"
58
+ fixable: "code",
59
+
60
+ messages: {
61
+ unexpectedOtherBlock: "Unexpected block statement surrounding arrow body.",
62
+ unexpectedEmptyBlock: "Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.",
63
+ unexpectedObjectBlock: "Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.",
64
+ unexpectedSingleBlock: "Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.",
65
+ expectedBlock: "Expected block statement surrounding arrow body."
66
+ }
59
67
  },
60
68
 
61
69
  create(context) {
@@ -110,22 +118,22 @@ module.exports = {
110
118
  }
111
119
 
112
120
  if (never || asNeeded && blockBody[0].type === "ReturnStatement") {
113
- let message;
121
+ let messageId;
114
122
 
115
123
  if (blockBody.length === 0) {
116
- message = "Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.";
124
+ messageId = "unexpectedEmptyBlock";
117
125
  } else if (blockBody.length > 1) {
118
- message = "Unexpected block statement surrounding arrow body.";
126
+ messageId = "unexpectedOtherBlock";
119
127
  } else if (astUtils.isOpeningBraceToken(sourceCode.getFirstToken(blockBody[0], { skip: 1 }))) {
120
- message = "Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.";
128
+ messageId = "unexpectedObjectBlock";
121
129
  } else {
122
- message = "Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.";
130
+ messageId = "unexpectedSingleBlock";
123
131
  }
124
132
 
125
133
  context.report({
126
134
  node,
127
135
  loc: arrowBody.loc.start,
128
- message,
136
+ messageId,
129
137
  fix(fixer) {
130
138
  const fixes = [];
131
139
 
@@ -190,7 +198,7 @@ module.exports = {
190
198
  context.report({
191
199
  node,
192
200
  loc: arrowBody.loc.start,
193
- message: "Expected block statement surrounding arrow body.",
201
+ messageId: "expectedBlock",
194
202
  fix(fixer) {
195
203
  const fixes = [];
196
204
  const arrowToken = sourceCode.getTokenBefore(arrowBody, astUtils.isArrowToken);
@@ -38,15 +38,19 @@ module.exports = {
38
38
  },
39
39
  additionalProperties: false
40
40
  }
41
- ]
41
+ ],
42
+
43
+ messages: {
44
+ unexpectedParens: "Unexpected parentheses around single function argument.",
45
+ expectedParens: "Expected parentheses around arrow function argument.",
46
+
47
+ unexpectedParensInline: "Unexpected parentheses around single function argument having a body with no curly braces.",
48
+ expectedParensBlock: "Expected parentheses around arrow function argument having a body with curly braces."
49
+ }
42
50
  },
43
51
 
44
52
  create(context) {
45
- const message = "Expected parentheses around arrow function argument.";
46
- const asNeededMessage = "Unexpected parentheses around single function argument.";
47
53
  const asNeeded = context.options[0] === "as-needed";
48
- const requireForBlockBodyMessage = "Unexpected parentheses around single function argument having a body with no curly braces";
49
- const requireForBlockBodyNoParensMessage = "Expected parentheses around arrow function argument having a body with curly braces.";
50
54
  const requireForBlockBody = asNeeded && context.options[1] && context.options[1].requireForBlockBody === true;
51
55
 
52
56
  const sourceCode = context.getSourceCode();
@@ -94,7 +98,7 @@ module.exports = {
94
98
  if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
95
99
  context.report({
96
100
  node,
97
- message: requireForBlockBodyMessage,
101
+ messageId: "unexpectedParensInline",
98
102
  fix: fixParamsWithParenthesis
99
103
  });
100
104
  }
@@ -108,7 +112,7 @@ module.exports = {
108
112
  if (!astUtils.isOpeningParenToken(firstTokenOfParam)) {
109
113
  context.report({
110
114
  node,
111
- message: requireForBlockBodyNoParensMessage,
115
+ messageId: "expectedParensBlock",
112
116
  fix(fixer) {
113
117
  return fixer.replaceText(firstTokenOfParam, `(${firstTokenOfParam.value})`);
114
118
  }
@@ -127,7 +131,7 @@ module.exports = {
127
131
  if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
128
132
  context.report({
129
133
  node,
130
- message: asNeededMessage,
134
+ messageId: "unexpectedParens",
131
135
  fix: fixParamsWithParenthesis
132
136
  });
133
137
  }
@@ -141,7 +145,7 @@ module.exports = {
141
145
  if (after.value !== ")") {
142
146
  context.report({
143
147
  node,
144
- message,
148
+ messageId: "expectedParens",
145
149
  fix(fixer) {
146
150
  return fixer.replaceText(firstTokenOfParam, `(${firstTokenOfParam.value})`);
147
151
  }
@@ -38,7 +38,15 @@ module.exports = {
38
38
  },
39
39
  additionalProperties: false
40
40
  }
41
- ]
41
+ ],
42
+
43
+ messages: {
44
+ expectedBefore: "Missing space before =>.",
45
+ unexpectedBefore: "Unexpected space before =>.",
46
+
47
+ expectedAfter: "Missing space after =>.",
48
+ unexpectedAfter: "Unexpected space after =>."
49
+ }
42
50
  },
43
51
 
44
52
  create(context) {
@@ -96,7 +104,7 @@ module.exports = {
96
104
  if (countSpace.before === 0) {
97
105
  context.report({
98
106
  node: tokens.before,
99
- message: "Missing space before =>.",
107
+ messageId: "expectedBefore",
100
108
  fix(fixer) {
101
109
  return fixer.insertTextBefore(tokens.arrow, " ");
102
110
  }
@@ -108,7 +116,7 @@ module.exports = {
108
116
  if (countSpace.before > 0) {
109
117
  context.report({
110
118
  node: tokens.before,
111
- message: "Unexpected space before =>.",
119
+ messageId: "unexpectedBefore",
112
120
  fix(fixer) {
113
121
  return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]);
114
122
  }
@@ -122,7 +130,7 @@ module.exports = {
122
130
  if (countSpace.after === 0) {
123
131
  context.report({
124
132
  node: tokens.after,
125
- message: "Missing space after =>.",
133
+ messageId: "expectedAfter",
126
134
  fix(fixer) {
127
135
  return fixer.insertTextAfter(tokens.arrow, " ");
128
136
  }
@@ -134,7 +142,7 @@ module.exports = {
134
142
  if (countSpace.after > 0) {
135
143
  context.report({
136
144
  node: tokens.after,
137
- message: "Unexpected space after =>.",
145
+ messageId: "unexpectedAfter",
138
146
  fix(fixer) {
139
147
  return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]);
140
148
  }
@@ -17,7 +17,11 @@ module.exports = {
17
17
  url: "https://eslint.org/docs/rules/block-scoped-var"
18
18
  },
19
19
 
20
- schema: []
20
+ schema: [],
21
+
22
+ messages: {
23
+ outOfScope: "'{{name}}' used outside of binding context."
24
+ }
21
25
  },
22
26
 
23
27
  create(context) {
@@ -48,7 +52,7 @@ module.exports = {
48
52
  function report(reference) {
49
53
  const identifier = reference.identifier;
50
54
 
51
- context.report({ node: identifier, message: "'{{name}}' used outside of binding context.", data: { name: identifier.name } });
55
+ context.report({ node: identifier, messageId: "outOfScope", data: { name: identifier.name } });
52
56
  }
53
57
 
54
58
  /**
@@ -24,12 +24,17 @@ module.exports = {
24
24
 
25
25
  schema: [
26
26
  { enum: ["always", "never"] }
27
- ]
27
+ ],
28
+
29
+ messages: {
30
+ missing: "Requires a space {{location}} '{{token}}'",
31
+ extra: "Unexpected space(s) {{location}} '{{token}}'"
32
+ }
28
33
  },
29
34
 
30
35
  create(context) {
31
36
  const always = (context.options[0] !== "never"),
32
- message = always ? "Requires a space" : "Unexpected space(s)",
37
+ messageId = always ? "missing" : "extra",
33
38
  sourceCode = context.getSourceCode();
34
39
 
35
40
  /**
@@ -98,9 +103,10 @@ module.exports = {
98
103
  context.report({
99
104
  node,
100
105
  loc: openBrace.loc.start,
101
- message: "{{message}} after '{'.",
106
+ messageId,
102
107
  data: {
103
- message
108
+ location: "after",
109
+ token: openBrace.value
104
110
  },
105
111
  fix(fixer) {
106
112
  if (always) {
@@ -115,9 +121,10 @@ module.exports = {
115
121
  context.report({
116
122
  node,
117
123
  loc: closeBrace.loc.start,
118
- message: "{{message}} before '}'.",
124
+ messageId,
119
125
  data: {
120
- message
126
+ location: "before",
127
+ token: closeBrace.value
121
128
  },
122
129
  fix(fixer) {
123
130
  if (always) {
@@ -35,7 +35,16 @@ module.exports = {
35
35
  }
36
36
  ],
37
37
 
38
- fixable: "whitespace"
38
+ fixable: "whitespace",
39
+
40
+ messages: {
41
+ nextLineOpen: "Opening curly brace does not appear on the same line as controlling statement.",
42
+ sameLineOpen: "Opening curly brace appears on the same line as controlling statement.",
43
+ blockSameLine: "Statement inside of curly braces should be on next line.",
44
+ nextLineClose: "Closing curly brace does not appear on the same line as the subsequent block.",
45
+ singleLineClose: "Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.",
46
+ sameLineClose: "Closing curly brace appears on the same line as the subsequent block."
47
+ }
39
48
  },
40
49
 
41
50
  create(context) {
@@ -43,13 +52,6 @@ module.exports = {
43
52
  params = context.options[1] || {},
44
53
  sourceCode = context.getSourceCode();
45
54
 
46
- const OPEN_MESSAGE = "Opening curly brace does not appear on the same line as controlling statement.",
47
- OPEN_MESSAGE_ALLMAN = "Opening curly brace appears on the same line as controlling statement.",
48
- BODY_MESSAGE = "Statement inside of curly braces should be on next line.",
49
- CLOSE_MESSAGE = "Closing curly brace does not appear on the same line as the subsequent block.",
50
- CLOSE_MESSAGE_SINGLE = "Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.",
51
- CLOSE_MESSAGE_STROUSTRUP_ALLMAN = "Closing curly brace appears on the same line as the subsequent block.";
52
-
53
55
  //--------------------------------------------------------------------------
54
56
  // Helpers
55
57
  //--------------------------------------------------------------------------
@@ -86,7 +88,7 @@ module.exports = {
86
88
  if (style !== "allman" && !astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly)) {
87
89
  context.report({
88
90
  node: openingCurly,
89
- message: OPEN_MESSAGE,
91
+ messageId: "nextLineOpen",
90
92
  fix: removeNewlineBetween(tokenBeforeOpeningCurly, openingCurly)
91
93
  });
92
94
  }
@@ -94,7 +96,7 @@ module.exports = {
94
96
  if (style === "allman" && astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly) && !singleLineException) {
95
97
  context.report({
96
98
  node: openingCurly,
97
- message: OPEN_MESSAGE_ALLMAN,
99
+ messageId: "sameLineOpen",
98
100
  fix: fixer => fixer.insertTextBefore(openingCurly, "\n")
99
101
  });
100
102
  }
@@ -102,7 +104,7 @@ module.exports = {
102
104
  if (astUtils.isTokenOnSameLine(openingCurly, tokenAfterOpeningCurly) && tokenAfterOpeningCurly !== closingCurly && !singleLineException) {
103
105
  context.report({
104
106
  node: openingCurly,
105
- message: BODY_MESSAGE,
107
+ messageId: "blockSameLine",
106
108
  fix: fixer => fixer.insertTextAfter(openingCurly, "\n")
107
109
  });
108
110
  }
@@ -110,7 +112,7 @@ module.exports = {
110
112
  if (tokenBeforeClosingCurly !== openingCurly && !singleLineException && astUtils.isTokenOnSameLine(tokenBeforeClosingCurly, closingCurly)) {
111
113
  context.report({
112
114
  node: closingCurly,
113
- message: CLOSE_MESSAGE_SINGLE,
115
+ messageId: "singleLineClose",
114
116
  fix: fixer => fixer.insertTextBefore(closingCurly, "\n")
115
117
  });
116
118
  }
@@ -127,7 +129,7 @@ module.exports = {
127
129
  if (style === "1tbs" && !astUtils.isTokenOnSameLine(curlyToken, keywordToken)) {
128
130
  context.report({
129
131
  node: curlyToken,
130
- message: CLOSE_MESSAGE,
132
+ messageId: "nextLineClose",
131
133
  fix: removeNewlineBetween(curlyToken, keywordToken)
132
134
  });
133
135
  }
@@ -135,7 +137,7 @@ module.exports = {
135
137
  if (style !== "1tbs" && astUtils.isTokenOnSameLine(curlyToken, keywordToken)) {
136
138
  context.report({
137
139
  node: curlyToken,
138
- message: CLOSE_MESSAGE_STROUSTRUP_ALLMAN,
140
+ messageId: "sameLineClose",
139
141
  fix: fixer => fixer.insertTextAfter(curlyToken, "\n")
140
142
  });
141
143
  }
@@ -20,7 +20,11 @@ module.exports = {
20
20
  schema: [{
21
21
  type: "array",
22
22
  items: { type: "string" }
23
- }]
23
+ }],
24
+
25
+ messages: {
26
+ missingReturn: "Expected return with your callback function."
27
+ }
24
28
  },
25
29
 
26
30
  create(context) {
@@ -166,7 +170,7 @@ module.exports = {
166
170
 
167
171
  // as long as you're the child of a function at this point you should be asked to return
168
172
  if (findClosestParentOfType(node, ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"])) {
169
- context.report({ node, message: "Expected return with your callback function." });
173
+ context.report({ node, messageId: "missingReturn" });
170
174
  }
171
175
 
172
176
  }
@@ -28,7 +28,11 @@ module.exports = {
28
28
  },
29
29
  additionalProperties: false
30
30
  }
31
- ]
31
+ ],
32
+
33
+ messages: {
34
+ notCamelCase: "Identifier '{{name}}' is not in camel case."
35
+ }
32
36
  },
33
37
 
34
38
  create(context) {
@@ -62,7 +66,7 @@ module.exports = {
62
66
  function report(node) {
63
67
  if (reported.indexOf(node) < 0) {
64
68
  reported.push(node);
65
- context.report({ node, message: "Identifier '{{name}}' is not in camel case.", data: { name: node.name } });
69
+ context.report({ node, messageId: "notCamelCase", data: { name: node.name } });
66
70
  }
67
71
  }
68
72
 
@@ -15,9 +15,7 @@ const astUtils = require("../ast-utils");
15
15
  // Helpers
16
16
  //------------------------------------------------------------------------------
17
17
 
18
- const ALWAYS_MESSAGE = "Comments should not begin with a lowercase character",
19
- NEVER_MESSAGE = "Comments should not begin with an uppercase character",
20
- DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN,
18
+ const DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN,
21
19
  WHITESPACE = /\s/g,
22
20
  MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/, // TODO: Combine w/ max-len pattern?
23
21
  DEFAULTS = {
@@ -132,7 +130,12 @@ module.exports = {
132
130
  }
133
131
  ]
134
132
  }
135
- ]
133
+ ],
134
+
135
+ messages: {
136
+ unexpectedLowercaseComment: "Comments should not begin with a lowercase character",
137
+ unexpectedUppercaseComment: "Comments should not begin with an uppercase character"
138
+ }
136
139
  },
137
140
 
138
141
  create(context) {
@@ -267,14 +270,14 @@ module.exports = {
267
270
  commentValid = isCommentValid(comment, options);
268
271
 
269
272
  if (!commentValid) {
270
- const message = capitalize === "always"
271
- ? ALWAYS_MESSAGE
272
- : NEVER_MESSAGE;
273
+ const messageId = capitalize === "always"
274
+ ? "unexpectedLowercaseComment"
275
+ : "unexpectedUppercaseComment";
273
276
 
274
277
  context.report({
275
278
  node: null, // Intentionally using loc instead
276
279
  loc: comment.loc,
277
- message,
280
+ messageId,
278
281
  fix(fixer) {
279
282
  const match = comment.value.match(LETTER_PATTERN);
280
283
 
@@ -28,7 +28,11 @@ module.exports = {
28
28
  }
29
29
  },
30
30
  additionalProperties: false
31
- }]
31
+ }],
32
+
33
+ messages: {
34
+ missingThis: "Expected 'this' to be used by class method '{{name}}'."
35
+ }
32
36
  },
33
37
  create(context) {
34
38
  const config = context.options[0] ? Object.assign({}, context.options[0]) : {};
@@ -80,9 +84,9 @@ module.exports = {
80
84
  if (isIncludedInstanceMethod(node.parent) && !methodUsesThis) {
81
85
  context.report({
82
86
  node,
83
- message: "Expected 'this' to be used by class method '{{classMethod}}'.",
87
+ messageId: "missingThis",
84
88
  data: {
85
- classMethod: node.parent.key.name
89
+ name: node.parent.key.name
86
90
  }
87
91
  });
88
92
  }