prettier / prettier-regression-testing

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

pr 10222 / 3 #29

Closed thorn0 closed 3 years ago

thorn0 commented 3 years ago

run #10222

github-actions[bot] commented 3 years ago

prettier/prettier#10222 VS prettier/prettier@main

Diff (3023 lines) ```diff diff --git ORI/babel/packages/babel-core/src/config/config-chain.js ALT/babel/packages/babel-core/src/config/config-chain.js index 350111a1a..6e586eeaf 100644 --- ORI/babel/packages/babel-core/src/config/config-chain.js +++ ALT/babel/packages/babel-core/src/config/config-chain.js @@ -76,17 +76,15 @@ export function* buildPresetChain( }; } -export const buildPresetChainWalker: ( - arg: PresetInstance, - context: *, -) => * = makeChainWalker({ - root: preset => loadPresetDescriptors(preset), - env: (preset, envName) => loadPresetEnvDescriptors(preset)(envName), - overrides: (preset, index) => loadPresetOverridesDescriptors(preset)(index), - overridesEnv: (preset, index, envName) => - loadPresetOverridesEnvDescriptors(preset)(index)(envName), - createLogger: () => () => {}, // Currently we don't support logging how preset is expanded -}); +export const buildPresetChainWalker: (arg: PresetInstance, context: *) => * = + makeChainWalker({ + root: preset => loadPresetDescriptors(preset), + env: (preset, envName) => loadPresetEnvDescriptors(preset)(envName), + overrides: (preset, index) => loadPresetOverridesDescriptors(preset)(index), + overridesEnv: (preset, index, envName) => + loadPresetOverridesEnvDescriptors(preset)(index)(envName), + createLogger: () => () => {}, // Currently we don't support logging how preset is expanded + }); const loadPresetDescriptors = makeWeakCacheSync((preset: PresetInstance) => buildRootDescriptors(preset, preset.alias, createUncachedDescriptors), ); @@ -705,10 +703,8 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions { function dedupDescriptors( items: Array, ): Array { - const map: Map< - Function, - Map, - > = new Map(); + const map: Map> = + new Map(); const descriptors = []; diff --git ORI/babel/packages/babel-core/src/config/files/plugins.js ALT/babel/packages/babel-core/src/config/files/plugins.js index 298843e2d..fde98cfd3 100644 --- ORI/babel/packages/babel-core/src/config/files/plugins.js +++ ALT/babel/packages/babel-core/src/config/files/plugins.js @@ -14,8 +14,10 @@ const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/; const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/; const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/; const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/; -const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/; -const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/; +const OTHER_PLUGIN_ORG_RE = + /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/; +const OTHER_PRESET_ORG_RE = + /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/; const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/; export function resolvePlugin(name: string, dirname: string): string | null { diff --git ORI/babel/packages/babel-core/src/config/validation/options.js ALT/babel/packages/babel-core/src/config/validation/options.js index 27caf3bcc..529d6606d 100644 --- ORI/babel/packages/babel-core/src/config/validation/options.js +++ ALT/babel/packages/babel-core/src/config/validation/options.js @@ -369,10 +369,8 @@ function throwUnknownError(loc: OptionPath) { const key = loc.name; if (removed[key]) { - const { - message, - version = 5, - }: { message: string, version?: number } = removed[key]; + const { message, version = 5 }: { message: string, version?: number } = + removed[key]; throw new Error( `Using removed Babel ${version} option: ${msg(loc)} - ${message}`, diff --git ORI/babel/packages/babel-core/src/transformation/normalize-file.js ALT/babel/packages/babel-core/src/transformation/normalize-file.js index aca84e1e4..8734534cc 100644 --- ORI/babel/packages/babel-core/src/transformation/normalize-file.js +++ ALT/babel/packages/babel-core/src/transformation/normalize-file.js @@ -98,8 +98,10 @@ export default function* normalizeFile( // but without // or /* at the beginning of the comment. // eslint-disable-next-line max-len -const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/; -const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+)[ \t]*$/; +const INLINE_SOURCEMAP_REGEX = + /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/; +const EXTERNAL_SOURCEMAP_REGEX = + /^[@#][ \t]+sourceMappingURL=([^\s'"`]+)[ \t]*$/; function extractCommentsFromList(regex, comments, lastComment) { if (comments) { diff --git ORI/babel/packages/babel-core/test/api.js ALT/babel/packages/babel-core/test/api.js index d715b6386..a8aed41cc 100644 --- ORI/babel/packages/babel-core/test/api.js +++ ALT/babel/packages/babel-core/test/api.js @@ -308,9 +308,8 @@ describe("api", function () { new Plugin({ visitor: { Function: function (path) { - const alias = path.scope - .getProgramParent() - .path.get("body")[0].node; + const alias = + path.scope.getProgramParent().path.get("body")[0].node; if (!babel.types.isTypeAlias(alias)) return; // In case of `passPerPreset` being `false`, the diff --git ORI/babel/packages/babel-core/test/config-chain.js ALT/babel/packages/babel-core/test/config-chain.js index 8de2bc99d..4b3c1d10b 100644 --- ORI/babel/packages/babel-core/test/config-chain.js +++ ALT/babel/packages/babel-core/test/config-chain.js @@ -94,7 +94,8 @@ async function loadOptionsAsyncInSpawedProcess({ filename, cwd }) { }, ); - const EXPERIMENTAL_WARNING = /\(node:\d+\) ExperimentalWarning: The ESM module loader is experimental\./; + const EXPERIMENTAL_WARNING = + /\(node:\d+\) ExperimentalWarning: The ESM module loader is experimental\./; if (stderr.replace(EXPERIMENTAL_WARNING, "").trim()) { throw new Error( diff --git ORI/babel/packages/babel-helper-create-class-features-plugin/src/fields.js ALT/babel/packages/babel-helper-create-class-features-plugin/src/fields.js index aca3cfa75..08fb1f6e0 100644 --- ORI/babel/packages/babel-helper-create-class-features-plugin/src/fields.js +++ ALT/babel/packages/babel-helper-create-class-features-plugin/src/fields.js @@ -200,14 +200,8 @@ const privateNameHandlerSpec = { get(member) { const { classRef, privateNamesMap, file } = this; const { name } = member.node.property.id; - const { - id, - static: isStatic, - method: isMethod, - methodId, - getId, - setId, - } = privateNamesMap.get(name); + const { id, static: isStatic, method: isMethod, methodId, getId, setId } = + privateNamesMap.get(name); const isAccessor = getId || setId; if (isStatic) { @@ -264,13 +258,8 @@ const privateNameHandlerSpec = { set(member, value) { const { classRef, privateNamesMap, file } = this; const { name } = member.node.property.id; - const { - id, - static: isStatic, - method: isMethod, - setId, - getId, - } = privateNamesMap.get(name); + const { id, static: isStatic, method: isMethod, setId, getId } = + privateNamesMap.get(name); const isAccessor = getId || setId; if (isStatic) { diff --git ORI/babel/packages/babel-helper-module-transforms/src/index.js ALT/babel/packages/babel-helper-module-transforms/src/index.js index c1aff14c1..77b6845c0 100644 --- ORI/babel/packages/babel-helper-module-transforms/src/index.js +++ ALT/babel/packages/babel-helper-module-transforms/src/index.js @@ -214,10 +214,8 @@ const buildReexportsFromMeta = ( true, ); } else { - NAMESPACE_IMPORT = NAMESPACE_IMPORT = t.memberExpression( - t.cloneNode(namespace), - t.identifier(importName), - ); + NAMESPACE_IMPORT = NAMESPACE_IMPORT = + t.memberExpression(t.cloneNode(namespace), t.identifier(importName)); } const astNodes = { EXPORTS: meta.exportName, diff --git ORI/babel/packages/babel-helper-module-transforms/src/rewrite-live-references.js ALT/babel/packages/babel-helper-module-transforms/src/rewrite-live-references.js index 4f31fd926..706d84efc 100644 --- ORI/babel/packages/babel-helper-module-transforms/src/rewrite-live-references.js +++ ALT/babel/packages/babel-helper-module-transforms/src/rewrite-live-references.js @@ -165,13 +165,8 @@ const buildImportThrow = localName => { const rewriteReferencesVisitor = { ReferencedIdentifier(path) { - const { - seen, - buildImportReference, - scope, - imported, - requeueInParent, - } = this; + const { seen, buildImportReference, scope, imported, requeueInParent } = + this; if (seen.has(path.node)) return; seen.add(path.node); diff --git ORI/babel/packages/babel-parser/src/parser/statement.js ALT/babel/packages/babel-parser/src/parser/statement.js index 5827e5154..a1b0e5824 100644 --- ORI/babel/packages/babel-parser/src/parser/statement.js +++ ALT/babel/packages/babel-parser/src/parser/statement.js @@ -316,9 +316,8 @@ export default class StatementParser extends ExpressionParser { } takeDecorators(node: N.HasDecorators): void { - const decorators = this.state.decoratorStack[ - this.state.decoratorStack.length - 1 - ]; + const decorators = + this.state.decoratorStack[this.state.decoratorStack.length - 1]; if (decorators.length) { node.decorators = decorators; this.resetStartLocationFromNode(node, decorators[0]); @@ -331,9 +330,8 @@ export default class StatementParser extends ExpressionParser { } parseDecorators(allowExport?: boolean): void { - const currentContextDecorators = this.state.decoratorStack[ - this.state.decoratorStack.length - 1 - ]; + const currentContextDecorators = + this.state.decoratorStack[this.state.decoratorStack.length - 1]; while (this.match(tt.at)) { const decorator = this.parseDecorator(); currentContextDecorators.push(decorator); @@ -2010,9 +2008,8 @@ export default class StatementParser extends ExpressionParser { } } - const currentContextDecorators = this.state.decoratorStack[ - this.state.decoratorStack.length - 1 - ]; + const currentContextDecorators = + this.state.decoratorStack[this.state.decoratorStack.length - 1]; // If node.declaration is a class, it will take all decorators in the current context. // Thus we should throw if we see non-empty decorators here. if (currentContextDecorators.length) { diff --git ORI/babel/packages/babel-parser/src/plugins/flow.js ALT/babel/packages/babel-parser/src/plugins/flow.js index 0e00291fc..db810370f 100644 --- ORI/babel/packages/babel-parser/src/plugins/flow.js +++ ALT/babel/packages/babel-parser/src/plugins/flow.js @@ -2962,7 +2962,8 @@ export default (superClass: Class): Class => node.callee = base; const result = this.tryParse(() => { - node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew(); + node.typeArguments = + this.flowParseTypeParameterInstantiationCallOrNew(); this.expect(tt.parenL); node.arguments = this.parseCallExpressionArguments(tt.parenR, false); if (subscriptState.optionalChainMember) node.optional = false; diff --git ORI/babel/packages/babel-parser/src/tokenizer/context.js ALT/babel/packages/babel-parser/src/tokenizer/context.js index 5581e6b05..942f83b82 100644 --- ORI/babel/packages/babel-parser/src/tokenizer/context.js +++ ALT/babel/packages/babel-parser/src/tokenizer/context.js @@ -49,19 +49,23 @@ export const types: { // When `=>` is eaten, the context update of `yield` is executed, however, // `this.prodParam` still has `[Yield]` production because it is not yet updated -tt.parenR.updateContext = tt.braceR.updateContext = function () { - if (this.state.context.length === 1) { - this.state.exprAllowed = true; - return; - } +tt.parenR.updateContext = tt.braceR.updateContext = + function () { + if (this.state.context.length === 1) { + this.state.exprAllowed = true; + return; + } - let out = this.state.context.pop(); - if (out === types.braceStatement && this.curContext().token === "function") { - out = this.state.context.pop(); - } + let out = this.state.context.pop(); + if ( + out === types.braceStatement && + this.curContext().token === "function" + ) { + out = this.state.context.pop(); + } - this.state.exprAllowed = !out.isExpr; -}; + this.state.exprAllowed = !out.isExpr; + }; tt.name.updateContext = function (prevType) { let allowed = false; @@ -110,24 +114,25 @@ tt.incDec.updateContext = function () { // tokExprAllowed stays unchanged }; -tt._function.updateContext = tt._class.updateContext = function (prevType) { - if ( - prevType.beforeExpr && - prevType !== tt.semi && - prevType !== tt._else && - !(prevType === tt._return && this.hasPrecedingLineBreak()) && - !( - (prevType === tt.colon || prevType === tt.braceL) && - this.curContext() === types.b_stat - ) - ) { - this.state.context.push(types.functionExpression); - } else { - this.state.context.push(types.functionStatement); - } +tt._function.updateContext = tt._class.updateContext = + function (prevType) { + if ( + prevType.beforeExpr && + prevType !== tt.semi && + prevType !== tt._else && + !(prevType === tt._return && this.hasPrecedingLineBreak()) && + !( + (prevType === tt.colon || prevType === tt.braceL) && + this.curContext() === types.b_stat + ) + ) { + this.state.context.push(types.functionExpression); + } else { + this.state.context.push(types.functionStatement); + } - this.state.exprAllowed = false; -}; + this.state.exprAllowed = false; + }; tt.backQuote.updateContext = function () { if (this.curContext() === types.template) { diff --git ORI/babel/packages/babel-parser/src/types.js ALT/babel/packages/babel-parser/src/types.js index d5a28729d..b75520a79 100644 --- ORI/babel/packages/babel-parser/src/types.js +++ ALT/babel/packages/babel-parser/src/types.js @@ -1137,9 +1137,10 @@ export type TsSignatureDeclarationOrIndexSignatureBase = NodeBase & { typeAnnotation: ?TsTypeAnnotation, }; -export type TsSignatureDeclarationBase = TsSignatureDeclarationOrIndexSignatureBase & { - typeParameters: ?TsTypeParameterDeclaration, -}; +export type TsSignatureDeclarationBase = + TsSignatureDeclarationOrIndexSignatureBase & { + typeParameters: ?TsTypeParameterDeclaration, + }; // ================ // TypeScript type members (for type literal / interface / class) diff --git ORI/babel/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js ALT/babel/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js index 34198840e..e19a77552 100644 --- ORI/babel/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js +++ ALT/babel/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js @@ -48,9 +48,8 @@ function applyEnsureOrdering(path) { identDecorators .map(decorator => { const expression = decorator.expression; - const id = (decorator.expression = path.scope.generateDeclaredUidIdentifier( - "dec", - )); + const id = (decorator.expression = + path.scope.generateDeclaredUidIdentifier("dec")); return t.assignmentExpression("=", id, expression); }) .concat([path.node]), diff --git ORI/babel/packages/babel-plugin-proposal-object-rest-spread/src/index.js ALT/babel/packages/babel-plugin-proposal-object-rest-spread/src/index.js index e1f9b7d51..387e2634c 100644 --- ORI/babel/packages/babel-plugin-proposal-object-rest-spread/src/index.js +++ ALT/babel/packages/babel-plugin-proposal-object-rest-spread/src/index.js @@ -357,11 +357,8 @@ export default declare((api, opts) => { path.isObjectPattern(), ); - const [ - impureComputedPropertyDeclarators, - argument, - callExpression, - ] = createObjectSpread(objectPatternPath, file, ref); + const [impureComputedPropertyDeclarators, argument, callExpression] = + createObjectSpread(objectPatternPath, file, ref); if (loose) { removeUnusedExcludedKeys(objectPatternPath); @@ -440,11 +437,8 @@ export default declare((api, opts) => { ]), ); - const [ - impureComputedPropertyDeclarators, - argument, - callExpression, - ] = createObjectSpread(leftPath, file, t.identifier(refName)); + const [impureComputedPropertyDeclarators, argument, callExpression] = + createObjectSpread(leftPath, file, t.identifier(refName)); if (impureComputedPropertyDeclarators.length > 0) { nodes.push( diff --git ORI/babel/packages/babel-plugin-transform-destructuring/src/index.js ALT/babel/packages/babel-plugin-transform-destructuring/src/index.js index cca55d21b..47dbd1ed3 100644 --- ORI/babel/packages/babel-plugin-transform-destructuring/src/index.js +++ ALT/babel/packages/babel-plugin-transform-destructuring/src/index.js @@ -4,11 +4,8 @@ import { types as t } from "@babel/core"; export default declare((api, options) => { api.assertVersion(7); - const { - loose = false, - useBuiltIns = false, - allowArrayLike = false, - } = options; + const { loose = false, useBuiltIns = false, allowArrayLike = false } = + options; if (typeof loose !== "boolean") { throw new Error(`.loose must be a boolean or undefined`); @@ -296,10 +293,11 @@ export default declare((api, options) => { const name = this.scope.generateUidIdentifierBasedOnNode(key); this.nodes.push(this.buildVariableDeclaration(name, key)); if (!copiedPattern) { - copiedPattern = pattern = { - ...pattern, - properties: pattern.properties.slice(), - }; + copiedPattern = pattern = + { + ...pattern, + properties: pattern.properties.slice(), + }; } copiedPattern.properties[i] = { ...copiedPattern.properties[i], diff --git ORI/babel/packages/babel-plugin-transform-parameters/src/params.js ALT/babel/packages/babel-plugin-transform-parameters/src/params.js index 4608a225a..60989c943 100644 --- ORI/babel/packages/babel-plugin-transform-parameters/src/params.js +++ ALT/babel/packages/babel-plugin-transform-parameters/src/params.js @@ -37,8 +37,8 @@ const iifeVisitor = { } }, // type annotations don't use or introduce "real" bindings - "TypeAnnotation|TSTypeAnnotation|TypeParameterDeclaration|TSTypeParameterDeclaration": path => - path.skip(), + "TypeAnnotation|TSTypeAnnotation|TypeParameterDeclaration|TSTypeParameterDeclaration": + path => path.skip(), }; // last 2 parameters are optional -- they are used by proposal-object-rest-spread/src/index.js 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 1cdbf6491..2d944d58c 100644 --- ORI/babel/packages/babel-plugin-transform-runtime/scripts/build-dist.js +++ ALT/babel/packages/babel-plugin-transform-runtime/scripts/build-dist.js @@ -10,8 +10,10 @@ const t = require("@babel/types"); const transformRuntime = require("../"); const runtimeVersion = require("@babel/runtime/package.json").version; -const corejs2Definitions = require("../lib/runtime-corejs2-definitions").default(); -const corejs3Definitions = require("../lib/runtime-corejs3-definitions").default(); +const corejs2Definitions = + require("../lib/runtime-corejs2-definitions").default(); +const corejs3Definitions = + require("../lib/runtime-corejs3-definitions").default(); function outputFile(filePath, data) { fs.mkdirSync(path.dirname(filePath), { recursive: true }); diff --git ORI/babel/packages/babel-preset-env/src/polyfills/corejs3/usage-plugin.js ALT/babel/packages/babel-preset-env/src/polyfills/corejs3/usage-plugin.js index 0cd423af1..37370a9b6 100644 --- ORI/babel/packages/babel-preset-env/src/polyfills/corejs3/usage-plugin.js +++ ALT/babel/packages/babel-preset-env/src/polyfills/corejs3/usage-plugin.js @@ -39,13 +39,14 @@ const corejs3PolyfillsWithoutProposals = Object.keys(corejs3Polyfills) return memo; }, {}); -const corejs3PolyfillsWithShippedProposals = (corejs3ShippedProposalsList: string[]).reduce( - (memo, key) => { - memo[key] = corejs3Polyfills[key]; - return memo; - }, - { ...corejs3PolyfillsWithoutProposals }, -); +const corejs3PolyfillsWithShippedProposals = + (corejs3ShippedProposalsList: string[]).reduce( + (memo, key) => { + memo[key] = corejs3Polyfills[key]; + return memo; + }, + { ...corejs3PolyfillsWithoutProposals }, + ); export default function ( _: any, diff --git ORI/babel/packages/babel-preset-env/test/get-option-specific-excludes.spec.js ALT/babel/packages/babel-preset-env/test/get-option-specific-excludes.spec.js index ea0cd6950..1b9d8c7db 100644 --- ORI/babel/packages/babel-preset-env/test/get-option-specific-excludes.spec.js +++ ALT/babel/packages/babel-preset-env/test/get-option-specific-excludes.spec.js @@ -1,7 +1,7 @@ "use strict"; -const getOptionSpecificExcludesFor = require("../lib/get-option-specific-excludes") - .default; +const getOptionSpecificExcludesFor = + require("../lib/get-option-specific-excludes").default; describe("defaults", () => { describe("getOptionSpecificExcludesFor", () => { diff --git ORI/babel/packages/babel-preset-env/test/get-platform-specific-default.spec.js ALT/babel/packages/babel-preset-env/test/get-platform-specific-default.spec.js index 1958a7fa6..9b3541292 100644 --- ORI/babel/packages/babel-preset-env/test/get-platform-specific-default.spec.js +++ ALT/babel/packages/babel-preset-env/test/get-platform-specific-default.spec.js @@ -1,17 +1,16 @@ "use strict"; -const getCoreJS2PlatformSpecificDefaultFor = require("../lib/polyfills/corejs2/get-platform-specific-default") - .default; +const getCoreJS2PlatformSpecificDefaultFor = + require("../lib/polyfills/corejs2/get-platform-specific-default").default; describe("defaults", () => { describe("getCoreJS2PlatformSpecificDefaultFor", () => { it("should return web polyfills for non-`node` platform", () => { - const defaultWebIncludesForChromeAndNode = getCoreJS2PlatformSpecificDefaultFor( - { + const defaultWebIncludesForChromeAndNode = + getCoreJS2PlatformSpecificDefaultFor({ chrome: "63", node: "8", - }, - ); + }); expect(defaultWebIncludesForChromeAndNode).toEqual([ "web.timers", "web.immediate", @@ -20,11 +19,10 @@ describe("defaults", () => { }); it("shouldn't return web polyfills for node platform", () => { - const defaultWebIncludesForChromeAndNode = getCoreJS2PlatformSpecificDefaultFor( - { + const defaultWebIncludesForChromeAndNode = + getCoreJS2PlatformSpecificDefaultFor({ node: "8", - }, - ); + }); expect(defaultWebIncludesForChromeAndNode).toBeNull(); }); }); diff --git ORI/babel/packages/babel-preset-env/test/index.spec.js ALT/babel/packages/babel-preset-env/test/index.spec.js index 291bb26c7..e6a2d00c6 100644 --- ORI/babel/packages/babel-preset-env/test/index.spec.js +++ ALT/babel/packages/babel-preset-env/test/index.spec.js @@ -1,18 +1,18 @@ "use strict"; const babelPresetEnv = require("../lib/index"); -const addCoreJS2UsagePlugin = require("../lib/polyfills/corejs2/usage-plugin") - .default; -const addCoreJS3UsagePlugin = require("../lib/polyfills/corejs3/usage-plugin") - .default; -const addRegeneratorUsagePlugin = require("../lib/polyfills/regenerator/usage-plugin") - .default; -const replaceCoreJS2EntryPlugin = require("../lib/polyfills/corejs2/entry-plugin") - .default; -const replaceCoreJS3EntryPlugin = require("../lib/polyfills/corejs3/entry-plugin") - .default; -const removeRegeneratorEntryPlugin = require("../lib/polyfills/regenerator/entry-plugin") - .default; +const addCoreJS2UsagePlugin = + require("../lib/polyfills/corejs2/usage-plugin").default; +const addCoreJS3UsagePlugin = + require("../lib/polyfills/corejs3/usage-plugin").default; +const addRegeneratorUsagePlugin = + require("../lib/polyfills/regenerator/usage-plugin").default; +const replaceCoreJS2EntryPlugin = + require("../lib/polyfills/corejs2/entry-plugin").default; +const replaceCoreJS3EntryPlugin = + require("../lib/polyfills/corejs3/entry-plugin").default; +const removeRegeneratorEntryPlugin = + require("../lib/polyfills/regenerator/entry-plugin").default; const transformations = require("../lib/module-transformations").default; const compatData = require("@babel/compat-data/plugins"); diff --git ORI/babel/packages/babel-register/src/index.js ALT/babel/packages/babel-register/src/index.js index aea88df53..d9fefa1c4 100644 --- ORI/babel/packages/babel-register/src/index.js +++ ALT/babel/packages/babel-register/src/index.js @@ -4,9 +4,10 @@ * from a compiled Babel import. */ -exports = module.exports = function (...args) { - return register(...args); -}; +exports = module.exports = + function (...args) { + return register(...args); + }; exports.__esModule = true; const node = require("./nodeWrapper"); diff --git ORI/babel/packages/babel-standalone/src/generated/plugins.js ALT/babel/packages/babel-standalone/src/generated/plugins.js index 889f6a494..01a0ae395 100644 --- ORI/babel/packages/babel-standalone/src/generated/plugins.js +++ ALT/babel/packages/babel-standalone/src/generated/plugins.js @@ -259,7 +259,8 @@ export const all = { "transform-new-target": transformNewTarget, "transform-object-assign": transformObjectAssign, "transform-object-super": transformObjectSuper, - "transform-object-set-prototype-of-to-assign": transformObjectSetPrototypeOfToAssign, + "transform-object-set-prototype-of-to-assign": + transformObjectSetPrototypeOfToAssign, "transform-parameters": transformParameters, "transform-property-literals": transformPropertyLiterals, "transform-property-mutators": transformPropertyMutators, diff --git ORI/babel/packages/babel-template/test/index.js ALT/babel/packages/babel-template/test/index.js index 7b893d7e4..63b821b0d 100644 --- ORI/babel/packages/babel-template/test/index.js +++ ALT/babel/packages/babel-template/test/index.js @@ -43,11 +43,12 @@ describe("@babel/template", function () { describe("string-based", () => { it("should handle replacing values from an object", () => { const value = t.stringLiteral("some string value"); - const result = template(` + const result = + template(` if (SOME_VAR === "") {} `)({ - SOME_VAR: value, - }); + SOME_VAR: value, + }); expect(result.type).toBe("IfStatement"); expect(result.test.type).toBe("BinaryExpression"); @@ -56,7 +57,8 @@ describe("@babel/template", function () { it("should handle replacing values given an array", () => { const value = t.stringLiteral("some string value"); - const result = template(` + const result = + template(` if ($0 === "") {} `)([value]); @@ -66,7 +68,8 @@ describe("@babel/template", function () { }); it("should handle replacing values with null to remove them", () => { - const result = template(` + const result = + template(` callee(ARG); `)({ ARG: null }); @@ -76,7 +79,8 @@ describe("@babel/template", function () { }); it("should handle replacing values that are string content", () => { - const result = template(` + const result = + template(` ("ARG"); `)({ ARG: "some new content" }); @@ -88,7 +92,8 @@ describe("@babel/template", function () { it("should automatically clone nodes if they are injected twice", () => { const id = t.identifier("someIdent"); - const result = template(` + const result = + template(` ID; ID; `)({ ID: id }); @@ -277,23 +282,26 @@ describe("@babel/template", function () { describe(".syntacticPlaceholders", () => { it("works in function body", () => { - const output = template(`function f() %%A%%`)({ - A: t.blockStatement([]), - }); + const output = + template(`function f() %%A%%`)({ + A: t.blockStatement([]), + }); expect(generator(output).code).toMatchInlineSnapshot(`"function f() {}"`); }); it("works in class body", () => { - const output = template(`class C %%A%%`)({ - A: t.classBody([]), - }); + const output = + template(`class C %%A%%`)({ + A: t.classBody([]), + }); expect(generator(output).code).toMatchInlineSnapshot(`"class C {}"`); }); it("replaces lowercase names", () => { - const output = template(`%%foo%%`)({ - foo: t.numericLiteral(1), - }); + const output = + template(`%%foo%%`)({ + foo: t.numericLiteral(1), + }); expect(generator(output).code).toMatchInlineSnapshot(`"1;"`); }); @@ -372,23 +380,26 @@ describe("@babel/template", function () { describe("undefined", () => { it("allows placeholders", () => { - const output = template(`%%FOO%%`)({ - FOO: t.numericLiteral(1), - }); + const output = + template(`%%FOO%%`)({ + FOO: t.numericLiteral(1), + }); expect(generator(output).code).toMatchInlineSnapshot(`"1;"`); }); it("replaces identifiers", () => { - const output = template(`FOO`)({ - FOO: t.numericLiteral(1), - }); + const output = + template(`FOO`)({ + FOO: t.numericLiteral(1), + }); expect(generator(output).code).toMatchInlineSnapshot(`"1;"`); }); it("doesn't mix placeholder styles", () => { - const output = template(`FOO + %%FOO%%`)({ - FOO: t.numericLiteral(1), - }); + const output = + template(`FOO + %%FOO%%`)({ + FOO: t.numericLiteral(1), + }); expect(generator(output).code).toMatchInlineSnapshot(`"FOO + 1;"`); }); }); diff --git ORI/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js ALT/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js index b209376..d215a27 100644 --- ORI/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js +++ ALT/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js @@ -161,8 +161,9 @@ function parseSetup(code, espree, eslintScope) { fallback: AST.getFallbackKeys }) - const variables = /** @type {Variable[]} */ (result.globalScope.childScopes[0] - .variables) + const variables = /** @type {Variable[]} */ ( + result.globalScope.childScopes[0].variables + ) return variables.map((v) => v.name) } diff --git ORI/eslint-plugin-vue/lib/rules/html-self-closing.js ALT/eslint-plugin-vue/lib/rules/html-self-closing.js index b54c206..ed4a3dc 100644 --- ORI/eslint-plugin-vue/lib/rules/html-self-closing.js +++ ALT/eslint-plugin-vue/lib/rules/html-self-closing.js @@ -164,7 +164,8 @@ module.exports = { name: node.rawName }, fix(fixer) { - const tokens = context.parserServices.getTemplateBodyTokenStore() + const tokens = + context.parserServices.getTemplateBodyTokenStore() const close = tokens.getLastToken(node.startTag) if (close.type !== 'HTMLTagClose') { return null @@ -188,7 +189,8 @@ module.exports = { name: node.rawName }, fix(fixer) { - const tokens = context.parserServices.getTemplateBodyTokenStore() + const tokens = + context.parserServices.getTemplateBodyTokenStore() const close = tokens.getLastToken(node.startTag) if (close.type !== 'HTMLSelfClosingTagClose') { return null diff --git ORI/eslint-plugin-vue/lib/rules/max-attributes-per-line.js ALT/eslint-plugin-vue/lib/rules/max-attributes-per-line.js index 8cec636..ce03a82 100644 --- ORI/eslint-plugin-vue/lib/rules/max-attributes-per-line.js +++ ALT/eslint-plugin-vue/lib/rules/max-attributes-per-line.js @@ -157,12 +157,11 @@ module.exports = { // Find the closest token before the current prop // that is not a white space - const prevToken = /** @type {Token} */ (template.getTokenBefore( - prop, - { + const prevToken = /** @type {Token} */ ( + template.getTokenBefore(prop, { filter: (token) => token.type !== 'HTMLWhitespace' - } - )) + }) + ) /** @type {Range} */ const range = [prevToken.range[1], prop.range[0]] diff --git ORI/eslint-plugin-vue/lib/rules/multiline-html-element-content-newline.js ALT/eslint-plugin-vue/lib/rules/multiline-html-element-content-newline.js index 49a675c..455692d 100644 --- ORI/eslint-plugin-vue/lib/rules/multiline-html-element-content-newline.js +++ ALT/eslint-plugin-vue/lib/rules/multiline-html-element-content-newline.js @@ -179,14 +179,12 @@ module.exports = { return } - const contentFirst = /** @type {Token} */ (template.getTokenAfter( - element.startTag, - getTokenOption - )) - const contentLast = /** @type {Token} */ (template.getTokenBefore( - element.endTag, - getTokenOption - )) + const contentFirst = /** @type {Token} */ ( + template.getTokenAfter(element.startTag, getTokenOption) + ) + const contentLast = /** @type {Token} */ ( + template.getTokenBefore(element.endTag, getTokenOption) + ) const beforeLineBreaks = contentFirst.loc.start.line - element.startTag.loc.end.line diff --git ORI/eslint-plugin-vue/lib/rules/no-extra-parens.js ALT/eslint-plugin-vue/lib/rules/no-extra-parens.js index 3f202fa..20c2593 100644 --- ORI/eslint-plugin-vue/lib/rules/no-extra-parens.js +++ ALT/eslint-plugin-vue/lib/rules/no-extra-parens.js @@ -176,7 +176,8 @@ function createForVueSyntax(context) { } return { - "VAttribute[directive=true][key.name.name='bind'] > VExpressionContainer": verify, + "VAttribute[directive=true][key.name.name='bind'] > VExpressionContainer": + verify, 'VElement > VExpressionContainer': verify } } diff --git ORI/eslint-plugin-vue/lib/rules/no-irregular-whitespace.js ALT/eslint-plugin-vue/lib/rules/no-irregular-whitespace.js index 7c05083..1cfbd61 100644 --- ORI/eslint-plugin-vue/lib/rules/no-irregular-whitespace.js +++ ALT/eslint-plugin-vue/lib/rules/no-irregular-whitespace.js @@ -15,8 +15,10 @@ const utils = require('../utils') // Constants // ------------------------------------------------------------------------------ -const ALL_IRREGULARS = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]/u -const IRREGULAR_WHITESPACE = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/gmu +const ALL_IRREGULARS = + /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]/u +const IRREGULAR_WHITESPACE = + /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/gmu const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/gmu // ------------------------------------------------------------------------------ @@ -195,7 +197,8 @@ module.exports = { const bodyVisitor = utils.defineTemplateBodyVisitor(context, { ...(skipHTMLAttributeValues ? { - 'VAttribute[directive=false] > VLiteral': removeInvalidNodeErrorsInHTMLAttributeValue + 'VAttribute[directive=false] > VLiteral': + removeInvalidNodeErrorsInHTMLAttributeValue } : {}), ...(skipHTMLTextContents diff --git ORI/eslint-plugin-vue/lib/rules/no-side-effects-in-computed-properties.js ALT/eslint-plugin-vue/lib/rules/no-side-effects-in-computed-properties.js index 7c0639b..2474869 100644 --- ORI/eslint-plugin-vue/lib/rules/no-side-effects-in-computed-properties.js +++ ALT/eslint-plugin-vue/lib/rules/no-side-effects-in-computed-properties.js @@ -104,9 +104,9 @@ module.exports = { } const targetBody = scopeStack.body - const computedProperty = /** @type {ComponentComputedProperty[]} */ (computedPropertiesMap.get( - vueNode - )).find((cp) => { + const computedProperty = /** @type {ComponentComputedProperty[]} */ ( + computedPropertiesMap.get(vueNode) + ).find((cp) => { return ( cp.value && node.loc.start.line >= cp.value.loc.start.line && diff --git ORI/eslint-plugin-vue/lib/rules/no-useless-mustaches.js ALT/eslint-plugin-vue/lib/rules/no-useless-mustaches.js index b8a2057..709617e 100644 --- ORI/eslint-plugin-vue/lib/rules/no-useless-mustaches.js +++ ALT/eslint-plugin-vue/lib/rules/no-useless-mustaches.js @@ -19,9 +19,10 @@ function stripQuotesForHTML(text) { return text.slice(1, -1) } - const re = /^(?:&(?:quot|apos|#\d+|#x[\da-f]+);|["'`])([\s\S]*)(?:&(?:quot|apos|#\d+|#x[\da-f]+);|["'`])$/u.exec( - text - ) + const re = + /^(?:&(?:quot|apos|#\d+|#x[\da-f]+);|["'`])([\s\S]*)(?:&(?:quot|apos|#\d+|#x[\da-f]+);|["'`])$/u.exec( + text + ) if (!re) { return null } diff --git ORI/eslint-plugin-vue/lib/rules/no-useless-v-bind.js ALT/eslint-plugin-vue/lib/rules/no-useless-v-bind.js index 01549ca..c2440da 100644 --- ORI/eslint-plugin-vue/lib/rules/no-useless-v-bind.js +++ ALT/eslint-plugin-vue/lib/rules/no-useless-v-bind.js @@ -144,7 +144,8 @@ module.exports = { } return utils.defineTemplateBodyVisitor(context, { - "VAttribute[directive=true][key.name.name='bind'][key.argument!=null]": verify + "VAttribute[directive=true][key.name.name='bind'][key.argument!=null]": + verify }) } } diff --git ORI/eslint-plugin-vue/lib/rules/require-explicit-emits.js ALT/eslint-plugin-vue/lib/rules/require-explicit-emits.js index ec35636..7974282 100644 --- ORI/eslint-plugin-vue/lib/rules/require-explicit-emits.js +++ ALT/eslint-plugin-vue/lib/rules/require-explicit-emits.js @@ -387,10 +387,9 @@ function buildSuggest(object, emits, nameNode, context) { const sourceCode = context.getSourceCode() const emitsOptionValue = emitsOption.value if (emitsOptionValue.type === 'ArrayExpression') { - const leftBracket = /** @type {Token} */ (sourceCode.getFirstToken( - emitsOptionValue, - isLeftBracket - )) + const leftBracket = /** @type {Token} */ ( + sourceCode.getFirstToken(emitsOptionValue, isLeftBracket) + ) return [ { messageId: 'addOneOption', @@ -406,10 +405,9 @@ function buildSuggest(object, emits, nameNode, context) { } ] } else if (emitsOptionValue.type === 'ObjectExpression') { - const leftBrace = /** @type {Token} */ (sourceCode.getFirstToken( - emitsOptionValue, - isLeftBrace - )) + const leftBrace = /** @type {Token} */ ( + sourceCode.getFirstToken(emitsOptionValue, isLeftBrace) + ) return [ { messageId: 'addOneOption', @@ -451,14 +449,12 @@ function buildSuggest(object, emits, nameNode, context) { `,\nemits: ['${nameNode.value}']` ) } else { - const objectLeftBrace = /** @type {Token} */ (sourceCode.getFirstToken( - object, - isLeftBrace - )) - const objectRightBrace = /** @type {Token} */ (sourceCode.getLastToken( - object, - isRightBrace - )) + const objectLeftBrace = /** @type {Token} */ ( + sourceCode.getFirstToken(object, isLeftBrace) + ) + const objectRightBrace = /** @type {Token} */ ( + sourceCode.getLastToken(object, isRightBrace) + ) return fixer.insertTextAfter( objectLeftBrace, `\nemits: ['${nameNode.value}']${ @@ -488,14 +484,12 @@ function buildSuggest(object, emits, nameNode, context) { `,\nemits: {'${nameNode.value}': null}` ) } else { - const objectLeftBrace = /** @type {Token} */ (sourceCode.getFirstToken( - object, - isLeftBrace - )) - const objectRightBrace = /** @type {Token} */ (sourceCode.getLastToken( - object, - isRightBrace - )) + const objectLeftBrace = /** @type {Token} */ ( + sourceCode.getFirstToken(object, isLeftBrace) + ) + const objectRightBrace = /** @type {Token} */ ( + sourceCode.getLastToken(object, isRightBrace) + ) return fixer.insertTextAfter( objectLeftBrace, `\nemits: {'${nameNode.value}': null}${ diff --git ORI/eslint-plugin-vue/lib/rules/singleline-html-element-content-newline.js ALT/eslint-plugin-vue/lib/rules/singleline-html-element-content-newline.js index 52b5ed1..fc016cc 100644 --- ORI/eslint-plugin-vue/lib/rules/singleline-html-element-content-newline.js +++ ALT/eslint-plugin-vue/lib/rules/singleline-html-element-content-newline.js @@ -157,14 +157,12 @@ module.exports = { return } - const contentFirst = /** @type {Token} */ (template.getTokenAfter( - elem.startTag, - getTokenOption - )) - const contentLast = /** @type {Token} */ (template.getTokenBefore( - elem.endTag, - getTokenOption - )) + const contentFirst = /** @type {Token} */ ( + template.getTokenAfter(elem.startTag, getTokenOption) + ) + const contentLast = /** @type {Token} */ ( + template.getTokenBefore(elem.endTag, getTokenOption) + ) context.report({ node: template.getLastToken(elem.startTag), diff --git ORI/eslint-plugin-vue/lib/rules/syntaxes/dynamic-directive-arguments.js ALT/eslint-plugin-vue/lib/rules/syntaxes/dynamic-directive-arguments.js index 9a790e9..e670fa3 100644 --- ORI/eslint-plugin-vue/lib/rules/syntaxes/dynamic-directive-arguments.js +++ ALT/eslint-plugin-vue/lib/rules/syntaxes/dynamic-directive-arguments.js @@ -20,7 +20,8 @@ module.exports = { } return { - 'VAttribute[directive=true] > VDirectiveKey > VExpressionContainer': reportDynamicArgument + 'VAttribute[directive=true] > VDirectiveKey > VExpressionContainer': + reportDynamicArgument } } } diff --git ORI/eslint-plugin-vue/lib/rules/syntaxes/scope-attribute.js ALT/eslint-plugin-vue/lib/rules/syntaxes/scope-attribute.js index c356a67..af7dbcd 100644 --- ORI/eslint-plugin-vue/lib/rules/syntaxes/scope-attribute.js +++ ALT/eslint-plugin-vue/lib/rules/syntaxes/scope-attribute.js @@ -23,7 +23,8 @@ module.exports = { } return { - "VAttribute[directive=true] > VDirectiveKey[name.name='scope']": reportScope + "VAttribute[directive=true] > VDirectiveKey[name.name='scope']": + reportScope } } } diff --git ORI/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js ALT/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js index 1ce2748..ba59c6e 100644 --- ORI/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js +++ ALT/eslint-plugin-vue/lib/rules/syntaxes/slot-attribute.js @@ -128,7 +128,8 @@ module.exports = { return { "VAttribute[directive=false][key.name='slot']": reportSlot, - "VAttribute[directive=true][key.name.name='bind'][key.argument.name='slot']": reportVBindSlot + "VAttribute[directive=true][key.name.name='bind'][key.argument.name='slot']": + reportVBindSlot } } } diff --git ORI/eslint-plugin-vue/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js ALT/eslint-plugin-vue/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js index 219d2b3..5a53a9e 100644 --- ORI/eslint-plugin-vue/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js +++ ALT/eslint-plugin-vue/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js @@ -27,7 +27,8 @@ module.exports = { } return { - "VAttribute[directive=true] > VDirectiveKey[name.name='bind'][name.rawName='.']": reportPropModifierShorthand + "VAttribute[directive=true] > VDirectiveKey[name.name='bind'][name.rawName='.']": + reportPropModifierShorthand } } } diff --git ORI/eslint-plugin-vue/lib/rules/v-for-delimiter-style.js ALT/eslint-plugin-vue/lib/rules/v-for-delimiter-style.js index ef0086c..a50b6a5 100644 --- ORI/eslint-plugin-vue/lib/rules/v-for-delimiter-style.js +++ ALT/eslint-plugin-vue/lib/rules/v-for-delimiter-style.js @@ -40,12 +40,14 @@ module.exports = { context.parserServices.getTemplateBodyTokenStore && context.parserServices.getTemplateBodyTokenStore() - const delimiterToken = /** @type {Token} */ (tokenStore.getTokenAfter( - node.left.length - ? node.left[node.left.length - 1] - : tokenStore.getFirstToken(node), - (token) => token.type !== 'Punctuator' || token.value !== ')' - )) + const delimiterToken = /** @type {Token} */ ( + tokenStore.getTokenAfter( + node.left.length + ? node.left[node.left.length - 1] + : tokenStore.getFirstToken(node), + (token) => token.type !== 'Punctuator' || token.value !== ')' + ) + ) if (delimiterToken.value === preferredDelimiter) { return diff --git ORI/eslint-plugin-vue/lib/rules/v-slot-style.js ALT/eslint-plugin-vue/lib/rules/v-slot-style.js index f0cbe36..1bb5f57 100644 --- ORI/eslint-plugin-vue/lib/rules/v-slot-style.js +++ ALT/eslint-plugin-vue/lib/rules/v-slot-style.js @@ -28,7 +28,10 @@ function normalizeOptions(options) { } if (typeof options === 'string') { - normalized.atComponent = normalized.default = normalized.named = /** @type {"shorthand" | "longform"} */ (options) + normalized.atComponent = + normalized.default = + normalized.named = + /** @type {"shorthand" | "longform"} */ (options) } else if (options != null) { /** @type {(keyof Options)[]} */ const keys = ['atComponent', 'default', 'named'] diff --git ORI/eslint-plugin-vue/lib/utils/indent-common.js ALT/eslint-plugin-vue/lib/utils/indent-common.js index 9e6bfde..c4818b4 100644 --- ORI/eslint-plugin-vue/lib/utils/indent-common.js +++ ALT/eslint-plugin-vue/lib/utils/indent-common.js @@ -739,10 +739,9 @@ module.exports.defineVisitor = function create( return true } if (parent.type === 'CallExpression' || parent.type === 'NewExpression') { - const openParen = /** @type {Token} */ (tokenStore.getTokenAfter( - parent.callee, - isNotRightParen - )) + const openParen = /** @type {Token} */ ( + tokenStore.getTokenAfter(parent.callee, isNotRightParen) + ) return parent.arguments.some( (param) => getFirstAndLastTokens(param, openParen.range[1]).firstToken @@ -1078,9 +1077,8 @@ module.exports.defineVisitor = function create( baseline.add(token) } else if (baseline.has(offsetInfo.baseToken)) { // The base token is a baseline token on this line, so inherit it. - offsetInfo.expectedIndent = offsets.get( - offsetInfo.baseToken - ).expectedIndent + offsetInfo.expectedIndent = + offsets.get(offsetInfo.baseToken).expectedIndent baseline.add(token) } else { // Otherwise, set the expected indent of this line. @@ -1215,10 +1213,9 @@ module.exports.defineVisitor = function create( VForExpression(node) { const firstToken = tokenStore.getFirstToken(node) const lastOfLeft = last(node.left) || firstToken - const inToken = /** @type {Token} */ (tokenStore.getTokenAfter( - lastOfLeft, - isNotRightParen - )) + const inToken = /** @type {Token} */ ( + tokenStore.getTokenAfter(lastOfLeft, isNotRightParen) + ) const rightToken = tokenStore.getFirstToken(node.right) if (isLeftParen(firstToken)) { @@ -1296,10 +1293,9 @@ module.exports.defineVisitor = function create( node ) { const leftToken = getChainHeadToken(node) - const opToken = /** @type {Token} */ (tokenStore.getTokenAfter( - node.left, - isNotRightParen - )) + const opToken = /** @type {Token} */ ( + tokenStore.getTokenAfter(node.left, isNotRightParen) + ) const rightToken = tokenStore.getTokenAfter(opToken) const prevToken = tokenStore.getTokenBefore(leftToken) const shouldIndent = @@ -1392,15 +1388,13 @@ module.exports.defineVisitor = function create( ConditionalExpression(node) { const prevToken = tokenStore.getTokenBefore(node) const firstToken = tokenStore.getFirstToken(node) - const questionToken = /** @type {Token} */ (tokenStore.getTokenAfter( - node.test, - isNotRightParen - )) + const questionToken = /** @type {Token} */ ( + tokenStore.getTokenAfter(node.test, isNotRightParen) + ) const consequentToken = tokenStore.getTokenAfter(questionToken) - const colonToken = /** @type {Token} */ (tokenStore.getTokenAfter( - node.consequent, - isNotRightParen - )) + const colonToken = /** @type {Token} */ ( + tokenStore.getTokenAfter(node.consequent, isNotRightParen) + ) const alternateToken = tokenStore.getTokenAfter(colonToken) const isFlat = prevToken && @@ -1421,10 +1415,9 @@ module.exports.defineVisitor = function create( /** @param {DoWhileStatement} node */ DoWhileStatement(node) { const doToken = tokenStore.getFirstToken(node) - const whileToken = /** @type {Token} */ (tokenStore.getTokenAfter( - node.body, - isNotRightParen - )) + const whileToken = /** @type {Token} */ ( + tokenStore.getTokenAfter(node.body, isNotRightParen) + ) const leftToken = tokenStore.getTokenAfter(whileToken) const testToken = tokenStore.getTokenAfter(leftToken) const lastToken = tokenStore.getLastToken(node) @@ -1464,8 +1457,8 @@ module.exports.defineVisitor = function create( ExportDefaultDeclaration(node) { const exportToken = tokenStore.getFirstToken(node) const defaultToken = tokenStore.getFirstToken(node, 1) - const declarationToken = getFirstAndLastTokens(node.declaration) - .firstToken + const declarationToken = + getFirstAndLastTokens(node.declaration).firstToken setOffset([defaultToken, declarationToken], 1, exportToken) }, /** @param {ExportNamedDeclaration} node */ @@ -1480,10 +1473,9 @@ module.exports.defineVisitor = function create( if (!firstSpecifier || firstSpecifier.type === 'ExportSpecifier') { // export {foo, bar}; or export {foo, bar} from "mod"; const leftParenToken = tokenStore.getFirstToken(node, 1) - const rightParenToken = /** @type {Token} */ (tokenStore.getLastToken( - node, - isRightBrace - )) + const rightParenToken = /** @type {Token} */ ( + tokenStore.getLastToken(node, isRightBrace) + ) setOffset(leftParenToken, 0, exportToken) processNodeList(node.specifiers, leftParenToken, rightParenToken, 1) @@ -1517,10 +1509,9 @@ module.exports.defineVisitor = function create( null const leftParenToken = tokenStore.getTokenAfter(awaitToken || forToken) const leftToken = tokenStore.getTokenAfter(leftParenToken) - const inToken = /** @type {Token} */ (tokenStore.getTokenAfter( - leftToken, - isNotRightParen - )) + const inToken = /** @type {Token} */ ( + tokenStore.getTokenAfter(leftToken, isNotRightParen) + ) const rightToken = tokenStore.getTokenAfter(inToken) const rightParenToken = tokenStore.getTokenBefore( node.body, @@ -1615,10 +1606,9 @@ module.exports.defineVisitor = function create( processMaybeBlock(node.consequent, ifToken) if (node.alternate != null) { - const elseToken = /** @type {Token} */ (tokenStore.getTokenAfter( - node.consequent, - isNotRightParen - )) + const elseToken = /** @type {Token} */ ( + tokenStore.getTokenAfter(node.consequent, isNotRightParen) + ) setOffset(elseToken, 0, ifToken) processMaybeBlock(node.alternate, elseToken) @@ -1739,10 +1729,9 @@ module.exports.defineVisitor = function create( 'MemberExpression, MetaProperty'(node) { const objectToken = tokenStore.getFirstToken(node) if (node.type === 'MemberExpression' && node.computed) { - const leftBracketToken = /** @type {Token} */ (tokenStore.getTokenBefore( - node.property, - isLeftBracket - )) + const leftBracketToken = /** @type {Token} */ ( + tokenStore.getTokenBefore(node.property, isLeftBracket) + ) const propertyToken = tokenStore.getTokenAfter(leftBracketToken) const rightBracketToken = tokenStore.getTokenAfter( node.property, @@ -1772,15 +1761,13 @@ module.exports.defineVisitor = function create( /** @type {Token} */ let lastKeyToken if (node.computed) { - const keyLeftToken = /** @type {Token} */ (tokenStore.getFirstToken( - node, - isLeftBracket - )) + const keyLeftToken = /** @type {Token} */ ( + tokenStore.getFirstToken(node, isLeftBracket) + ) const keyToken = tokenStore.getTokenAfter(keyLeftToken) - const keyRightToken = (lastKeyToken = /** @type {Token} */ (tokenStore.getTokenAfter( - node.key, - isRightBracket - ))) + const keyRightToken = (lastKeyToken = /** @type {Token} */ ( + tokenStore.getTokenAfter(node.key, isRightBracket) + )) if (hasPrefix) { setOffset(keyLeftToken, 0, /** @type {Token} */ (last(prefixTokens))) @@ -1864,10 +1851,9 @@ module.exports.defineVisitor = function create( const switchToken = tokenStore.getFirstToken(node) const leftParenToken = tokenStore.getTokenAfter(switchToken) const discriminantToken = tokenStore.getTokenAfter(leftParenToken) - const leftBraceToken = /** @type {Token} */ (tokenStore.getTokenAfter( - node.discriminant, - isLeftBrace - )) + const leftBraceToken = /** @type {Token} */ ( + tokenStore.getTokenAfter(node.discriminant, isLeftBrace) + ) const rightParenToken = tokenStore.getTokenBefore(leftBraceToken) const rightBraceToken = tokenStore.getLastToken(node) diff --git ORI/eslint-plugin-vue/lib/utils/index.js ALT/eslint-plugin-vue/lib/utils/index.js index 0bcf801..055ffb4 100644 --- ORI/eslint-plugin-vue/lib/utils/index.js +++ ALT/eslint-plugin-vue/lib/utils/index.js @@ -274,10 +274,9 @@ module.exports = { // Move `Program` handlers to `VElement[parent.type!='VElement']` const coreHandlers = coreRule.create(context) - const handlers = /** @type {TemplateListener} */ (Object.assign( - {}, - coreHandlers - )) + const handlers = /** @type {TemplateListener} */ ( + Object.assign({}, coreHandlers) + ) if (handlers.Program) { handlers["VElement[parent.type!='VElement']"] = handlers.Program delete handlers.Program @@ -838,11 +837,14 @@ module.exports = { if (propValue.type === 'FunctionExpression') { value = propValue.body } else if (propValue.type === 'ObjectExpression') { - const get = /** @type {(Property & { value: FunctionExpression }) | null} */ (findProperty( - propValue, - 'get', - (p) => p.value.type === 'FunctionExpression' - )) + const get = + /** @type {(Property & { value: FunctionExpression }) | null} */ ( + findProperty( + propValue, + 'get', + (p) => p.value.type === 'FunctionExpression' + ) + ) value = get ? get.value.body : null } @@ -870,13 +872,16 @@ module.exports = { } if (arg.type === 'ObjectExpression') { - const getProperty = /** @type {(Property & { value: FunctionExpression | ArrowFunctionExpression }) | null} */ (findProperty( - arg, - 'get', - (p) => - p.value.type === 'FunctionExpression' || - p.value.type === 'ArrowFunctionExpression' - )) + const getProperty = + /** @type {(Property & { value: FunctionExpression | ArrowFunctionExpression }) | null} */ ( + findProperty( + arg, + 'get', + (p) => + p.value.type === 'FunctionExpression' || + p.value.type === 'ArrowFunctionExpression' + ) + ) return getProperty ? getProperty.value : null } diff --git ORI/eslint-plugin-vue/tests/lib/rules/no-irregular-whitespace.js ALT/eslint-plugin-vue/tests/lib/rules/no-irregular-whitespace.js index 85a0ad4..9c3a40c 100644 --- ORI/eslint-plugin-vue/tests/lib/rules/no-irregular-whitespace.js +++ ALT/eslint-plugin-vue/tests/lib/rules/no-irregular-whitespace.js @@ -11,9 +11,10 @@ const tester = new RuleTester({ parserOptions: { ecmaVersion: 2018 } }) -const IRREGULAR_WHITESPACES = '\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000'.split( - '' -) +const IRREGULAR_WHITESPACES = + '\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000'.split( + '' + ) const IRREGULAR_LINE_TERMINATORS = '\u2028\u2029'.split('') const ALL_IRREGULAR_WHITESPACES = [].concat( IRREGULAR_WHITESPACES, diff --git ORI/prettier/scripts/release/steps/update-dependents-count.js ALT/prettier/scripts/release/steps/update-dependents-count.js index 1fb641bb6..b8e717537 100644 --- ORI/prettier/scripts/release/steps/update-dependents-count.js +++ ALT/prettier/scripts/release/steps/update-dependents-count.js @@ -23,9 +23,9 @@ async function update() { const githubPage = await logPromise( "Fetching github dependents count", - fetch( - "https://github.com/prettier/prettier/network/dependents" - ).then((response) => response.text()) + fetch("https://github.com/prettier/prettier/network/dependents").then( + (response) => response.text() + ) ); const dependentsCountGithub = Number( githubPage diff --git ORI/prettier/src/language-html/conditional-comment.js ALT/prettier/src/language-html/conditional-comment.js index 228076446..f93551f98 100644 --- ORI/prettier/src/language-html/conditional-comment.js +++ ALT/prettier/src/language-html/conditional-comment.js @@ -7,7 +7,8 @@ const { // https://css-tricks.com/how-to-create-an-ie-only-stylesheet // -const IE_CONDITIONAL_START_END_COMMENT_REGEX = /^(\[if([^\]]*?)]>)([\S\s]*?))([\S\s]*?) const IE_CONDITIONAL_START_COMMENT_REGEX = /^\[if([^\]]*?)]> diff --git ORI/prettier/src/language-html/print-preprocess.js ALT/prettier/src/language-html/print-preprocess.js index 896d72bcd..600947b77 100644 --- ORI/prettier/src/language-html/print-preprocess.js +++ ALT/prettier/src/language-html/print-preprocess.js @@ -336,11 +336,8 @@ function extractWhitespaces(ast /*, options*/) { const localChildren = []; - const { - leadingWhitespace, - text, - trailingWhitespace, - } = getLeadingAndTrailingHtmlWhitespace(child.value); + const { leadingWhitespace, text, trailingWhitespace } = + getLeadingAndTrailingHtmlWhitespace(child.value); if (leadingWhitespace) { localChildren.push({ type: TYPE_WHITESPACE }); diff --git ORI/prettier/src/language-html/syntax-vue.js ALT/prettier/src/language-html/syntax-vue.js index 0ce5bb005..48bc66d47 100644 --- ORI/prettier/src/language-html/syntax-vue.js +++ ALT/prettier/src/language-html/syntax-vue.js @@ -79,7 +79,8 @@ function isVueEventBindingExpression(eventBindingValue) { // arrow function or anonymous function const fnExpRE = /^([\w$]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b]) - const simplePathRE = /^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[$A-Z_a-z][\w$]*])*$/; + const simplePathRE = + /^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[$A-Z_a-z][\w$]*])*$/; // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104 const value = eventBindingValue.trim(); diff --git ORI/prettier/src/language-js/comments.js ALT/prettier/src/language-js/comments.js index e4e0caa09..d34fa03ce 100644 --- ORI/prettier/src/language-js/comments.js +++ ALT/prettier/src/language-js/comments.js @@ -588,10 +588,11 @@ function handleLastFunctionArgComments({ locEnd(getLast(parameters)) ); } - const functionParamLeftParenIndex = getNextNonSpaceNonCommentCharacterIndexWithStartIndex( - text, - locEnd(enclosingNode.id) - ); + const functionParamLeftParenIndex = + getNextNonSpaceNonCommentCharacterIndexWithStartIndex( + text, + locEnd(enclosingNode.id) + ); return ( functionParamLeftParenIndex !== false && getNextNonSpaceNonCommentCharacterIndexWithStartIndex( diff --git ORI/prettier/src/language-js/parse-postprocess.js ALT/prettier/src/language-js/parse-postprocess.js index be9dcd9dd..d74e063cc 100644 --- ORI/prettier/src/language-js/parse-postprocess.js +++ ALT/prettier/src/language-js/parse-postprocess.js @@ -21,10 +21,8 @@ function postprocess(ast, options) { // Invalid decorators are removed since `@typescript-eslint/typescript-estree` v4 // https://github.com/typescript-eslint/typescript-eslint/pull/2375 if (options.parser === "typescript" && options.originalText.includes("@")) { - const { - esTreeNodeToTSNodeMap, - tsNodeToESTreeNodeMap, - } = options.tsParseResult; + const { esTreeNodeToTSNodeMap, tsNodeToESTreeNodeMap } = + options.tsParseResult; ast = visitNode(ast, (node) => { const tsNode = esTreeNodeToTSNodeMap.get(node); if (!tsNode) { diff --git ORI/prettier/src/language-js/parser-babel.js ALT/prettier/src/language-js/parser-babel.js index dad0eded4..b9f3282f7 100644 --- ORI/prettier/src/language-js/parser-babel.js +++ ALT/prettier/src/language-js/parser-babel.js @@ -62,10 +62,8 @@ function isFlowFile(text, options) { text = text.slice(shebang.length); } - const firstNonSpaceNonCommentCharacterIndex = getNextNonSpaceNonCommentCharacterIndexWithStartIndex( - text, - 0 - ); + const firstNonSpaceNonCommentCharacterIndex = + getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, 0); if (firstNonSpaceNonCommentCharacterIndex !== false) { text = text.slice(0, firstNonSpaceNonCommentCharacterIndex); diff --git ORI/prettier/src/language-markdown/constants.evaluate.js ALT/prettier/src/language-markdown/constants.evaluate.js index 1b9ab9d09..45c799f9e 100644 --- ORI/prettier/src/language-markdown/constants.evaluate.js +++ ALT/prettier/src/language-markdown/constants.evaluate.js @@ -27,7 +27,8 @@ const kPattern = unicodeRegex({ Script: ["Hangul"] }) .toString(); // http://spec.commonmark.org/0.25/#ascii-punctuation-character -const asciiPunctuationCharset = /* prettier-ignore */ regexpUtil.charset( +const asciiPunctuationCharset = + /* prettier-ignore */ regexpUtil.charset( "!", '"', "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "_", "`", "{", "|", diff --git ORI/prettier/src/main/ast-to-doc.js ALT/prettier/src/main/ast-to-doc.js index 369e6fc50..3d5a5fec0 100644 --- ORI/prettier/src/main/ast-to-doc.js +++ ALT/prettier/src/main/ast-to-doc.js @@ -86,12 +86,8 @@ function printAstToDoc(ast, options, alignmentSize = 0) { } function printPrettierIgnoredNode(node, options) { - const { - originalText, - [Symbol.for("comments")]: comments, - locStart, - locEnd, - } = options; + const { originalText, [Symbol.for("comments")]: comments, locStart, locEnd } = + options; const start = locStart(node); const end = locEnd(node); diff --git ORI/prettier/src/main/comments.js ALT/prettier/src/main/comments.js index 3903278c3..8dec303a2 100644 --- ORI/prettier/src/main/comments.js +++ ALT/prettier/src/main/comments.js @@ -313,10 +313,8 @@ function isOwnLineComment(text, options, decoratedComments, commentIndex) { if (precedingNode) { // Find first comment on the same line for (let index = commentIndex - 1; index >= 0; index--) { - const { - comment, - precedingNode: currentCommentPrecedingNode, - } = decoratedComments[index]; + const { comment, precedingNode: currentCommentPrecedingNode } = + decoratedComments[index]; if ( currentCommentPrecedingNode !== precedingNode || !isAllEmptyAndNoLineBreak(text.slice(locEnd(comment), start)) @@ -342,10 +340,8 @@ function isEndOfLineComment(text, options, decoratedComments, commentIndex) { index < decoratedComments.length; index++ ) { - const { - comment, - followingNode: currentCommentFollowingNode, - } = decoratedComments[index]; + const { comment, followingNode: currentCommentFollowingNode } = + decoratedComments[index]; if ( currentCommentFollowingNode !== followingNode || !isAllEmptyAndNoLineBreak(text.slice(end, locStart(comment))) diff --git ORI/prettier/tests_integration/__tests__/infer-parser.js ALT/prettier/tests_integration/__tests__/infer-parser.js index 5e27a6b09..88ea30065 100644 --- ORI/prettier/tests_integration/__tests__/infer-parser.js +++ ALT/prettier/tests_integration/__tests__/infer-parser.js @@ -163,11 +163,9 @@ describe("--write and --list-different with unknown path and no parser", () => { }); describe("multiple files", () => { - runPrettier("cli/infer-parser/", [ - "--list-different", - "--write", - "*", - ]).test({ status: 0 }); + runPrettier("cli/infer-parser/", ["--list-different", "--write", "*"]).test( + { status: 0 } + ); }); }); diff --git ORI/prettier/tests_integration/__tests__/line-suffix-boundary.js ALT/prettier/tests_integration/__tests__/line-suffix-boundary.js index a420c561f..8622a9bce 100644 --- ORI/prettier/tests_integration/__tests__/line-suffix-boundary.js +++ ALT/prettier/tests_integration/__tests__/line-suffix-boundary.js @@ -3,14 +3,8 @@ /** @type {import('prettier')} */ const prettier = require("prettier-local"); -const { - group, - indent, - line, - lineSuffix, - lineSuffixBoundary, - softline, -} = prettier.doc.builders; +const { group, indent, line, lineSuffix, lineSuffixBoundary, softline } = + prettier.doc.builders; const printDoc = require("../printDoc"); diff --git ORI/prettier/website/pages/playground-redirect.html ALT/prettier/website/pages/playground-redirect.html index e8bc4a40f..f03a9a573 100644 --- ORI/prettier/website/pages/playground-redirect.html +++ ALT/prettier/website/pages/playground-redirect.html @@ -16,9 +16,10 @@ />

Githubissues.
  • Githubissues is a development platform for aggregating issues.