Skip to content

Commit b08d8b6

Browse files
feat: update eslint-plugin-eslint-plugin + update configs (#23)
* feat: update `eslint-plugin-eslint-plugin` + update configs BREAKING CHANGE: `+eslint-plugin` config now has extra rules from `eslint-plugin-eslint-plugin` * chore: fix ESLint errors
1 parent 0bc3644 commit b08d8b6

11 files changed

+63
-23
lines changed

lib/configs/+eslint-plugin.js

+10
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,20 @@ module.exports = {
3636
"error",
3737
"@eslint-community/mysticatea/eslint-plugin/no-identical-tests":
3838
"error",
39+
"@eslint-community/mysticatea/eslint-plugin/no-missing-message-ids":
40+
"error",
3941
"@eslint-community/mysticatea/eslint-plugin/no-missing-placeholders":
4042
"error",
43+
"@eslint-community/mysticatea/eslint-plugin/no-only-tests":
44+
"error",
45+
"@eslint-community/mysticatea/eslint-plugin/no-unused-message-ids":
46+
"error",
4147
"@eslint-community/mysticatea/eslint-plugin/no-unused-placeholders":
4248
"error",
4349
"@eslint-community/mysticatea/eslint-plugin/no-useless-token-range":
4450
"error",
51+
"@eslint-community/mysticatea/eslint-plugin/prefer-message-ids":
52+
"error",
4553
"@eslint-community/mysticatea/eslint-plugin/prefer-object-rule":
4654
"error",
4755
"@eslint-community/mysticatea/eslint-plugin/prefer-output-null":
@@ -58,6 +66,8 @@ module.exports = {
5866
["error", { pattern: rulesDocumentUrl }],
5967
"@eslint-community/mysticatea/eslint-plugin/require-meta-fixable":
6068
"error",
69+
"@eslint-community/mysticatea/eslint-plugin/require-meta-has-suggestions":
70+
"error",
6171
"@eslint-community/mysticatea/eslint-plugin/require-meta-schema":
6272
"error",
6373
"@eslint-community/mysticatea/eslint-plugin/require-meta-type":

lib/rules/arrow-parens.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ module.exports = {
3333
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/arrow-parens.md",
3434
},
3535
fixable: "code",
36+
messages: {
37+
expectedParentheses:
38+
"Expected to enclose this argument with parentheses.",
39+
unexpectedParentheses:
40+
"Unexpected parentheses enclosing this argument.",
41+
},
3642
schema: [],
3743
type: "suggestion",
3844
},
@@ -53,8 +59,7 @@ module.exports = {
5359
) {
5460
context.report({
5561
node,
56-
message:
57-
"Unexpected parentheses enclosing this argument.",
62+
messageId: "unexpectedParentheses",
5863
fix(fixer) {
5964
const id = node.params[0]
6065
const begin = first.range[0]
@@ -72,8 +77,7 @@ module.exports = {
7277
} else if (!isOpenParen(before) || !isSameLine(before, first)) {
7378
context.report({
7479
node,
75-
message:
76-
"Expected to enclose this argument with parentheses.",
80+
messageId: "expectedParentheses",
7781
fix(fixer) {
7882
const id = node.params[0]
7983

lib/rules/block-scoped-var.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ module.exports = {
201201
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/block-scoped-var.md",
202202
},
203203
fixable: null,
204+
messages: {
205+
alreadyDefined: '"{{name}}" is already defined.',
206+
definedInUpperScope:
207+
'"{{name}}" is already defined in the upper scope.',
208+
undefined: '"{{name}}" is not defined.',
209+
unused: '"{{name}}" is defined but never used.',
210+
},
204211
schema: [],
205212
type: "suggestion",
206213
},
@@ -245,7 +252,7 @@ module.exports = {
245252
if (scope == null) {
246253
context.report({
247254
node: reference.identifier,
248-
message: '"{{name}}" is not defined.',
255+
messageId: "undefined",
249256
data: { name: reference.identifier.name },
250257
})
251258
}
@@ -256,24 +263,23 @@ module.exports = {
256263
for (const identifier of scope.redeclarations) {
257264
context.report({
258265
node: identifier,
259-
message: '"{{name}}" is already defined.',
266+
messageId: "alreadyDefined",
260267
data: { name: identifier.name },
261268
})
262269
}
263270

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

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

lib/rules/no-instanceof-array.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ module.exports = {
1717
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-array.md",
1818
},
1919
fixable: "code",
20+
messages: {
21+
noInstanceofArray:
22+
"Unexpected 'instanceof' operator. Use 'Array.isArray' instead.",
23+
},
2024
schema: [],
2125
type: "problem",
2226
},
@@ -61,8 +65,7 @@ module.exports = {
6165
context.report({
6266
node,
6367
loc: node.loc,
64-
message:
65-
"Unexpected 'instanceof' operator. Use 'Array.isArray' instead.",
68+
messageId: "noInstanceofArray",
6669
fix: (fixer) =>
6770
fixer.replaceText(
6871
node,

lib/rules/no-instanceof-wrapper.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ module.exports = {
1717
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-wrapper.md",
1818
},
1919
fixable: "code",
20+
messages: {
21+
noInstanceofWrapper:
22+
"Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.",
23+
},
2024
schema: [],
2125
type: "problem",
2226
},
@@ -72,8 +76,7 @@ module.exports = {
7276
context.report({
7377
node,
7478
loc: node.loc,
75-
message:
76-
"Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.",
79+
messageId: "noInstanceofWrapper",
7780
data: { typeName },
7881
fix: (fixer) =>
7982
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
url: "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
@@ -17,6 +17,9 @@ module.exports = {
1717
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-this-in-static.md",
1818
},
1919
fixable: null,
20+
messages: {
21+
noThisInStatic: "Unexpected '{{type}}'.",
22+
},
2023
schema: [],
2124
type: "suggestion",
2225
},
@@ -72,7 +75,7 @@ module.exports = {
7275
context.report({
7376
node,
7477
loc: node.loc,
75-
message: "Unexpected '{{type}}'.",
78+
messageId: "noThisInStatic",
7679
data: { type: sourceCode.getText(node) },
7780
})
7881
}

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

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

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

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ module.exports = {
101101
url: "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
url: "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
},

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@typescript-eslint/eslint-plugin": "^5.40.0",
1717
"@typescript-eslint/parser": "^5.40.0",
1818
"eslint-plugin-eslint-comments": "^3.2.0",
19-
"eslint-plugin-eslint-plugin": "^2.3.0",
19+
"eslint-plugin-eslint-plugin": "^4.4.1",
2020
"eslint-plugin-node": "^10.0.0",
2121
"eslint-plugin-prettier": "^3.4.1",
2222
"eslint-plugin-vue": "^6.2.2",

0 commit comments

Comments
 (0)