diff --git a/lib/configs/+eslint-plugin.js b/lib/configs/+eslint-plugin.js index ff89f7b..888468d 100644 --- a/lib/configs/+eslint-plugin.js +++ b/lib/configs/+eslint-plugin.js @@ -36,12 +36,20 @@ module.exports = { "error", "@eslint-community/mysticatea/eslint-plugin/no-identical-tests": "error", + "@eslint-community/mysticatea/eslint-plugin/no-missing-message-ids": + "error", "@eslint-community/mysticatea/eslint-plugin/no-missing-placeholders": "error", + "@eslint-community/mysticatea/eslint-plugin/no-only-tests": + "error", + "@eslint-community/mysticatea/eslint-plugin/no-unused-message-ids": + "error", "@eslint-community/mysticatea/eslint-plugin/no-unused-placeholders": "error", "@eslint-community/mysticatea/eslint-plugin/no-useless-token-range": "error", + "@eslint-community/mysticatea/eslint-plugin/prefer-message-ids": + "error", "@eslint-community/mysticatea/eslint-plugin/prefer-object-rule": "error", "@eslint-community/mysticatea/eslint-plugin/prefer-output-null": @@ -58,6 +66,8 @@ module.exports = { ["error", { pattern: rulesDocumentUrl }], "@eslint-community/mysticatea/eslint-plugin/require-meta-fixable": "error", + "@eslint-community/mysticatea/eslint-plugin/require-meta-has-suggestions": + "error", "@eslint-community/mysticatea/eslint-plugin/require-meta-schema": "error", "@eslint-community/mysticatea/eslint-plugin/require-meta-type": diff --git a/lib/rules/arrow-parens.js b/lib/rules/arrow-parens.js index e57abc4..9a18682 100644 --- a/lib/rules/arrow-parens.js +++ b/lib/rules/arrow-parens.js @@ -33,6 +33,12 @@ module.exports = { url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/arrow-parens.md", }, fixable: "code", + messages: { + expectedParentheses: + "Expected to enclose this argument with parentheses.", + unexpectedParentheses: + "Unexpected parentheses enclosing this argument.", + }, schema: [], type: "suggestion", }, @@ -53,8 +59,7 @@ module.exports = { ) { context.report({ node, - message: - "Unexpected parentheses enclosing this argument.", + messageId: "unexpectedParentheses", fix(fixer) { const id = node.params[0] const begin = first.range[0] @@ -72,8 +77,7 @@ module.exports = { } else if (!isOpenParen(before) || !isSameLine(before, first)) { context.report({ node, - message: - "Expected to enclose this argument with parentheses.", + messageId: "expectedParentheses", fix(fixer) { const id = node.params[0] diff --git a/lib/rules/block-scoped-var.js b/lib/rules/block-scoped-var.js index 8f7e9ef..ee25e82 100644 --- a/lib/rules/block-scoped-var.js +++ b/lib/rules/block-scoped-var.js @@ -201,6 +201,13 @@ module.exports = { url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/block-scoped-var.md", }, fixable: null, + messages: { + alreadyDefined: '"{{name}}" is already defined.', + definedInUpperScope: + '"{{name}}" is already defined in the upper scope.', + undefined: '"{{name}}" is not defined.', + unused: '"{{name}}" is defined but never used.', + }, schema: [], type: "suggestion", }, @@ -245,7 +252,7 @@ module.exports = { if (scope == null) { context.report({ node: reference.identifier, - message: '"{{name}}" is not defined.', + messageId: "undefined", data: { name: reference.identifier.name }, }) } @@ -256,7 +263,7 @@ module.exports = { for (const identifier of scope.redeclarations) { context.report({ node: identifier, - message: '"{{name}}" is already defined.', + messageId: "alreadyDefined", data: { name: identifier.name }, }) } @@ -264,8 +271,7 @@ module.exports = { if (scope.shadowing) { context.report({ node: scope.identifier, - message: - '"{{name}}" is already defined in the upper scope.', + messageId: "definedInUpperScope", data: { name: scope.identifier.name }, }) } @@ -273,7 +279,7 @@ module.exports = { if (hasReadRef && !scope.used) { context.report({ node: scope.identifier, - message: '"{{name}}" is defined but never used.', + messageId: "unused", data: { name: scope.identifier.name }, }) } diff --git a/lib/rules/no-instanceof-array.js b/lib/rules/no-instanceof-array.js index 121dc63..ea74699 100644 --- a/lib/rules/no-instanceof-array.js +++ b/lib/rules/no-instanceof-array.js @@ -17,6 +17,10 @@ module.exports = { url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-array.md", }, fixable: "code", + messages: { + noInstanceofArray: + "Unexpected 'instanceof' operator. Use 'Array.isArray' instead.", + }, schema: [], type: "problem", }, @@ -61,8 +65,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: - "Unexpected 'instanceof' operator. Use 'Array.isArray' instead.", + messageId: "noInstanceofArray", fix: (fixer) => fixer.replaceText( node, diff --git a/lib/rules/no-instanceof-wrapper.js b/lib/rules/no-instanceof-wrapper.js index 0a20ece..c343ca9 100644 --- a/lib/rules/no-instanceof-wrapper.js +++ b/lib/rules/no-instanceof-wrapper.js @@ -17,6 +17,10 @@ module.exports = { url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-wrapper.md", }, fixable: "code", + messages: { + noInstanceofWrapper: + "Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.", + }, schema: [], type: "problem", }, @@ -72,8 +76,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: - "Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.", + messageId: "noInstanceofWrapper", data: { typeName }, fix: (fixer) => fixer.replaceText( diff --git a/lib/rules/no-literal-call.js b/lib/rules/no-literal-call.js index d5e8d4a..ce992d2 100644 --- a/lib/rules/no-literal-call.js +++ b/lib/rules/no-literal-call.js @@ -25,6 +25,9 @@ module.exports = { url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-literal-call.md", }, fixable: null, + messages: { + noLiteralCall: "This is not a function.", + }, schema: [], type: "problem", }, @@ -41,7 +44,7 @@ module.exports = { if (pattern.test(callee.type)) { context.report({ node: callee, - message: "This is not a function.", + messageId: "noLiteralCall", }) } } diff --git a/lib/rules/no-this-in-static.js b/lib/rules/no-this-in-static.js index 2b29b62..ab84bdb 100644 --- a/lib/rules/no-this-in-static.js +++ b/lib/rules/no-this-in-static.js @@ -17,6 +17,9 @@ module.exports = { url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-this-in-static.md", }, fixable: null, + messages: { + noThisInStatic: "Unexpected '{{type}}'.", + }, schema: [], type: "suggestion", }, @@ -72,7 +75,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: "Unexpected '{{type}}'.", + messageId: "noThisInStatic", data: { type: sourceCode.getText(node) }, }) } diff --git a/lib/rules/no-use-ignored-vars.js b/lib/rules/no-use-ignored-vars.js index 612219d..daa677a 100644 --- a/lib/rules/no-use-ignored-vars.js +++ b/lib/rules/no-use-ignored-vars.js @@ -23,6 +23,10 @@ module.exports = { url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-use-ignored-vars.md", }, fixable: null, + messages: { + noUseIgnoredVars: + "Unexpected a use of '{{name}}'. This name is matched to ignored pattern.", + }, schema: [{ type: "string" }], type: "suggestion", }, @@ -64,8 +68,7 @@ module.exports = { context.report({ node: id, - message: - "Unexpected a use of '{{name}}'. This name is matched to ignored pattern.", + messageId: "noUseIgnoredVars", data: id, }) } diff --git a/lib/rules/no-useless-rest-spread.js b/lib/rules/no-useless-rest-spread.js index a1f9529..5c3f615 100644 --- a/lib/rules/no-useless-rest-spread.js +++ b/lib/rules/no-useless-rest-spread.js @@ -101,6 +101,9 @@ module.exports = { url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-useless-rest-spread.md", }, fixable: "code", + messages: { + noUselessRestSpread: "Redundant {{type1}} {{type2}}.", + }, schema: [], type: "suggestion", }, @@ -139,7 +142,7 @@ module.exports = { context.report({ node, - message: "Redundant {{type1}} {{type2}}.", + messageId: "noUselessRestSpread", data: { type1, type2 }, fix: defineFixer(sourceCode, node), }) diff --git a/lib/rules/prefer-for-of.js b/lib/rules/prefer-for-of.js index 463a8f6..e0921d9 100644 --- a/lib/rules/prefer-for-of.js +++ b/lib/rules/prefer-for-of.js @@ -16,7 +16,6 @@ const assert = require("assert") //------------------------------------------------------------------------------ const SENTINEL_TYPE = /(?:Declaration|Statement)$/u -const MESSAGE = "Expected for-of statement." /** * Checks whether the given outer node contains the given inner node. @@ -501,6 +500,9 @@ module.exports = { url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/prefer-for-of.md", }, fixable: "code", + messages: { + preferForOf: "Expected for-of statement.", + }, schema: [], type: "suggestion", }, @@ -547,7 +549,7 @@ module.exports = { const expressionStatementNode = funcInfo.node.parent.parent context.report({ node: expressionStatementNode, - message: MESSAGE, + messageId: "preferForOf", fix: fixArrayForEach.bind(null, context, funcInfo), }) } @@ -609,14 +611,14 @@ module.exports = { ) { context.report({ node, - message: MESSAGE, + messageId: "preferForOf", fix: fixForStatement.bind(null, context, node), }) } }, ForInStatement(node) { - context.report({ node, message: MESSAGE }) + context.report({ node, messageId: "preferForOf" }) }, } }, diff --git a/package.json b/package.json index afeee8e..4404134 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@typescript-eslint/eslint-plugin": "^5.40.0", "@typescript-eslint/parser": "^5.40.0", "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-eslint-plugin": "^2.3.0", + "eslint-plugin-eslint-plugin": "^4.4.1", "eslint-plugin-node": "^10.0.0", "eslint-plugin-prettier": "^3.4.1", "eslint-plugin-vue": "^6.2.2",