prettier / prettier-regression-testing

Automates the prettier/prettier regression checks with GitHub Actions.
11 stars 9 forks source link

for 12087 #130

Open fisker opened 2 years ago

fisker commented 2 years ago

https://github.com/prettier/prettier/pull/12087

fisker commented 2 years ago

Run #12087

github-actions[bot] commented 2 years ago

prettier/prettier#12087 VS prettier/prettier@main :: babel/babel@36a5ac4145be44b5dbbe2e8a70d1d0e7dc32ba43

Diff (302 lines) ```diff diff --git ORI/babel/packages/babel-core/test/config-loading.js ALT/babel/packages/babel-core/test/config-loading.js index 46e1758b..c363ea60 100644 --- ORI/babel/packages/babel-core/test/config-loading.js +++ ALT/babel/packages/babel-core/test/config-loading.js @@ -36,12 +36,14 @@ describe("@babel/core config loading", () => { return { cwd: path.dirname(FILEPATH), filename: FILEPATH, - presets: skipProgrammatic - ? null - : [[require("./fixtures/config-loading/preset3.js"), {}]], - plugins: skipProgrammatic - ? null - : [[require("./fixtures/config-loading/plugin6.js"), {}]], + presets: + skipProgrammatic + ? null + : [[require("./fixtures/config-loading/preset3.js"), {}]], + plugins: + skipProgrammatic + ? null + : [[require("./fixtures/config-loading/plugin6.js"), {}]], }; } diff --git ORI/babel/packages/babel-parser/src/parser/expression.js ALT/babel/packages/babel-parser/src/parser/expression.js index e221d4d9..a8f68f18 100644 --- ORI/babel/packages/babel-parser/src/parser/expression.js +++ ALT/babel/packages/babel-parser/src/parser/expression.js @@ -621,9 +621,10 @@ export default class ExpressionParser extends LValParser { if (isAwait) { const { type } = this.state; - const startsExpr = this.hasPlugin("v8intrinsic") - ? tokenCanStartExpression(type) - : tokenCanStartExpression(type) && !this.match(tt.modulo); + const startsExpr = + this.hasPlugin("v8intrinsic") + ? tokenCanStartExpression(type) + : tokenCanStartExpression(type) && !this.match(tt.modulo); if (startsExpr && !this.isAmbiguousAwait()) { this.raiseOverwrite(startPos, Errors.AwaitNotInAsyncContext); return this.parseAwait(startPos, startLoc); @@ -2120,9 +2121,10 @@ export default class ExpressionParser extends LValParser { prop.shorthand = false; if (this.eat(tt.colon)) { - prop.value = isPattern - ? this.parseMaybeDefault(this.state.start, this.state.startLoc) - : this.parseMaybeAssignAllowIn(refExpressionErrors); + prop.value = + isPattern + ? this.parseMaybeDefault(this.state.start, this.state.startLoc) + : this.parseMaybeAssignAllowIn(refExpressionErrors); return this.finishNode(prop, "ObjectProperty"); } @@ -2631,11 +2633,12 @@ export default class ExpressionParser extends LValParser { return; } - const reservedTest = !this.state.strict - ? isReservedWord - : isBinding - ? isStrictBindReservedWord - : isStrictReservedWord; + const reservedTest = + !this.state.strict + ? isReservedWord + : isBinding + ? isStrictBindReservedWord + : isStrictReservedWord; if (reservedTest(word, this.inModule)) { this.raise(startLoc, Errors.UnexpectedReservedWord, word); diff --git ORI/babel/packages/babel-parser/src/parser/statement.js ALT/babel/packages/babel-parser/src/parser/statement.js index 4addc193..8b2d0a22 100644 --- ORI/babel/packages/babel-parser/src/parser/statement.js +++ ALT/babel/packages/babel-parser/src/parser/statement.js @@ -867,11 +867,12 @@ export default class StatementParser extends ExpressionParser { } } - const kind = tokenIsLoop(this.state.type) - ? "loop" - : this.match(tt._switch) - ? "switch" - : null; + const kind = + tokenIsLoop(this.state.type) + ? "loop" + : this.match(tt._switch) + ? "switch" + : null; for (let i = this.state.labels.length - 1; i >= 0; i--) { const label = this.state.labels[i]; if (label.statementStart === node.start) { @@ -1081,9 +1082,8 @@ export default class StatementParser extends ExpressionParser { } node.left = init; - node.right = isForIn - ? this.parseExpression() - : this.parseMaybeAssignAllowIn(); + node.right = + isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn(); this.expect(tt.parenR); // Parse the loop body. @@ -1116,9 +1116,10 @@ export default class StatementParser extends ExpressionParser { const decl = this.startNode(); this.parseVarId(decl, kind); if (this.eat(tt.eq)) { - decl.init = isFor - ? this.parseMaybeAssignDisallowIn() - : this.parseMaybeAssignAllowIn(); + decl.init = + isFor + ? this.parseMaybeAssignDisallowIn() + : this.parseMaybeAssignAllowIn(); } else { if ( kind === "const" && diff --git ORI/babel/packages/babel-parser/src/plugins/flow/index.js ALT/babel/packages/babel-parser/src/plugins/flow/index.js index 660fcb59..78916d67 100644 --- ORI/babel/packages/babel-parser/src/plugins/flow/index.js +++ ALT/babel/packages/babel-parser/src/plugins/flow/index.js @@ -1735,9 +1735,10 @@ export default (superClass: Class): Class => flowParseTypeAnnotatableIdentifier( allowPrimitiveOverride?: boolean, ): N.Identifier { - const ident = allowPrimitiveOverride - ? this.parseIdentifier() - : this.flowParseRestrictedIdentifier(); + const ident = + allowPrimitiveOverride + ? this.parseIdentifier() + : this.flowParseRestrictedIdentifier(); if (this.match(tt.colon)) { ident.typeAnnotation = this.flowParseTypeAnnotation(); this.resetEndLocation(ident); @@ -1805,9 +1806,10 @@ export default (superClass: Class): Class => node.predicate, ] = this.flowParseTypeAndPredicateInitialiser(); - node.returnType = typeNode.typeAnnotation - ? this.finishNode(typeNode, "TypeAnnotation") - : null; + node.returnType = + typeNode.typeAnnotation + ? this.finishNode(typeNode, "TypeAnnotation") + : null; } super.parseFunctionBodyAndFinish(node, type, isMethod); @@ -2579,12 +2581,13 @@ export default (superClass: Class): Class => type: string, contextDescription: string, ): void { - specifier.local = hasTypeImportKind(node) - ? this.flowParseRestrictedIdentifier( - /* liberal */ true, - /* declaration */ true, - ) - : this.parseIdentifier(); + specifier.local = + hasTypeImportKind(node) + ? this.flowParseRestrictedIdentifier( + /* liberal */ true, + /* declaration */ true, + ) + : this.parseIdentifier(); this.checkLVal(specifier.local, contextDescription, BIND_LEXICAL); node.specifiers.push(this.finishNode(specifier, type)); @@ -2941,9 +2944,10 @@ export default (superClass: Class): Class => if (result.error) this.state = result.failState; // assign after it is clear it is an arrow - node.returnType = result.node.typeAnnotation - ? this.finishNode(result.node, "TypeAnnotation") - : null; + node.returnType = + result.node.typeAnnotation + ? this.finishNode(result.node, "TypeAnnotation") + : null; } return super.parseArrow(node); @@ -3370,9 +3374,8 @@ export default (superClass: Class): Class => flowEnumMemberRaw(): { id: N.Node, init: EnumMemberInit } { const pos = this.state.start; const id = this.parseIdentifier(true); - const init = this.eat(tt.eq) - ? this.flowEnumMemberInit() - : { type: "none", pos }; + const init = + this.eat(tt.eq) ? this.flowEnumMemberInit() : { type: "none", pos }; return { id, init }; } diff --git ORI/babel/packages/babel-parser/src/plugins/typescript/index.js ALT/babel/packages/babel-parser/src/plugins/typescript/index.js index c749d838..b5a9c077 100644 --- ORI/babel/packages/babel-parser/src/plugins/typescript/index.js +++ ALT/babel/packages/babel-parser/src/plugins/typescript/index.js @@ -1573,9 +1573,10 @@ export default (superClass: Class): Class => tsParseEnumMember(): N.TsEnumMember { const node: N.TsEnumMember = this.startNode(); // Computed property names are grammar errors in an enum, so accept just string literal or identifier. - node.id = this.match(tt.string) - ? this.parseExprAtom() - : this.parseIdentifier(/* liberal */ true); + node.id = + this.match(tt.string) + ? this.parseExprAtom() + : this.parseIdentifier(/* liberal */ true); if (this.eat(tt.eq)) { node.initializer = this.parseMaybeAssignAllowIn(); } @@ -3337,9 +3338,8 @@ export default (superClass: Class): Class => parseMethod(...args: any[]) { const method = super.parseMethod(...args); if (method.abstract) { - const hasBody = this.hasPlugin("estree") - ? !!method.value.body - : !!method.body; + const hasBody = + this.hasPlugin("estree") ? !!method.value.body : !!method.body; if (hasBody) { const { key } = method; this.raise( @@ -3491,9 +3491,8 @@ export default (superClass: Class): Class => node[kindKey] = hasTypeSpecifier ? "type" : "value"; if (canParseAsKeyword && this.eatContextual(tt._as)) { - node[rightOfAsKey] = isImport - ? this.parseIdentifier() - : this.parseModuleExportName(); + node[rightOfAsKey] = + isImport ? this.parseIdentifier() : this.parseModuleExportName(); } if (!node[rightOfAsKey]) { node[rightOfAsKey] = cloneIdentifier(node[leftOfAsKey]); diff --git ORI/babel/packages/babel-plugin-transform-runtime/scripts/build-dist.js ALT/babel/packages/babel-plugin-transform-runtime/scripts/build-dist.js index 4e13c713..1e931e62 100644 --- ORI/babel/packages/babel-plugin-transform-runtime/scripts/build-dist.js +++ ALT/babel/packages/babel-plugin-transform-runtime/scripts/build-dist.js @@ -117,9 +117,10 @@ function writeHelperFile( { esm, corejs } ) { const fileName = `${helperName}.js`; - const filePath = esm - ? path.join("helpers", "esm", fileName) - : path.join("helpers", fileName); + const filePath = + esm + ? path.join("helpers", "esm", fileName) + : path.join("helpers", fileName); const fullPath = path.join(pkgDirname, filePath); outputFile( diff --git ORI/babel/packages/babel-types/scripts/generators/builders.js ALT/babel/packages/babel-types/scripts/generators/builders.js index 13e772eb..18d387bc 100644 --- ORI/babel/packages/babel-types/scripts/generators/builders.js +++ ALT/babel/packages/babel-types/scripts/generators/builders.js @@ -93,9 +93,10 @@ import type * as t from "../.."; Object.keys(definitions.BUILDER_KEYS).forEach(type => { const defArgs = generateBuilderArgs(type); const formatedBuilderName = formatBuilderName(type); - const formatedBuilderNameLocal = reservedNames.has(formatedBuilderName) - ? `_${formatedBuilderName}` - : formatedBuilderName; + const formatedBuilderNameLocal = + reservedNames.has(formatedBuilderName) + ? `_${formatedBuilderName}` + : formatedBuilderName; output += `${ formatedBuilderNameLocal === formatedBuilderName ? "export " : "" }function ${formatedBuilderNameLocal}(${defArgs.join( diff --git ORI/babel/packages/babel-types/test/builders/typescript/tsTypeParameter.js ALT/babel/packages/babel-types/test/builders/typescript/tsTypeParameter.js index e11753de..653d06a9 100644 --- ORI/babel/packages/babel-types/test/builders/typescript/tsTypeParameter.js +++ ALT/babel/packages/babel-types/test/builders/typescript/tsTypeParameter.js @@ -15,12 +15,13 @@ describe("builders", function () { // TODO(babel-8): move this check to the snapshot expect(tsTypeParameter).toEqual( expect.objectContaining({ - name: !process.env.BABEL_8_BREAKING - ? "foo" - : expect.objectContaining({ - name: "foo", - type: "Identifier", - }), + name: + !process.env.BABEL_8_BREAKING + ? "foo" + : expect.objectContaining({ + name: "foo", + type: "Identifier", + }), }), ); }); ```
github-actions[bot] commented 2 years ago

prettier/prettier#12087 VS prettier/prettier@main :: vuejs/eslint-plugin-vue@10dd1a99aa983754deb76383b224d48ebb2cbe91

Diff (1197 lines) ```diff diff --git ORI/eslint-plugin-vue/lib/rules/attribute-hyphenation.js ALT/eslint-plugin-vue/lib/rules/attribute-hyphenation.js index ec5a3a9..8336ea9 100644 --- ORI/eslint-plugin-vue/lib/rules/attribute-hyphenation.js +++ ALT/eslint-plugin-vue/lib/rules/attribute-hyphenation.js @@ -74,9 +74,10 @@ module.exports = { context.report({ node: node.key, loc: node.loc, - message: useHyphenated - ? "Attribute '{{text}}' must be hyphenated." - : "Attribute '{{text}}' can't be hyphenated.", + message: + useHyphenated + ? "Attribute '{{text}}' must be hyphenated." + : "Attribute '{{text}}' can't be hyphenated.", data: { text }, @@ -108,13 +109,14 @@ module.exports = { VAttribute(node) { if (!utils.isCustomComponent(node.parent.parent)) return - const name = !node.directive - ? node.key.rawName - : node.key.name.name === 'bind' - ? node.key.argument && - node.key.argument.type === 'VIdentifier' && - node.key.argument.rawName - : /* otherwise */ false + const name = + !node.directive + ? node.key.rawName + : node.key.name.name === 'bind' + ? node.key.argument && + node.key.argument.type === 'VIdentifier' && + node.key.argument.rawName + : /* otherwise */ false if (!name || isIgnoredAttribute(name)) return reportIssue(node, name) diff --git ORI/eslint-plugin-vue/lib/rules/comment-directive.js ALT/eslint-plugin-vue/lib/rules/comment-directive.js index 942860f..c0e7090 100644 --- ORI/eslint-plugin-vue/lib/rules/comment-directive.js +++ ALT/eslint-plugin-vue/lib/rules/comment-directive.js @@ -129,9 +129,10 @@ function processBlock(context, comment, reportUnusedDisableDirectives) { if (parsed != null) { if (parsed.type === 'eslint-disable') { if (parsed.rules.length) { - const rules = reportUnusedDisableDirectives - ? reportUnusedRules(context, comment, parsed.type, parsed.rules) - : parsed.rules + const rules = + reportUnusedDisableDirectives + ? reportUnusedRules(context, comment, parsed.type, parsed.rules) + : parsed.rules for (const rule of rules) { disable( context, @@ -142,9 +143,10 @@ function processBlock(context, comment, reportUnusedDisableDirectives) { ) } } else { - const key = reportUnusedDisableDirectives - ? reportUnused(context, comment, parsed.type) - : '' + const key = + reportUnusedDisableDirectives + ? reportUnused(context, comment, parsed.type) + : '' disable(context, comment.loc.start, 'block', null, key) } } else { @@ -174,17 +176,19 @@ function processLine(context, comment, reportUnusedDisableDirectives) { comment.loc.start.line + (parsed.type === 'eslint-disable-line' ? 0 : 1) const column = -1 if (parsed.rules.length) { - const rules = reportUnusedDisableDirectives - ? reportUnusedRules(context, comment, parsed.type, parsed.rules) - : parsed.rules + const rules = + reportUnusedDisableDirectives + ? reportUnusedRules(context, comment, parsed.type, parsed.rules) + : parsed.rules for (const rule of rules) { disable(context, { line, column }, 'line', rule.ruleId, rule.key || '') enable(context, { line: line + 1, column }, 'line', rule.ruleId) } } else { - const key = reportUnusedDisableDirectives - ? reportUnused(context, comment, parsed.type) - : '' + const key = + reportUnusedDisableDirectives + ? reportUnused(context, comment, parsed.type) + : '' disable(context, { line, column }, 'line', null, key) enable(context, { line: line + 1, column }, 'line', null) } diff --git ORI/eslint-plugin-vue/lib/rules/component-api-style.js ALT/eslint-plugin-vue/lib/rules/component-api-style.js index 9ebf01d..5f5e275 100644 --- ORI/eslint-plugin-vue/lib/rules/component-api-style.js +++ ALT/eslint-plugin-vue/lib/rules/component-api-style.js @@ -240,9 +240,10 @@ module.exports = { }, utils.defineVueVisitor(context, { onVueObjectEnter(node) { - const allows = utils.isSFCObject(context, node) - ? options.allowsSFC - : options.allowsOther + const allows = + utils.isSFCObject(context, node) + ? options.allowsSFC + : options.allowsOther if ( (allows.composition || allows.compositionVue2) && allows.options @@ -281,9 +282,10 @@ module.exports = { if (disallowApi) { context.report({ node: prop.key, - messageId: isPreferScriptSetup(allows) - ? 'disallowComponentOptionPreferScriptSetup' - : 'disallowComponentOption', + messageId: + isPreferScriptSetup(allows) + ? 'disallowComponentOptionPreferScriptSetup' + : 'disallowComponentOption', data: { disallowedApi: disallowApi.apiName, optionPhrase: buildOptionPhrase(name), diff --git ORI/eslint-plugin-vue/lib/rules/component-options-name-casing.js ALT/eslint-plugin-vue/lib/rules/component-options-name-casing.js index ad70c15..a427682 100644 --- ORI/eslint-plugin-vue/lib/rules/component-options-name-casing.js +++ ALT/eslint-plugin-vue/lib/rules/component-options-name-casing.js @@ -81,33 +81,38 @@ module.exports = { component: name, caseType }, - fix: canAutoFix - ? (fixer) => { - const converted = convert(name) - return property.shorthand - ? fixer.replaceText(property, `${converted}: ${name}`) - : fixer.replaceText(property.key, converted) - } - : undefined, - suggest: canAutoFix - ? undefined - : [ - { - messageId: 'possibleRenaming', - data: { caseType }, - fix: (fixer) => { - const converted = convert(name) - if (caseType === 'kebab-case') { + fix: + canAutoFix + ? (fixer) => { + const converted = convert(name) + return property.shorthand + ? fixer.replaceText(property, `${converted}: ${name}`) + : fixer.replaceText(property.key, converted) + } + : undefined, + suggest: + canAutoFix + ? undefined + : [ + { + messageId: 'possibleRenaming', + data: { caseType }, + fix: (fixer) => { + const converted = convert(name) + if (caseType === 'kebab-case') { + return property.shorthand + ? fixer.replaceText( + property, + `'${converted}': ${name}` + ) + : fixer.replaceText(property.key, `'${converted}'`) + } return property.shorthand - ? fixer.replaceText(property, `'${converted}': ${name}`) - : fixer.replaceText(property.key, `'${converted}'`) + ? fixer.replaceText(property, `${converted}: ${name}`) + : fixer.replaceText(property.key, converted) } - return property.shorthand - ? fixer.replaceText(property, `${converted}: ${name}`) - : fixer.replaceText(property.key, converted) } - } - ] + ] }) }) }) diff --git ORI/eslint-plugin-vue/lib/rules/html-comment-content-newline.js ALT/eslint-plugin-vue/lib/rules/html-comment-content-newline.js index 3985f7d..c651f9f 100644 --- ORI/eslint-plugin-vue/lib/rules/html-comment-content-newline.js +++ ALT/eslint-plugin-vue/lib/rules/html-comment-content-newline.js @@ -102,12 +102,10 @@ module.exports = { return } - const startLine = openDecoration - ? openDecoration.loc.end.line - : value.loc.start.line - const endLine = closeDecoration - ? closeDecoration.loc.start.line - : value.loc.end.line + const startLine = + openDecoration ? openDecoration.loc.end.line : value.loc.start.line + const endLine = + closeDecoration ? closeDecoration.loc.start.line : value.loc.end.line const newlineType = startLine === endLine ? option.singleline : option.multiline if (newlineType === 'ignore') { @@ -141,12 +139,14 @@ module.exports = { start: beforeToken.loc.end, end: value.loc.start }, - messageId: openDecoration - ? 'expectedAfterExceptionBlock' - : 'expectedAfterHTMLCommentOpen', - fix: openDecoration - ? undefined - : (fixer) => fixer.insertTextAfter(beforeToken, '\n') + messageId: + openDecoration + ? 'expectedAfterExceptionBlock' + : 'expectedAfterHTMLCommentOpen', + fix: + openDecoration + ? undefined + : (fixer) => fixer.insertTextAfter(beforeToken, '\n') }) } else { if (beforeToken.loc.end.line === value.loc.start.line) { @@ -188,12 +188,14 @@ module.exports = { start: value.loc.end, end: afterToken.loc.start }, - messageId: closeDecoration - ? 'expectedBeforeExceptionBlock' - : 'expectedBeforeHTMLCommentOpen', - fix: closeDecoration - ? undefined - : (fixer) => fixer.insertTextBefore(afterToken, '\n') + messageId: + closeDecoration + ? 'expectedBeforeExceptionBlock' + : 'expectedBeforeHTMLCommentOpen', + fix: + closeDecoration + ? undefined + : (fixer) => fixer.insertTextBefore(afterToken, '\n') }) } else { if (value.loc.end.line === afterToken.loc.start.line) { diff --git ORI/eslint-plugin-vue/lib/rules/html-comment-content-spacing.js ALT/eslint-plugin-vue/lib/rules/html-comment-content-spacing.js index b4f3167..5cd599a 100644 --- ORI/eslint-plugin-vue/lib/rules/html-comment-content-spacing.js +++ ALT/eslint-plugin-vue/lib/rules/html-comment-content-spacing.js @@ -94,12 +94,14 @@ module.exports = { start: beforeToken.loc.end, end: value.loc.start }, - messageId: openDecoration - ? 'expectedAfterExceptionBlock' - : 'expectedAfterHTMLCommentOpen', - fix: openDecoration - ? undefined - : (fixer) => fixer.insertTextAfter(beforeToken, ' ') + messageId: + openDecoration + ? 'expectedAfterExceptionBlock' + : 'expectedAfterHTMLCommentOpen', + fix: + openDecoration + ? undefined + : (fixer) => fixer.insertTextAfter(beforeToken, ' ') }) } else { if (openDecoration) { @@ -148,12 +150,14 @@ module.exports = { start: value.loc.end, end: afterToken.loc.start }, - messageId: closeDecoration - ? 'expectedBeforeExceptionBlock' - : 'expectedBeforeHTMLCommentOpen', - fix: closeDecoration - ? undefined - : (fixer) => fixer.insertTextBefore(afterToken, ' ') + messageId: + closeDecoration + ? 'expectedBeforeExceptionBlock' + : 'expectedBeforeHTMLCommentOpen', + fix: + closeDecoration + ? undefined + : (fixer) => fixer.insertTextBefore(afterToken, ' ') }) } else { if (closeDecoration) { diff --git ORI/eslint-plugin-vue/lib/rules/html-comment-indent.js ALT/eslint-plugin-vue/lib/rules/html-comment-indent.js index d5992b5..ae88d31 100644 --- ORI/eslint-plugin-vue/lib/rules/html-comment-indent.js +++ ALT/eslint-plugin-vue/lib/rules/html-comment-indent.js @@ -201,9 +201,10 @@ module.exports = { start: { line, column: 0 }, end: { line, column: actualIndentText.length } }, - messageId: actualIndentText - ? 'unexpectedBaseIndentation' - : 'missingBaseIndentation', + messageId: + actualIndentText + ? 'unexpectedBaseIndentation' + : 'missingBaseIndentation', data: { expected: toDisplay(baseIndentText), actual: toDisplay(actualIndentText.slice(0, baseIndentText.length)) @@ -243,9 +244,10 @@ module.exports = { start: { line, column: baseIndentText.length }, end: { line, column: actualIndentText.length } }, - messageId: baseIndentText - ? 'unexpectedRelativeIndentation' - : 'unexpectedIndentation', + messageId: + baseIndentText + ? 'unexpectedRelativeIndentation' + : 'unexpectedIndentation', data: { expected: toDisplay(expectedOffsetIndentText, options.indentChar), actual: toDisplay(actualOffsetIndentText, options.indentChar) diff --git ORI/eslint-plugin-vue/lib/rules/match-component-file-name.js ALT/eslint-plugin-vue/lib/rules/match-component-file-name.js index 8428516..966ae41 100644 --- ORI/eslint-plugin-vue/lib/rules/match-component-file-name.js +++ ALT/eslint-plugin-vue/lib/rules/match-component-file-name.js @@ -50,9 +50,8 @@ module.exports = { const options = context.options[0] const shouldMatchCase = (options && options.shouldMatchCase) || false const extensionsArray = options && options.extensions - const allowedExtensions = Array.isArray(extensionsArray) - ? extensionsArray - : ['jsx'] + const allowedExtensions = + Array.isArray(extensionsArray) ? extensionsArray : ['jsx'] const extension = path.extname(context.getFilename()) const filename = path.basename(context.getFilename(), extension) diff --git ORI/eslint-plugin-vue/lib/rules/no-irregular-whitespace.js ALT/eslint-plugin-vue/lib/rules/no-irregular-whitespace.js index 1cfbd61..40a162f 100644 --- ORI/eslint-plugin-vue/lib/rules/no-irregular-whitespace.js +++ ALT/eslint-plugin-vue/lib/rules/no-irregular-whitespace.js @@ -232,9 +232,8 @@ module.exports = { // Removes errors that occur outside script and template const [scriptStart, scriptEnd] = node.range - const [templateStart, templateEnd] = templateBody - ? templateBody.range - : [0, 0] + const [templateStart, templateEnd] = + templateBody ? templateBody.range : [0, 0] errorIndexes = errorIndexes.filter( (errorIndex) => (scriptStart <= errorIndex && errorIndex < scriptEnd) || diff --git ORI/eslint-plugin-vue/lib/rules/no-parsing-error.js ALT/eslint-plugin-vue/lib/rules/no-parsing-error.js index 9a6b4f8..c111a4c 100644 --- ORI/eslint-plugin-vue/lib/rules/no-parsing-error.js +++ ALT/eslint-plugin-vue/lib/rules/no-parsing-error.js @@ -99,9 +99,10 @@ module.exports = { loc: { line: error.lineNumber, column: error.column }, message: 'Parsing error: {{message}}.', data: { - message: error.message.endsWith('.') - ? error.message.slice(0, -1) - : error.message + message: + error.message.endsWith('.') + ? error.message.slice(0, -1) + : error.message } }) } diff --git ORI/eslint-plugin-vue/lib/rules/no-reserved-component-names.js ALT/eslint-plugin-vue/lib/rules/no-reserved-component-names.js index e32e182..1ba998a 100644 --- ORI/eslint-plugin-vue/lib/rules/no-reserved-component-names.js +++ ALT/eslint-plugin-vue/lib/rules/no-reserved-component-names.js @@ -133,13 +133,14 @@ module.exports = { function report(node, name) { context.report({ node, - messageId: RESERVED_NAMES_IN_HTML.has(name) - ? 'reservedInHtml' - : RESERVED_NAMES_IN_VUE.has(name) - ? 'reservedInVue' - : RESERVED_NAMES_IN_VUE3.has(name) - ? 'reservedInVue3' - : 'reserved', + messageId: + RESERVED_NAMES_IN_HTML.has(name) + ? 'reservedInHtml' + : RESERVED_NAMES_IN_VUE.has(name) + ? 'reservedInVue' + : RESERVED_NAMES_IN_VUE3.has(name) + ? 'reservedInVue3' + : 'reserved', data: { name } diff --git ORI/eslint-plugin-vue/lib/rules/no-restricted-call-after-await.js ALT/eslint-plugin-vue/lib/rules/no-restricted-call-after-await.js index 523d6af..1838311 100644 --- ORI/eslint-plugin-vue/lib/rules/no-restricted-call-after-await.js +++ ALT/eslint-plugin-vue/lib/rules/no-restricted-call-after-await.js @@ -158,9 +158,10 @@ module.exports = { /** @type {TraceKind & TraceMap} */ const mod = traceMap[module] let local = mod - const paths = Array.isArray(option.path) - ? option.path - : [option.path || 'default'] + const paths = + Array.isArray(option.path) + ? option.path + : [option.path || 'default'] for (const path of paths) { local = local[path] || (local[path] = {}) } diff --git ORI/eslint-plugin-vue/lib/rules/no-restricted-custom-event.js ALT/eslint-plugin-vue/lib/rules/no-restricted-custom-event.js index 22d128c..04cd1f4 100644 --- ORI/eslint-plugin-vue/lib/rules/no-restricted-custom-event.js +++ ALT/eslint-plugin-vue/lib/rules/no-restricted-custom-event.js @@ -147,27 +147,28 @@ module.exports = { node: nameLiteralNode, messageId: 'restrictedEvent', data: { message }, - suggest: option.suggest - ? [ - { - fix(fixer) { - const sourceCode = context.getSourceCode() - return fixer.replaceText( - nameLiteralNode, - `${ - sourceCode.text[nameLiteralNode.range[0]] - }${JSON.stringify(option.suggest) - .slice(1, -1) - .replace(/'/gu, "\\'")}${ - sourceCode.text[nameLiteralNode.range[1] - 1] - }` - ) - }, - messageId: 'instead', - data: { suggest: option.suggest } - } - ] - : [] + suggest: + option.suggest + ? [ + { + fix(fixer) { + const sourceCode = context.getSourceCode() + return fixer.replaceText( + nameLiteralNode, + `${ + sourceCode.text[nameLiteralNode.range[0]] + }${JSON.stringify(option.suggest) + .slice(1, -1) + .replace(/'/gu, "\\'")}${ + sourceCode.text[nameLiteralNode.range[1] - 1] + }` + ) + }, + messageId: 'instead', + data: { suggest: option.suggest } + } + ] + : [] }) break } diff --git ORI/eslint-plugin-vue/lib/rules/no-restricted-props.js ALT/eslint-plugin-vue/lib/rules/no-restricted-props.js index 6834df5..a49a0db 100644 --- ORI/eslint-plugin-vue/lib/rules/no-restricted-props.js +++ ALT/eslint-plugin-vue/lib/rules/no-restricted-props.js @@ -156,9 +156,10 @@ function createSuggest(node, option, withDefault) { if (node.type === 'Literal' || node.type === 'TemplateLiteral') { replaceText = JSON.stringify(option.suggest) } else if (node.type === 'Identifier') { - replaceText = /^[a-z]\w*$/iu.exec(option.suggest) - ? option.suggest - : JSON.stringify(option.suggest) + replaceText = + /^[a-z]\w*$/iu.exec(option.suggest) + ? option.suggest + : JSON.stringify(option.suggest) } else { return [] } diff --git ORI/eslint-plugin-vue/lib/rules/no-restricted-static-attribute.js ALT/eslint-plugin-vue/lib/rules/no-restricted-static-attribute.js index 24cab62..6402eb6 100644 --- ORI/eslint-plugin-vue/lib/rules/no-restricted-static-attribute.js +++ ALT/eslint-plugin-vue/lib/rules/no-restricted-static-attribute.js @@ -148,11 +148,12 @@ module.exports = { */ function defaultMessage(node, option) { const key = node.key.rawName - const value = !option.useValue - ? '' - : node.value == null - ? '` set to `true' - : `="${node.value.value}"` + const value = + !option.useValue + ? '' + : node.value == null + ? '` set to `true' + : `="${node.value.value}"` let on = '' if (option.useElement) { diff --git ORI/eslint-plugin-vue/lib/rules/no-restricted-v-bind.js ALT/eslint-plugin-vue/lib/rules/no-restricted-v-bind.js index 3cc46e7..7c33776 100644 --- ORI/eslint-plugin-vue/lib/rules/no-restricted-v-bind.js +++ ALT/eslint-plugin-vue/lib/rules/no-restricted-v-bind.js @@ -170,9 +170,8 @@ module.exports = { key.argument != null && key.argument.type === 'VIdentifier' ? `:${key.argument.rawName}` : '' - const mod = option.modifiers.length - ? `.${option.modifiers.join('.')}` - : '' + const mod = + option.modifiers.length ? `.${option.modifiers.join('.')}` : '' let on = '' if (option.useElement) { on = ` on \`<${key.parent.parent.parent.rawName}>\`` diff --git ORI/eslint-plugin-vue/lib/rules/no-undef-properties.js ALT/eslint-plugin-vue/lib/rules/no-undef-properties.js index 4246f77..f554437 100644 --- ORI/eslint-plugin-vue/lib/rules/no-undef-properties.js +++ ALT/eslint-plugin-vue/lib/rules/no-undef-properties.js @@ -153,9 +153,8 @@ module.exports = { return } for (const [refName, { nodes }] of references.allProperties()) { - const referencePathName = pathName - ? `${pathName}.${refName}` - : refName + const referencePathName = + pathName ? `${pathName}.${refName}` : refName const prop = defineProperties.get && defineProperties.get(refName) if (prop) { diff --git ORI/eslint-plugin-vue/lib/rules/no-unregistered-components.js ALT/eslint-plugin-vue/lib/rules/no-unregistered-components.js index 5cc22a9..0171658 100644 --- ORI/eslint-plugin-vue/lib/rules/no-unregistered-components.js +++ ALT/eslint-plugin-vue/lib/rules/no-unregistered-components.js @@ -116,9 +116,10 @@ module.exports = { !node.value // `` ) return - const value = node.value.value.startsWith('vue:') // Usage on native elements 3.1+ - ? node.value.value.slice(4) - : node.value.value + const value = + node.value.value.startsWith('vue:') // Usage on native elements 3.1+ + ? node.value.value.slice(4) + : node.value.value if (utils.isHtmlWellKnownElementName(value)) return usedComponentNodes.push({ node, name: value }) }, diff --git ORI/eslint-plugin-vue/lib/rules/no-unused-components.js ALT/eslint-plugin-vue/lib/rules/no-unused-components.js index 8497dd9..e7264b9 100644 --- ORI/eslint-plugin-vue/lib/rules/no-unused-components.js +++ ALT/eslint-plugin-vue/lib/rules/no-unused-components.js @@ -88,9 +88,10 @@ module.exports = { if (!node.value) { return } - const value = node.value.value.startsWith('vue:') // Usage on native elements 3.1+ - ? node.value.value.slice(4) - : node.value.value + const value = + node.value.value.startsWith('vue:') // Usage on native elements 3.1+ + ? node.value.value.slice(4) + : node.value.value usedComponents.add(value) }, /** @param {VElement} node */ diff --git ORI/eslint-plugin-vue/lib/rules/order-in-components.js ALT/eslint-plugin-vue/lib/rules/order-in-components.js index 83558aa..99594c3 100644 --- ORI/eslint-plugin-vue/lib/rules/order-in-components.js +++ ALT/eslint-plugin-vue/lib/rules/order-in-components.js @@ -313,13 +313,11 @@ module.exports = { const beforeComma = sourceCode.getTokenBefore(propertyNode) const codeStart = beforeComma.range[1] // to include comments - const codeEnd = hasAfterComma - ? afterComma.range[1] - : propertyNode.range[1] + const codeEnd = + hasAfterComma ? afterComma.range[1] : propertyNode.range[1] - const removeStart = hasAfterComma - ? codeStart - : beforeComma.range[0] + const removeStart = + hasAfterComma ? codeStart : beforeComma.range[0] yield fixer.removeRange([removeStart, codeEnd]) const propertyCode = diff --git ORI/eslint-plugin-vue/lib/rules/return-in-emits-validator.js ALT/eslint-plugin-vue/lib/rules/return-in-emits-validator.js index 03d197b..49efc6d 100644 --- ORI/eslint-plugin-vue/lib/rules/return-in-emits-validator.js +++ ALT/eslint-plugin-vue/lib/rules/return-in-emits-validator.js @@ -135,9 +135,10 @@ module.exports = { if (emits) { context.report({ node, - message: scopeStack.hasReturnValue - ? 'Expected to return a true value in "{{name}}" emits validator.' - : 'Expected to return a boolean value in "{{name}}" emits validator.', + message: + scopeStack.hasReturnValue + ? 'Expected to return a true value in "{{name}}" emits validator.' + : 'Expected to return a boolean value in "{{name}}" emits validator.', data: { name: emits.emitName || 'Unknown' } diff --git ORI/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js ALT/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js index 4cfe209..202cdbb 100644 --- ORI/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js +++ ALT/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js @@ -74,11 +74,8 @@ module.exports = { (attr.key.name.name === 'slot-scope' || attr.key.name.name === 'scope') ) - const nameArgument = slotName - ? vBind - ? `:[${slotName}]` - : `:${slotName}` - : '' + const nameArgument = + slotName ? (vBind ? `:[${slotName}]` : `:${slotName}`) : '' const scopeValue = scopeAttr && scopeAttr.value ? `=${sourceCode.getText(scopeAttr.value)}` diff --git ORI/eslint-plugin-vue/lib/rules/this-in-template.js ALT/eslint-plugin-vue/lib/rules/this-in-template.js index 671ac56..795fcf7 100644 --- ORI/eslint-plugin-vue/lib/rules/this-in-template.js +++ ALT/eslint-plugin-vue/lib/rules/this-in-template.js @@ -53,9 +53,10 @@ module.exports = { VElement(node) { scopeStack = { parent: scopeStack, - nodes: scopeStack - ? scopeStack.nodes.slice() // make copy - : [] + nodes: + scopeStack + ? scopeStack.nodes.slice() // make copy + : [] } if (node.variables) { for (const variable of node.variables) { diff --git ORI/eslint-plugin-vue/lib/rules/use-v-on-exact.js ALT/eslint-plugin-vue/lib/rules/use-v-on-exact.js index 0a17906..2293865 100644 --- ORI/eslint-plugin-vue/lib/rules/use-v-on-exact.js +++ ALT/eslint-plugin-vue/lib/rules/use-v-on-exact.js @@ -38,9 +38,8 @@ const GLOBAL_MODIFIERS = new Set([ */ function getEventDirectives(startTag, sourceCode) { return utils.getDirectives(startTag, 'on').map((attribute) => ({ - name: attribute.key.argument - ? sourceCode.getText(attribute.key.argument) - : '', + name: + attribute.key.argument ? sourceCode.getText(attribute.key.argument) : '', node: attribute.key, modifiers: attribute.key.modifiers.map((modifier) => modifier.name) })) diff --git ORI/eslint-plugin-vue/lib/rules/v-bind-style.js ALT/eslint-plugin-vue/lib/rules/v-bind-style.js index e6878a3..f08a99e 100644 --- ORI/eslint-plugin-vue/lib/rules/v-bind-style.js +++ ALT/eslint-plugin-vue/lib/rules/v-bind-style.js @@ -44,11 +44,12 @@ module.exports = { context.report({ node, loc: node.loc, - message: preferShorthand - ? "Unexpected 'v-bind' before ':'." - : shorthandProp - ? "Expected 'v-bind:' instead of '.'." - : /* otherwise */ "Expected 'v-bind' before ':'.", + message: + preferShorthand + ? "Unexpected 'v-bind' before ':'." + : shorthandProp + ? "Expected 'v-bind:' instead of '.'." + : /* otherwise */ "Expected 'v-bind' before ':'.", *fix(fixer) { if (preferShorthand) { yield fixer.remove(node.key.name) diff --git ORI/eslint-plugin-vue/lib/rules/v-on-event-hyphenation.js ALT/eslint-plugin-vue/lib/rules/v-on-event-hyphenation.js index 16ea753..75bc901 100644 --- ORI/eslint-plugin-vue/lib/rules/v-on-event-hyphenation.js +++ ALT/eslint-plugin-vue/lib/rules/v-on-event-hyphenation.js @@ -64,9 +64,10 @@ module.exports = { context.report({ node: node.key, loc: node.loc, - message: useHyphenated - ? "v-on event '{{text}}' must be hyphenated." - : "v-on event '{{text}}' can't be hyphenated.", + message: + useHyphenated + ? "v-on event '{{text}}' must be hyphenated." + : "v-on event '{{text}}' can't be hyphenated.", data: { text }, diff --git ORI/eslint-plugin-vue/lib/rules/v-on-function-call.js ALT/eslint-plugin-vue/lib/rules/v-on-function-call.js index 90da5ed..b892c27 100644 --- ORI/eslint-plugin-vue/lib/rules/v-on-function-call.js +++ ALT/eslint-plugin-vue/lib/rules/v-on-function-call.js @@ -164,20 +164,24 @@ module.exports = { node: expression, message: "Method calls without arguments inside of 'v-on' directives must not have parentheses.", - fix: hasComment - ? null /* The comment is included and cannot be fixed. */ - : (fixer) => { - /** @type {Range} */ - const range = - leftQuote && rightQuote - ? [leftQuote.range[1], rightQuote.range[0]] - : [tokens[0].range[0], tokens[tokens.length - 1].range[1]] - - return fixer.replaceTextRange( - range, - context.getSourceCode().getText(expression.callee) - ) - } + fix: + hasComment + ? null /* The comment is included and cannot be fixed. */ + : (fixer) => { + /** @type {Range} */ + const range = + leftQuote && rightQuote + ? [leftQuote.range[1], rightQuote.range[0]] + : [ + tokens[0].range[0], + tokens[tokens.length - 1].range[1] + ] + + return fixer.replaceTextRange( + range, + context.getSourceCode().getText(expression.callee) + ) + } }) } }, diff --git ORI/eslint-plugin-vue/lib/rules/v-on-style.js ALT/eslint-plugin-vue/lib/rules/v-on-style.js index 4649aac..6f3ed40 100644 --- ORI/eslint-plugin-vue/lib/rules/v-on-style.js +++ ALT/eslint-plugin-vue/lib/rules/v-on-style.js @@ -44,9 +44,10 @@ module.exports = { context.report({ node, loc: node.loc, - message: preferShorthand - ? "Expected '@' instead of 'v-on:'." - : "Expected 'v-on:' instead of '@'.", + message: + preferShorthand + ? "Expected '@' instead of 'v-on:'." + : "Expected 'v-on:' instead of '@'.", fix: (fixer) => preferShorthand ? fixer.replaceTextRange([pos, pos + 5], '@') diff --git ORI/eslint-plugin-vue/lib/utils/html-comments.js ALT/eslint-plugin-vue/lib/utils/html-comments.js index ec957af..21dc83e 100644 --- ORI/eslint-plugin-vue/lib/utils/html-comments.js +++ ALT/eslint-plugin-vue/lib/utils/html-comments.js @@ -180,19 +180,20 @@ function defineParser(sourceCode, config) { /** @type {HTMLCommentOpen} */ const open = createToken(TYPE_HTML_COMMENT_OPEN, '') diff --git ORI/eslint-plugin-vue/lib/utils/indent-common.js ALT/eslint-plugin-vue/lib/utils/indent-common.js index 39ef586..44bcc43 100644 --- ORI/eslint-plugin-vue/lib/utils/indent-common.js +++ ALT/eslint-plugin-vue/lib/utils/indent-common.js @@ -913,9 +913,10 @@ module.exports.defineVisitor = function create( // Validate. for (const comment of comments) { const commentExpectedIndents = getExpectedIndents([comment]) - const commentExpectedIndent = commentExpectedIndents - ? commentExpectedIndents.expectedIndent - : commentOptionalExpectedIndents[0] + const commentExpectedIndent = + commentExpectedIndents + ? commentExpectedIndents.expectedIndent + : commentOptionalExpectedIndents[0] validateCore( comment, @@ -1276,9 +1277,10 @@ module.exports.defineVisitor = function create( const leftToken = tokenStore.getTokenAfter(whileToken) const testToken = tokenStore.getTokenAfter(leftToken) const lastToken = tokenStore.getLastToken(node) - const rightToken = isSemicolonToken(lastToken) - ? tokenStore.getTokenBefore(lastToken) - : lastToken + const rightToken = + isSemicolonToken(lastToken) + ? tokenStore.getTokenBefore(lastToken) + : lastToken processMaybeBlock(node.body, doToken) setOffset(whileToken, 0, doToken) @@ -1634,13 +1636,14 @@ module.exports.defineVisitor = function create( const newToken = tokenStore.getFirstToken(node) const calleeToken = tokenStore.getTokenAfter(newToken) const rightToken = tokenStore.getLastToken(node) - const leftToken = isClosingParenToken(rightToken) - ? tokenStore.getFirstTokenBetween( - node.callee, - rightToken, - isOpeningParenToken - ) - : null + const leftToken = + isClosingParenToken(rightToken) + ? tokenStore.getFirstTokenBetween( + node.callee, + rightToken, + isOpeningParenToken + ) + : null setOffset(calleeToken, 1, newToken) if (leftToken != null) { @@ -1875,9 +1878,8 @@ module.exports.defineVisitor = function create( firstToken != null && firstToken.type === 'Punctuator' && firstToken.value === ' Githubissues.
  • Githubissues is a development platform for aggregating issues.