Skip to content

Commit

Permalink
feat: update eslint-plugin-eslint-plugin + update configs (mysticat…
Browse files Browse the repository at this point in the history
…ea#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
  • Loading branch information
MichaelDeBoey authored Oct 17, 2022
1 parent 0bc3644 commit b08d8b6
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 23 deletions.
10 changes: 10 additions & 0 deletions lib/configs/+eslint-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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":
Expand Down
12 changes: 8 additions & 4 deletions lib/rules/arrow-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -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]
Expand All @@ -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]

Expand Down
16 changes: 11 additions & 5 deletions lib/rules/block-scoped-var.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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 },
})
}
Expand All @@ -256,24 +263,23 @@ module.exports = {
for (const identifier of scope.redeclarations) {
context.report({
node: identifier,
message: '"{{name}}" is already defined.',
messageId: "alreadyDefined",
data: { name: identifier.name },
})
}

if (scope.shadowing) {
context.report({
node: scope.identifier,
message:
'"{{name}}" is already defined in the upper scope.',
messageId: "definedInUpperScope",
data: { name: scope.identifier.name },
})
}

if (hasReadRef && !scope.used) {
context.report({
node: scope.identifier,
message: '"{{name}}" is defined but never used.',
messageId: "unused",
data: { name: scope.identifier.name },
})
}
Expand Down
7 changes: 5 additions & 2 deletions lib/rules/no-instanceof-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions lib/rules/no-instanceof-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/no-literal-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -41,7 +44,7 @@ module.exports = {
if (pattern.test(callee.type)) {
context.report({
node: callee,
message: "This is not a function.",
messageId: "noLiteralCall",
})
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/no-this-in-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -72,7 +75,7 @@ module.exports = {
context.report({
node,
loc: node.loc,
message: "Unexpected '{{type}}'.",
messageId: "noThisInStatic",
data: { type: sourceCode.getText(node) },
})
}
Expand Down
7 changes: 5 additions & 2 deletions lib/rules/no-use-ignored-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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,
})
}
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/no-useless-rest-spread.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -139,7 +142,7 @@ module.exports = {

context.report({
node,
message: "Redundant {{type1}} {{type2}}.",
messageId: "noUselessRestSpread",
data: { type1, type2 },
fix: defineFixer(sourceCode, node),
})
Expand Down
10 changes: 6 additions & 4 deletions lib/rules/prefer-for-of.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
},
Expand Down Expand Up @@ -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),
})
}
Expand Down Expand Up @@ -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" })
},
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b08d8b6

Please sign in to comment.