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 ff11df1 commit 7e675d8
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 115 deletions.
58 changes: 28 additions & 30 deletions lib/configs/+eslint-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ module.exports = {
"error",
"@eslint-community/mysticatea/eslint-plugin/fixer-return":
"error",
"@eslint-community/mysticatea/eslint-plugin/meta-property-ordering": [
"error",
"@eslint-community/mysticatea/eslint-plugin/meta-property-ordering":
[
"deprecated",
"docs",
"fixable",
"messages",
"replacedBy",
"schema",
"type",
"error",
[
"deprecated",
"docs",
"fixable",
"messages",
"replacedBy",
"schema",
"type",
],
],
],
"@eslint-community/mysticatea/eslint-plugin/no-deprecated-context-methods":
"error",
"@eslint-community/mysticatea/eslint-plugin/no-deprecated-report-api":
Expand All @@ -49,36 +50,33 @@ module.exports = {
"error",
"@eslint-community/mysticatea/eslint-plugin/prefer-replace-text":
"error",
"@eslint-community/mysticatea/eslint-plugin/report-message-format": [
"error",
"[^a-z'\"{].*\\.$",
],
"@eslint-community/mysticatea/eslint-plugin/report-message-format":
["error", "[^a-z'\"{].*\\.$"],
"@eslint-community/mysticatea/eslint-plugin/require-meta-docs-description":
"error",
"@eslint-community/mysticatea/eslint-plugin/require-meta-docs-url": [
"error",
{ pattern: rulesDocumentUrl },
],
"@eslint-community/mysticatea/eslint-plugin/require-meta-docs-url":
["error", { pattern: rulesDocumentUrl }],
"@eslint-community/mysticatea/eslint-plugin/require-meta-fixable":
"error",
"@eslint-community/mysticatea/eslint-plugin/require-meta-schema":
"error",
"@eslint-community/mysticatea/eslint-plugin/require-meta-type":
"error",
"@eslint-community/mysticatea/eslint-plugin/test-case-property-ordering": [
"error",
"@eslint-community/mysticatea/eslint-plugin/test-case-property-ordering":
[
"filename",
"code",
"output",
"options",
"parser",
"parserOptions",
"globals",
"env",
"errors",
"error",
[
"filename",
"code",
"output",
"options",
"parser",
"parserOptions",
"globals",
"env",
"errors",
],
],
],
"@eslint-community/mysticatea/eslint-plugin/test-case-shorthand-strings":
"error",
},
Expand Down
21 changes: 10 additions & 11 deletions lib/configs/_override-vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,19 @@ module.exports = {
"@eslint-community/mysticatea/vue/html-quotes": "error",
"@eslint-community/mysticatea/vue/order-in-components": "error",
"@eslint-community/mysticatea/vue/this-in-template": "error",
"@eslint-community/mysticatea/vue/html-closing-bracket-newline": [
"error",
{
singleline: "never",
multiline: "always",
},
],
"@eslint-community/mysticatea/vue/html-closing-bracket-newline":
[
"error",
{
singleline: "never",
multiline: "always",
},
],
"@eslint-community/mysticatea/vue/html-closing-bracket-spacing":
"error",
"@eslint-community/mysticatea/vue/prop-name-casing": "error",
"@eslint-community/mysticatea/vue/component-name-in-template-casing": [
"error",
"kebab-case",
],
"@eslint-community/mysticatea/vue/component-name-in-template-casing":
["error", "kebab-case"],
"@eslint-community/mysticatea/vue/multiline-html-element-content-newline":
"error",
"@eslint-community/mysticatea/vue/singleline-html-element-content-newline":
Expand Down
2 changes: 1 addition & 1 deletion lib/processors/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
}

// Filter messages which are in disabled area.
return messages[0].filter(message => {
return messages[0].filter((message) => {
if (
message.ruleId ===
"@eslint-community/mysticatea/vue/comment-directive"
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/arrow-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ module.exports = {
description: "enforce the parentheses style of arrow functions.",
category: "Stylistic Issues",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/arrow-parens.md",
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/arrow-parens.md",
},
fixable: "code",
schema: [],
Expand Down
9 changes: 5 additions & 4 deletions lib/rules/block-scoped-var.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
// Helpers
//------------------------------------------------------------------------------

const scopeNodeType = /^(?:(?:Block|Switch|For(?:In|Of)?)Statement|CatchClause|Program)$/u
const containerNodeType = /^(?:For(?:In|Of)?Statement|(?:Arrow)?Function(?:Declaration|Expression))$/u
const scopeNodeType =
/^(?:(?:Block|Switch|For(?:In|Of)?)Statement|CatchClause|Program)$/u
const containerNodeType =
/^(?:For(?:In|Of)?Statement|(?:Arrow)?Function(?:Declaration|Expression))$/u

/**
* Checks whether or not a given definition should be skipped.
Expand Down Expand Up @@ -196,8 +198,7 @@ module.exports = {
description: "disallow illegal usage of variables as block-scoped.",
category: "Possible Errors",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/block-scoped-var.md",
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/block-scoped-var.md",
},
fixable: null,
schema: [],
Expand Down
5 changes: 2 additions & 3 deletions lib/rules/no-instanceof-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ module.exports = {
docs: {
description: "disallow 'instanceof' for Array",
category: "Best Practices",
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-array.md",
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-array.md",
},
fixable: "code",
schema: [],
Expand Down Expand Up @@ -64,7 +63,7 @@ module.exports = {
loc: node.loc,
message:
"Unexpected 'instanceof' operator. Use 'Array.isArray' instead.",
fix: fixer =>
fix: (fixer) =>
fixer.replaceText(
node,
`Array.isArray(${sourceCode.getText(
Expand Down
5 changes: 2 additions & 3 deletions lib/rules/no-instanceof-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ module.exports = {
docs: {
description: "disallow 'instanceof' for wrapper objects",
category: "Best Practices",
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-wrapper.md",
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-instanceof-wrapper.md",
},
fixable: "code",
schema: [],
Expand Down Expand Up @@ -76,7 +75,7 @@ module.exports = {
message:
"Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.",
data: { typeName },
fix: fixer =>
fix: (fixer) =>
fixer.replaceText(
node,
`typeof ${sourceCode.getText(
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-literal-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
//------------------------------------------------------------------------------

const LITERAL_TYPE = /^(?:(?:Array|Object)Expression|(?:Template)?Literal)$/u
const LITERAL_AND_CLASS_TYPE = /^(?:(?:Array|Class|Object)Expression|(?:Template)?Literal)$/u
const LITERAL_AND_CLASS_TYPE =
/^(?:(?:Array|Class|Object)Expression|(?:Template)?Literal)$/u

//------------------------------------------------------------------------------
// Rule Definition
Expand All @@ -21,8 +22,7 @@ module.exports = {
description: "disallow a call of a literal.",
category: "Possible Errors",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-literal-call.md",
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-literal-call.md",
},
fixable: null,
schema: [],
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/no-this-in-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ module.exports = {
docs: {
description: "disallow `this`/`super` in static methods",
category: "Best Practices",
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-this-in-static.md",
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-this-in-static.md",
},
fixable: null,
schema: [],
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/no-use-ignored-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ module.exports = {
description: "disallow a use of ignored variables.",
category: "Stylistic Issues",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-use-ignored-vars.md",
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-use-ignored-vars.md",
},
fixable: null,
schema: [{ type: "string" }],
Expand Down
14 changes: 7 additions & 7 deletions lib/rules/no-useless-rest-spread.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
// Helpers
//------------------------------------------------------------------------------

const FUNC_TYPE = /^(?:FunctionDeclaration|(?:New|Call|(?:Arrow)?Function)Expression)$/u
const FUNC_TYPE =
/^(?:FunctionDeclaration|(?:New|Call|(?:Arrow)?Function)Expression)$/u
const PROPERTY_PATTERN = /^(?:Experimental)?(Rest|Spread)Property$/u

/**
Expand Down Expand Up @@ -56,7 +57,7 @@ function getLastElementToken(sourceCode, node) {
* @returns {function} A fixer function.
*/
function defineFixer(sourceCode, node) {
return fixer => {
return (fixer) => {
const child = node.argument

// If the inner array includes holes, do nothing.
Expand Down Expand Up @@ -97,8 +98,7 @@ module.exports = {
description: "disallow unnecessary spread operators.",
category: "Best Practices",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-useless-rest-spread.md",
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/no-useless-rest-spread.md",
},
fixable: "code",
schema: [],
Expand All @@ -116,7 +116,7 @@ module.exports = {
function verify(node) {
const nodeType = node.type.replace(
PROPERTY_PATTERN,
t => `${t}Element`
(t) => `${t}Element`
)
const parentType = node.parent.type
const argumentType = node.argument.type
Expand All @@ -131,11 +131,11 @@ module.exports = {
nodeType === "RestElement" && argumentType !== parentType
const type1 = nodeType === "RestElement" ? "rest" : "spread"
const type2 =
/*eslint-disable @eslint-community/mysticatea/prettier */
/* eslint-disable @eslint-community/mysticatea/prettier */
isRestParameter ? "parameter" :
isArray ? "element" :
/* otherwise */ "property"
/*eslint-enable @eslint-community/mysticatea/prettier */
/* eslint-enable @eslint-community/mysticatea/prettier */

context.report({
node,
Expand Down
14 changes: 7 additions & 7 deletions lib/rules/prefer-for-of.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function isTraversingArray(node) {
let indexDecl = null
let lengthDecl = null

/*eslint-disable @eslint-community/mysticatea/prettier */
/* eslint-disable @eslint-community/mysticatea/prettier */
return (
init != null &&
init.type === "VariableDeclaration" &&
Expand Down Expand Up @@ -186,7 +186,7 @@ function isTraversingArray(node) {
)
)
)
/*eslint-enable @eslint-community/mysticatea/prettier */
/* eslint-enable @eslint-community/mysticatea/prettier */
}

/**
Expand Down Expand Up @@ -243,7 +243,7 @@ function isIndexVarOnlyUsedToGetArrayElements(context, node) {
const arrayText = getArrayTextOfForStatement(sourceCode, node)
const indexVar = context.getDeclaredVariables(node.init)[0]

return indexVar.references.every(reference => {
return indexVar.references.every((reference) => {
const id = reference.identifier

return (
Expand Down Expand Up @@ -273,7 +273,8 @@ function isLengthVarOnlyUsedToTest(context, node) {
const lengthVar = context.getDeclaredVariables(node.init.declarations[1])[0]

return lengthVar.references.every(
reference => reference.init || contains(node.test, reference.identifier)
(reference) =>
reference.init || contains(node.test, reference.identifier)
)
}

Expand Down Expand Up @@ -497,8 +498,7 @@ module.exports = {
description: "requires for-of statements instead of Array#forEach",
category: "Best Practices",
recommended: false,
url:
"https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/prefer-for-of.md",
url: "https://github.com/eslint-community/eslint-plugin-mysticatea/blob/HEAD/docs/rules/prefer-for-of.md",
},
fixable: "code",
schema: [],
Expand Down Expand Up @@ -580,7 +580,7 @@ module.exports = {
if (
thisFuncInfo != null &&
thisFuncInfo.isTarget &&
!thisFuncInfo.returnNodes.some(returnNode =>
!thisFuncInfo.returnNodes.some((returnNode) =>
contains(returnNode, node)
)
) {
Expand Down
6 changes: 3 additions & 3 deletions scripts/generate-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ fs.writeFileSync(
module.exports = {
${fs
.readdirSync(path.resolve(__dirname, "../lib/configs"))
.map(fileName => path.basename(fileName, ".js"))
.filter(id => !id.startsWith("_"))
.map(id => ` "${id}": require("./configs/${id}"),`)
.map((fileName) => path.basename(fileName, ".js"))
.filter((id) => !id.startsWith("_"))
.map((id) => ` "${id}": require("./configs/${id}"),`)
.join("\n")}
}
`
Expand Down
8 changes: 4 additions & 4 deletions scripts/generate-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ fs.writeFileSync(
module.exports = Object.assign(
${fs
.readdirSync(path.resolve(__dirname, "../lib/foreign-rules"))
.map(fileName => path.basename(fileName, ".js"))
.map(id => ` require("./foreign-rules/${id}"),`)
.map((fileName) => path.basename(fileName, ".js"))
.map((id) => ` require("./foreign-rules/${id}"),`)
.join("\n")}
{
${fs
.readdirSync(path.resolve(__dirname, "../lib/rules"))
.map(fileName => path.basename(fileName, ".js"))
.map(id => ` "${id}": require("./rules/${id}"),`)
.map((fileName) => path.basename(fileName, ".js"))
.map((id) => ` "${id}": require("./rules/${id}"),`)
.join("\n")}
}
)
Expand Down
Loading

0 comments on commit 7e675d8

Please sign in to comment.