Skip to content

Commit 5a94cbf

Browse files
committed
chore: fix ESLint errors
1 parent be5af22 commit 5a94cbf

9 files changed

+52
-22
lines changed

lib/rules/arrow-parens.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ module.exports = {
3434
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/arrow-parens.md",
3535
},
3636
fixable: "code",
37+
messages: {
38+
expectedParentheses:
39+
"Expected to enclose this argument with parentheses.",
40+
unexpectedParentheses:
41+
"Unexpected parentheses enclosing this argument.",
42+
},
3743
schema: [],
3844
type: "suggestion",
3945
},
@@ -54,8 +60,7 @@ module.exports = {
5460
) {
5561
context.report({
5662
node,
57-
message:
58-
"Unexpected parentheses enclosing this argument.",
63+
messageId: "unexpectedParentheses",
5964
fix(fixer) {
6065
const id = node.params[0]
6166
const begin = first.range[0]
@@ -73,8 +78,7 @@ module.exports = {
7378
} else if (!isOpenParen(before) || !isSameLine(before, first)) {
7479
context.report({
7580
node,
76-
message:
77-
"Expected to enclose this argument with parentheses.",
81+
messageId: "expectedParentheses",
7882
fix(fixer) {
7983
const id = node.params[0]
8084

lib/rules/block-scoped-var.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ module.exports = {
200200
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/block-scoped-var.md",
201201
},
202202
fixable: null,
203+
messages: {
204+
alreadyDefined: '"{{name}}" is already defined.',
205+
definedInUpperScope:
206+
'"{{name}}" is already defined in the upper scope.',
207+
undefined: '"{{name}}" is not defined.',
208+
unused: '"{{name}}" is defined but never used.',
209+
},
203210
schema: [],
204211
type: "suggestion",
205212
},
@@ -244,7 +251,7 @@ module.exports = {
244251
if (scope == null) {
245252
context.report({
246253
node: reference.identifier,
247-
message: '"{{name}}" is not defined.',
254+
messageId: "undefined",
248255
data: { name: reference.identifier.name },
249256
})
250257
}
@@ -255,24 +262,23 @@ module.exports = {
255262
for (const identifier of scope.redeclarations) {
256263
context.report({
257264
node: identifier,
258-
message: '"{{name}}" is already defined.',
265+
messageId: "alreadyDefined",
259266
data: { name: identifier.name },
260267
})
261268
}
262269

263270
if (scope.shadowing) {
264271
context.report({
265272
node: scope.identifier,
266-
message:
267-
'"{{name}}" is already defined in the upper scope.',
273+
messageId: "definedInUpperScope",
268274
data: { name: scope.identifier.name },
269275
})
270276
}
271277

272278
if (hasReadRef && !scope.used) {
273279
context.report({
274280
node: scope.identifier,
275-
message: '"{{name}}" is defined but never used.',
281+
messageId: "unused",
276282
data: { name: scope.identifier.name },
277283
})
278284
}

lib/rules/no-instanceof-array.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ module.exports = {
1818
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-array.md",
1919
},
2020
fixable: "code",
21+
messages: {
22+
noInstanceofArray:
23+
"Unexpected 'instanceof' operator. Use 'Array.isArray' instead.",
24+
},
2125
schema: [],
2226
type: "problem",
2327
},
@@ -62,8 +66,7 @@ module.exports = {
6266
context.report({
6367
node,
6468
loc: node.loc,
65-
message:
66-
"Unexpected 'instanceof' operator. Use 'Array.isArray' instead.",
69+
messageId: "noInstanceofArray",
6770
fix: fixer =>
6871
fixer.replaceText(
6972
node,

lib/rules/no-instanceof-wrapper.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ module.exports = {
1818
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-wrapper.md",
1919
},
2020
fixable: "code",
21+
messages: {
22+
noInstanceofWrapper:
23+
"Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.",
24+
},
2125
schema: [],
2226
type: "problem",
2327
},
@@ -73,8 +77,7 @@ module.exports = {
7377
context.report({
7478
node,
7579
loc: node.loc,
76-
message:
77-
"Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.",
80+
messageId: "noInstanceofWrapper",
7881
data: { typeName },
7982
fix: fixer =>
8083
fixer.replaceText(

lib/rules/no-literal-call.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ module.exports = {
2525
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-literal-call.md",
2626
},
2727
fixable: null,
28+
messages: {
29+
noLiteralCall: "This is not a function.",
30+
},
2831
schema: [],
2932
type: "problem",
3033
},
@@ -41,7 +44,7 @@ module.exports = {
4144
if (pattern.test(callee.type)) {
4245
context.report({
4346
node: callee,
44-
message: "This is not a function.",
47+
messageId: "noLiteralCall",
4548
})
4649
}
4750
}

lib/rules/no-this-in-static.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ module.exports = {
1818
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-this-in-static.md",
1919
},
2020
fixable: null,
21+
messages: {
22+
noThisInStatic: "Unexpected '{{type}}'.",
23+
},
2124
schema: [],
2225
type: "suggestion",
2326
},
@@ -73,7 +76,7 @@ module.exports = {
7376
context.report({
7477
node,
7578
loc: node.loc,
76-
message: "Unexpected '{{type}}'.",
79+
messageId: "noThisInStatic",
7780
data: { type: sourceCode.getText(node) },
7881
})
7982
}

lib/rules/no-use-ignored-vars.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ module.exports = {
2424
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-use-ignored-vars.md",
2525
},
2626
fixable: null,
27+
messages: {
28+
noUseIgnoredVars:
29+
"Unexpected a use of '{{name}}'. This name is matched to ignored pattern.",
30+
},
2731
schema: [{ type: "string" }],
2832
type: "suggestion",
2933
},
@@ -65,8 +69,7 @@ module.exports = {
6569

6670
context.report({
6771
node: id,
68-
message:
69-
"Unexpected a use of '{{name}}'. This name is matched to ignored pattern.",
72+
messageId: "noUseIgnoredVars",
7073
data: id,
7174
})
7275
}

lib/rules/no-useless-rest-spread.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ module.exports = {
101101
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-useless-rest-spread.md",
102102
},
103103
fixable: "code",
104+
messages: {
105+
noUselessRestSpread: "Redundant {{type1}} {{type2}}.",
106+
},
104107
schema: [],
105108
type: "suggestion",
106109
},
@@ -139,7 +142,7 @@ module.exports = {
139142

140143
context.report({
141144
node,
142-
message: "Redundant {{type1}} {{type2}}.",
145+
messageId: "noUselessRestSpread",
143146
data: { type1, type2 },
144147
fix: defineFixer(sourceCode, node),
145148
})

lib/rules/prefer-for-of.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const assert = require("assert")
1616
//------------------------------------------------------------------------------
1717

1818
const SENTINEL_TYPE = /(?:Declaration|Statement)$/u
19-
const MESSAGE = "Expected for-of statement."
2019

2120
/**
2221
* Checks whether the given outer node contains the given inner node.
@@ -501,6 +500,9 @@ module.exports = {
501500
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/prefer-for-of.md",
502501
},
503502
fixable: "code",
503+
messages: {
504+
preferForOf: "Expected for-of statement.",
505+
},
504506
schema: [],
505507
type: "suggestion",
506508
},
@@ -547,7 +549,7 @@ module.exports = {
547549
const expressionStatementNode = funcInfo.node.parent.parent
548550
context.report({
549551
node: expressionStatementNode,
550-
message: MESSAGE,
552+
messageId: "preferForOf",
551553
fix: fixArrayForEach.bind(null, context, funcInfo),
552554
})
553555
}
@@ -609,14 +611,14 @@ module.exports = {
609611
) {
610612
context.report({
611613
node,
612-
message: MESSAGE,
614+
messageId: "preferForOf",
613615
fix: fixForStatement.bind(null, context, node),
614616
})
615617
}
616618
},
617619

618620
ForInStatement(node) {
619-
context.report({ node, message: MESSAGE })
621+
context.report({ node, messageId: "preferForOf" })
620622
},
621623
}
622624
},

0 commit comments

Comments
 (0)