Skip to content

Commit

Permalink
chore: fix ESLint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Oct 17, 2022
1 parent be5af22 commit 5a94cbf
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 22 deletions.
12 changes: 8 additions & 4 deletions lib/rules/arrow-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ module.exports = {
"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 @@ -54,8 +60,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 @@ -73,8 +78,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 @@ -200,6 +200,13 @@ module.exports = {
"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 @@ -244,7 +251,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 @@ -255,24 +262,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 @@ -18,6 +18,10 @@ module.exports = {
"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 @@ -62,8 +66,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 @@ -18,6 +18,10 @@ module.exports = {
"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 @@ -73,8 +77,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 = {
"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 @@ -18,6 +18,9 @@ module.exports = {
"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 @@ -73,7 +76,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 @@ -24,6 +24,10 @@ module.exports = {
"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 @@ -65,8 +69,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 = {
"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 = {
"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

0 comments on commit 5a94cbf

Please sign in to comment.