From b2d9156cc62d37f4c522c9505a00f50b99a1eb74 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Mon, 10 May 2021 22:34:13 +0900 Subject: [PATCH] Update to Prettier 2.3 (#13288) --- .../src/convert/convertTokens.js | 10 +- .../test/rules/dry-error-messages.js | 198 ++++++------------ package.json | 2 +- packages/babel-core/src/config/caching.ts | 2 +- .../babel-core/src/config/config-chain.ts | 16 +- .../src/config/files/configuration.ts | 48 ++--- packages/babel-core/src/config/files/index.ts | 2 +- .../babel-core/src/config/files/plugins.ts | 6 +- packages/babel-core/src/config/full.ts | 12 +- packages/babel-core/src/config/index.ts | 7 +- packages/babel-core/src/config/partial.ts | 6 +- .../babel-core/src/config/resolve-targets.ts | 2 +- .../babel-core/src/gensync-utils/async.ts | 2 +- packages/babel-core/src/transform-file.ts | 2 +- .../src/transformation/file/file.ts | 5 +- .../src/transformation/normalize-file.ts | 8 +- packages/babel-core/test/helpers/esm.js | 3 +- packages/babel-generator/src/buffer.ts | 18 +- .../babel-generator/src/node/whitespace.ts | 39 ++-- .../src/index.js | 26 +-- .../babel-helper-function-name/src/index.ts | 18 +- .../src/index.ts | 32 +-- .../src/rewrite-live-references.ts | 9 +- packages/babel-parser/src/parser/statement.js | 15 +- packages/babel-parser/src/plugin-utils.js | 5 +- .../babel-parser/src/plugins/flow/index.js | 7 +- .../src/plugins/typescript/index.js | 10 +- packages/babel-parser/src/types.js | 7 +- .../src/transformer-legacy.js | 12 +- .../src/index.js | 14 +- .../src/transform.js | 5 +- .../src/transformClass.js | 5 +- .../src/index.js | 9 +- .../src/params.js | 4 +- .../src/index.js | 5 +- .../src/index.js | 5 +- .../babel-standalone/src/generated/plugins.js | 3 +- packages/babel-standalone/test/babel.js | 5 +- .../babel-traverse/src/path/conversion.ts | 9 +- .../babel-traverse/src/path/evaluation.ts | 4 +- .../babel-traverse/src/path/introspection.ts | 6 +- .../babel-types/scripts/generators/docs.js | 9 +- .../prependToMemberExpression.ts | 2 +- packages/babel-types/src/validators/is.ts | 2 +- yarn.lock | 10 +- 45 files changed, 262 insertions(+), 364 deletions(-) diff --git a/eslint/babel-eslint-parser/src/convert/convertTokens.js b/eslint/babel-eslint-parser/src/convert/convertTokens.js index 9c93990f2cd7..414067892979 100644 --- a/eslint/babel-eslint-parser/src/convert/convertTokens.js +++ b/eslint/babel-eslint-parser/src/convert/convertTokens.js @@ -1,10 +1,10 @@ import { tokTypes } from "@babel/core"; -const tl = (process.env.BABEL_8_BREAKING - ? Object.fromEntries - : p => p.reduce((o, [k, v]) => ({ ...o, [k]: v }), {}))( - Object.keys(tokTypes).map(key => [key, tokTypes[key].label]), -); +const tl = ( + process.env.BABEL_8_BREAKING + ? Object.fromEntries + : p => p.reduce((o, [k, v]) => ({ ...o, [k]: v }), {}) +)(Object.keys(tokTypes).map(key => [key, tokTypes[key].label])); function convertTemplateType(tokens) { let curlyBrace = null; diff --git a/eslint/babel-eslint-plugin-development-internal/test/rules/dry-error-messages.js b/eslint/babel-eslint-plugin-development-internal/test/rules/dry-error-messages.js index e5fc984d3d9e..ab8133889402 100644 --- a/eslint/babel-eslint-plugin-development-internal/test/rules/dry-error-messages.js +++ b/eslint/babel-eslint-plugin-development-internal/test/rules/dry-error-messages.js @@ -67,182 +67,152 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { NotErrors, Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { NotErrors, Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { NotErrors, Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], }, { filename: FILENAME, - code: - "import { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { NotErrors, Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { NotErrors, Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { NotErrors, Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], }, { filename: FILENAME, - code: - "import Errors from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import Errors from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import Errors from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors, { NotErrors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors, { NotErrors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import NotErrors, { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import NotErrors, { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import NotErrors, { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], }, { filename: FILENAME, - code: - "import Errors from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import Errors from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import Errors from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors, { NotErrors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors, { NotErrors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors, { NotErrors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import NotErrors, { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import NotErrors, { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import NotErrors, { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], }, @@ -268,8 +238,7 @@ ruleTester.run("dry-error-messages", rule, { // Support ternary as second argument { filename: FILENAME, - code: - "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : Errors.someOtherErrorMessage);", + code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : Errors.someOtherErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], }, ], @@ -309,8 +278,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "const Errors = { someErrorMessage: 'Uh oh!' }; this.raise(loc, Errors.someErrorMessage);", + code: "const Errors = { someErrorMessage: 'Uh oh!' }; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -332,8 +300,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { Errors } from 'errorsModule'; const msg = 'Uh oh!'; this.raise(loc, msg);", + code: "import { Errors } from 'errorsModule'; const msg = 'Uh oh!'; this.raise(loc, msg);", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -344,8 +311,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -356,8 +322,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -368,8 +333,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -380,8 +344,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { NotErrors, Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -392,8 +355,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { NotErrors, Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -404,8 +366,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import { NotErrors, Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -416,8 +377,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -428,8 +388,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -440,8 +399,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -452,8 +410,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { NotErrors, Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -464,8 +421,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { NotErrors, Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -476,8 +432,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import { NotErrors, Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import { NotErrors, Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -488,8 +443,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -500,8 +454,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -512,8 +465,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -524,8 +476,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors, { NotErrors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -536,8 +487,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors, { NotErrors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -548,8 +498,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import Errors, { NotErrors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -560,8 +509,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import NotErrors, { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -572,8 +520,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import NotErrors, { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -584,8 +531,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + code: "import NotErrors, { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -596,8 +542,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -608,8 +553,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -620,8 +564,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -632,8 +575,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors, { NotErrors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -644,8 +586,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors, { NotErrors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -656,8 +597,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import Errors, { NotErrors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -668,8 +608,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import NotErrors, { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -680,8 +619,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import NotErrors, { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_SAME_DIR }], errors: [ { @@ -692,8 +630,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import NotErrors, { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + code: "import NotErrors, { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", options: [{ errorModule: MODULE_PARENT_DIR }], errors: [ { @@ -706,8 +643,7 @@ ruleTester.run("dry-error-messages", rule, { // Should error if either part of a ternary isn't from error module { filename: FILENAME, - code: - "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : 'hello');", + code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : 'hello');", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -718,8 +654,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : Errors.someErrorMessage);", + code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : Errors.someErrorMessage);", options: [{ errorModule: ERRORS_MODULE }], errors: [ { @@ -730,8 +665,7 @@ ruleTester.run("dry-error-messages", rule, { }, { filename: FILENAME, - code: - "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : 'world');", + code: "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : 'world');", options: [{ errorModule: ERRORS_MODULE }], errors: [ { diff --git a/package.json b/package.json index 61e53385e3d6..221234fee9c8 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "lint-staged": "^9.2.0", "lodash": "^4.17.21", "mergeiterator": "^1.2.5", - "prettier": "^2.2.1", + "prettier": "2.3.0", "rollup": "^2.47.0", "rollup-plugin-dts": "^2.0.0", "rollup-plugin-node-polyfills": "^0.2.1", diff --git a/packages/babel-core/src/config/caching.ts b/packages/babel-core/src/config/caching.ts index c459679ceeff..cbe07b64fcc6 100644 --- a/packages/babel-core/src/config/caching.ts +++ b/packages/babel-core/src/config/caching.ts @@ -208,7 +208,7 @@ function updateFunctionCache< ArgT, ResultT, SideChannel, - Cache extends CacheMap + Cache extends CacheMap, >( cache: Cache, config: CacheConfigurator, diff --git a/packages/babel-core/src/config/config-chain.ts b/packages/babel-core/src/config/config-chain.ts index 3d5fdaa2a276..9af4cf4514d9 100644 --- a/packages/babel-core/src/config/config-chain.ts +++ b/packages/babel-core/src/config/config-chain.ts @@ -497,7 +497,7 @@ function buildOverrideEnvDescriptors( } function makeChainWalker< - ArgT extends { options: ValidatedOptions; dirname: string } + ArgT extends { options: ValidatedOptions; dirname: string }, >({ root, env, @@ -582,8 +582,12 @@ function makeChainWalker< // that we don't do extra work loading extended configs if a file is // ignored. if ( - flattenedConfigs.some(({ config: { options: { ignore, only } } }) => - shouldIgnore(context, ignore, only, dirname), + flattenedConfigs.some( + ({ + config: { + options: { ignore, only }, + }, + }) => shouldIgnore(context, ignore, only, dirname), ) ) { return null; @@ -713,10 +717,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 a/packages/babel-core/src/config/files/configuration.ts b/packages/babel-core/src/config/files/configuration.ts index fdd61466a7a6..e900369a894a 100644 --- a/packages/babel-core/src/config/files/configuration.ts +++ b/packages/babel-core/src/config/files/configuration.ts @@ -205,9 +205,7 @@ const readConfigJS = makeStrongCache(function* readConfigJS( // @ts-expect-error - if we want to make it possible to use async configs yield* []; - options = ((options as any) as (api: ConfigAPI) => {})( - makeConfigAPI(cache), - ); + options = (options as any as (api: ConfigAPI) => {})(makeConfigAPI(cache)); assertCache = true; } @@ -256,32 +254,30 @@ const packageToBabelConfig = makeWeakCacheSync( }, ); -const readConfigJSON5 = makeStaticFileCache( - (filepath, content): ConfigFile => { - let options; - try { - options = json5.parse(content); - } catch (err) { - err.message = `${filepath}: Error while parsing config - ${err.message}`; - throw err; - } +const readConfigJSON5 = makeStaticFileCache((filepath, content): ConfigFile => { + let options; + try { + options = json5.parse(content); + } catch (err) { + err.message = `${filepath}: Error while parsing config - ${err.message}`; + throw err; + } - if (!options) throw new Error(`${filepath}: No config detected`); + if (!options) throw new Error(`${filepath}: No config detected`); - if (typeof options !== "object") { - throw new Error(`${filepath}: Config returned typeof ${typeof options}`); - } - if (Array.isArray(options)) { - throw new Error(`${filepath}: Expected config object but found array`); - } + if (typeof options !== "object") { + throw new Error(`${filepath}: Config returned typeof ${typeof options}`); + } + if (Array.isArray(options)) { + throw new Error(`${filepath}: Expected config object but found array`); + } - return { - filepath, - dirname: path.dirname(filepath), - options, - }; - }, -); + return { + filepath, + dirname: path.dirname(filepath), + options, + }; +}); const readIgnoreConfig = makeStaticFileCache((filepath, content) => { const ignoreDir = path.dirname(filepath); diff --git a/packages/babel-core/src/config/files/index.ts b/packages/babel-core/src/config/files/index.ts index c1dfb76e447b..5acd74166e61 100644 --- a/packages/babel-core/src/config/files/index.ts +++ b/packages/babel-core/src/config/files/index.ts @@ -3,7 +3,7 @@ type indexType = typeof import("./index"); // Kind of gross, but essentially asserting that the exports of this module are the same as the // exports of index-browser, since this file may be replaced at bundle time with index-browser. -((({} as any) as indexBrowserType) as indexType); +({} as any as indexBrowserType as indexType); export { findPackageData } from "./package"; diff --git a/packages/babel-core/src/config/files/plugins.ts b/packages/babel-core/src/config/files/plugins.ts index 1483c7d2a421..f35432516099 100644 --- a/packages/babel-core/src/config/files/plugins.ts +++ b/packages/babel-core/src/config/files/plugins.ts @@ -17,8 +17,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 a/packages/babel-core/src/config/full.ts b/packages/babel-core/src/config/full.ts index c4b20aebd24d..dca5527492eb 100644 --- a/packages/babel-core/src/config/full.ts +++ b/packages/babel-core/src/config/full.ts @@ -279,14 +279,10 @@ const makeDescriptorLoader = ( return { value: item, options, dirname, alias }; }); -const pluginDescriptorLoader = makeDescriptorLoader< - Context.SimplePlugin, - PluginAPI ->(makePluginAPI); -const presetDescriptorLoader = makeDescriptorLoader< - Context.SimplePreset, - PresetAPI ->(makePresetAPI); +const pluginDescriptorLoader = + makeDescriptorLoader(makePluginAPI); +const presetDescriptorLoader = + makeDescriptorLoader(makePresetAPI); /** * Instantiate a plugin for the given descriptor, returning the plugin/options pair. diff --git a/packages/babel-core/src/config/index.ts b/packages/babel-core/src/config/index.ts index 8cab46d6977b..2aad3de17bcf 100644 --- a/packages/babel-core/src/config/index.ts +++ b/packages/babel-core/src/config/index.ts @@ -24,9 +24,10 @@ const loadOptionsRunner = gensync<(opts: unknown) => any>(function* (opts) { return config?.options ?? null; }); -const createConfigItemRunner = gensync< - (...args: Parameters) => ConfigItem ->(createConfigItemImpl); +const createConfigItemRunner = + gensync<(...args: Parameters) => ConfigItem>( + createConfigItemImpl, + ); const maybeErrback = runner => (opts: unknown, callback?: Function) => { if (callback === undefined && typeof opts === "function") { diff --git a/packages/babel-core/src/config/partial.ts b/packages/babel-core/src/config/partial.ts index 30ca4fbef88c..1e49ad7491de 100644 --- a/packages/babel-core/src/config/partial.ts +++ b/packages/babel-core/src/config/partial.ts @@ -169,10 +169,8 @@ export const loadPartialConfig = gensync< ({ showIgnoredFiles, ...opts } = opts); } - const result: - | PrivPartialConfig - | undefined - | null = yield* loadPrivatePartialConfig(opts); + const result: PrivPartialConfig | undefined | null = + yield* loadPrivatePartialConfig(opts); if (!result) return null; const { options, babelrc, ignore, config, fileHandling, files } = result; diff --git a/packages/babel-core/src/config/resolve-targets.ts b/packages/babel-core/src/config/resolve-targets.ts index 085292de4aa0..90a443ed3387 100644 --- a/packages/babel-core/src/config/resolve-targets.ts +++ b/packages/babel-core/src/config/resolve-targets.ts @@ -3,7 +3,7 @@ type nodeType = typeof import("./resolve-targets"); // Kind of gross, but essentially asserting that the exports of this module are the same as the // exports of index-browser, since this file may be replaced at bundle time with index-browser. -((({} as any) as browserType) as nodeType); +({} as any as browserType as nodeType); import type { ValidatedOptions } from "./validation/options"; import path from "path"; diff --git a/packages/babel-core/src/gensync-utils/async.ts b/packages/babel-core/src/gensync-utils/async.ts index d0d9c16c3134..7c5cc1da8101 100644 --- a/packages/babel-core/src/gensync-utils/async.ts +++ b/packages/babel-core/src/gensync-utils/async.ts @@ -67,7 +67,7 @@ const withKind = gensync<(cb: (kind: "sync" | "async") => any) => any>({ // ) export function forwardAsync< Action extends (...args: unknown[]) => any, - Return + Return, >( action: (...args: Parameters) => Handler>, cb: ( diff --git a/packages/babel-core/src/transform-file.ts b/packages/babel-core/src/transform-file.ts index be27260c84ef..4be0e16ac86a 100644 --- a/packages/babel-core/src/transform-file.ts +++ b/packages/babel-core/src/transform-file.ts @@ -12,7 +12,7 @@ type transformFileType = typeof import("./transform-file"); // Kind of gross, but essentially asserting that the exports of this module are the same as the // exports of transform-file-browser, since this file may be replaced at bundle time with // transform-file-browser. -((({} as any) as transformFileBrowserType) as transformFileType); +({} as any as transformFileBrowserType as transformFileType); type TransformFile = { (filename: string, callback: FileResultCallback): void; diff --git a/packages/babel-core/src/transformation/file/file.ts b/packages/babel-core/src/transformation/file/file.ts index 703afe204e1e..0dcf28b31e25 100644 --- a/packages/babel-core/src/transformation/file/file.ts +++ b/packages/babel-core/src/transformation/file/file.ts @@ -187,9 +187,8 @@ export default class File { // make sure that the helper exists helpers.ensure(name, File); - const uid = (this.declarations[name] = this.scope.generateUidIdentifier( - name, - )); + const uid = (this.declarations[name] = + this.scope.generateUidIdentifier(name)); const dependencies = {}; for (const dep of helpers.getDependencies(name)) { diff --git a/packages/babel-core/src/transformation/normalize-file.ts b/packages/babel-core/src/transformation/normalize-file.ts index 2a834cd9d494..bea98cd6413a 100644 --- a/packages/babel-core/src/transformation/normalize-file.ts +++ b/packages/babel-core/src/transformation/normalize-file.ts @@ -76,7 +76,7 @@ export default function* normalizeFile( } else { inputMap = convertSourceMap.fromJSON( // todo: - (inputMapContent as unknown) as string, + inputMapContent as unknown as string, ); } } catch (err) { @@ -99,8 +99,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 a/packages/babel-core/test/helpers/esm.js b/packages/babel-core/test/helpers/esm.js index c485f1fa8422..8565d61e1262 100644 --- a/packages/babel-core/test/helpers/esm.js +++ b/packages/babel-core/test/helpers/esm.js @@ -66,7 +66,8 @@ async function spawn(runner, filename, cwd = process.cwd()) { { cwd, env: process.env }, ); - 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 a/packages/babel-generator/src/buffer.ts b/packages/babel-generator/src/buffer.ts index f94a4d822552..896267ac15ff 100644 --- a/packages/babel-generator/src/buffer.ts +++ b/packages/babel-generator/src/buffer.ts @@ -81,13 +81,8 @@ export default class Buffer { append(str: string): void { this._flush(); - const { - line, - column, - filename, - identifierName, - force, - } = this._sourcePosition; + const { line, column, filename, identifierName, force } = + this._sourcePosition; this._append(str, line, column, identifierName, filename, force); } @@ -103,13 +98,8 @@ export default class Buffer { } } - const { - line, - column, - filename, - identifierName, - force, - } = this._sourcePosition; + const { line, column, filename, identifierName, force } = + this._sourcePosition; this._queue.unshift([str, line, column, identifierName, filename, force]); } diff --git a/packages/babel-generator/src/node/whitespace.ts b/packages/babel-generator/src/node/whitespace.ts index b5de18f3f439..8cec93c688c2 100644 --- a/packages/babel-generator/src/node/whitespace.ts +++ b/packages/babel-generator/src/node/whitespace.ts @@ -200,16 +200,19 @@ export const nodes: { * Test if Property needs whitespace. */ -nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function ( - node: t.ObjectProperty | t.ObjectTypeProperty | t.ObjectMethod, - parent: any, -): WhitespaceObject | undefined | null { - if (parent.properties[0] === node) { - return { - before: true, +nodes.ObjectProperty = + nodes.ObjectTypeProperty = + nodes.ObjectMethod = + function ( + node: t.ObjectProperty | t.ObjectTypeProperty | t.ObjectMethod, + parent: any, + ): WhitespaceObject | undefined | null { + if (parent.properties[0] === node) { + return { + before: true, + }; + } }; - } -}; nodes.ObjectTypeCallProperty = function ( node: t.ObjectTypeCallProperty, @@ -287,14 +290,16 @@ export const list = { * Add whitespace tests for nodes and their aliases. */ -([ - ["Function", true], - ["Class", true], - ["Loop", true], - ["LabeledStatement", true], - ["SwitchStatement", true], - ["TryStatement", true], -] as Array<[string, any]>).forEach(function ([type, amounts]) { +( + [ + ["Function", true], + ["Class", true], + ["Loop", true], + ["LabeledStatement", true], + ["SwitchStatement", true], + ["TryStatement", true], + ] as Array<[string, any]> +).forEach(function ([type, amounts]) { if (typeof amounts === "boolean") { amounts = { after: amounts, before: amounts }; } diff --git a/packages/babel-helper-create-class-features-plugin/src/index.js b/packages/babel-helper-create-class-features-plugin/src/index.js index 19da30a62e03..2534a88132e8 100644 --- a/packages/babel-helper-create-class-features-plugin/src/index.js +++ b/packages/babel-helper-create-class-features-plugin/src/index.js @@ -210,21 +210,17 @@ export function createClassFeaturePlugin({ )); } else { keysNodes = extractComputedKeys(ref, path, computedPaths, this.file); - ({ - staticNodes, - pureStaticNodes, - instanceNodes, - wrapClass, - } = buildFieldsInitNodes( - ref, - path.node.superClass, - props, - privateNamesMap, - state, - setPublicClassFields ?? loose, - privateFieldsAsProperties ?? loose, - constantSuper ?? loose, - )); + ({ staticNodes, pureStaticNodes, instanceNodes, wrapClass } = + buildFieldsInitNodes( + ref, + path.node.superClass, + props, + privateNamesMap, + state, + setPublicClassFields ?? loose, + privateFieldsAsProperties ?? loose, + constantSuper ?? loose, + )); } if (instanceNodes.length > 0) { diff --git a/packages/babel-helper-function-name/src/index.ts b/packages/babel-helper-function-name/src/index.ts index c8ade781a32b..90ee0a80a814 100644 --- a/packages/babel-helper-function-name/src/index.ts +++ b/packages/babel-helper-function-name/src/index.ts @@ -80,16 +80,20 @@ function wrap(state, method, id, scope) { build = buildGeneratorPropertyMethodAssignmentWrapper; } - const template = (build({ - FUNCTION: method, - FUNCTION_ID: id, - FUNCTION_KEY: scope.generateUidIdentifier(id.name), - }) as t.ExpressionStatement).expression as t.CallExpression; + const template = ( + build({ + FUNCTION: method, + FUNCTION_ID: id, + FUNCTION_KEY: scope.generateUidIdentifier(id.name), + }) as t.ExpressionStatement + ).expression as t.CallExpression; // shim in dummy params to retain function arity, if you try to read the // source then you'll get the original since it's proxied so it's all good - const params = (((template.callee as t.FunctionExpression).body - .body[0] as any) as t.FunctionExpression).params; + const params = ( + (template.callee as t.FunctionExpression).body + .body[0] as any as t.FunctionExpression + ).params; for (let i = 0, len = getFunctionArity(method); i < len; i++) { params.push(scope.generateUidIdentifier("x")); diff --git a/packages/babel-helper-module-transforms/src/index.ts b/packages/babel-helper-module-transforms/src/index.ts index 73899d6b8643..826ff2f6d7ab 100644 --- a/packages/babel-helper-module-transforms/src/index.ts +++ b/packages/babel-helper-module-transforms/src/index.ts @@ -279,23 +279,26 @@ function buildESModuleHeader( metadata: ModuleMetadata, enumerableModuleMeta: boolean = false, ) { - return (enumerableModuleMeta - ? template.statement` + return ( + enumerableModuleMeta + ? template.statement` EXPORTS.__esModule = true; ` - : template.statement` + : template.statement` Object.defineProperty(EXPORTS, "__esModule", { value: true, }); - `)({ EXPORTS: metadata.exportName }); + ` + )({ EXPORTS: metadata.exportName }); } /** * Create a re-export initialization loop for a specific imported namespace. */ function buildNamespaceReexport(metadata, namespace, constantReexports) { - return (constantReexports - ? template.statement` + return ( + constantReexports + ? template.statement` Object.keys(NAMESPACE).forEach(function(key) { if (key === "default" || key === "__esModule") return; VERIFY_NAME_LIST; @@ -304,13 +307,13 @@ function buildNamespaceReexport(metadata, namespace, constantReexports) { EXPORTS[key] = NAMESPACE[key]; }); ` - : // Also skip already assigned bindings if they are strictly equal - // to be somewhat more spec-compliant when a file has multiple - // namespace re-exports that would cause a binding to be exported - // multiple times. However, multiple bindings of the same name that - // export the same primitive value are silently skipped - // (the spec requires an "ambigous bindings" early error here). - template.statement` + : // Also skip already assigned bindings if they are strictly equal + // to be somewhat more spec-compliant when a file has multiple + // namespace re-exports that would cause a binding to be exported + // multiple times. However, multiple bindings of the same name that + // export the same primitive value are silently skipped + // (the spec requires an "ambigous bindings" early error here). + template.statement` Object.keys(NAMESPACE).forEach(function(key) { if (key === "default" || key === "__esModule") return; VERIFY_NAME_LIST; @@ -323,7 +326,8 @@ function buildNamespaceReexport(metadata, namespace, constantReexports) { }, }); }); - `)({ + ` + )({ NAMESPACE: namespace, EXPORTS: metadata.exportName, VERIFY_NAME_LIST: metadata.exportNameListName diff --git a/packages/babel-helper-module-transforms/src/rewrite-live-references.ts b/packages/babel-helper-module-transforms/src/rewrite-live-references.ts index 210a63ab3030..84a0a8da90d9 100644 --- a/packages/babel-helper-module-transforms/src/rewrite-live-references.ts +++ b/packages/babel-helper-module-transforms/src/rewrite-live-references.ts @@ -197,13 +197,8 @@ const buildImportThrow = localName => { const rewriteReferencesVisitor: Visitor = { 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 a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index f67e509e9e5d..856ccdeda4f7 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -373,9 +373,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]); @@ -388,9 +387,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); @@ -2067,9 +2065,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 a/packages/babel-parser/src/plugin-utils.js b/packages/babel-parser/src/plugin-utils.js index 194bc1aa7465..a9c8687f524d 100644 --- a/packages/babel-parser/src/plugin-utils.js +++ b/packages/babel-parser/src/plugin-utils.js @@ -150,6 +150,5 @@ export const mixinPlugins: { [name: string]: MixinPlugin } = { placeholders, }; -export const mixinPluginNames: $ReadOnlyArray = Object.keys( - mixinPlugins, -); +export const mixinPluginNames: $ReadOnlyArray = + Object.keys(mixinPlugins); diff --git a/packages/babel-parser/src/plugins/flow/index.js b/packages/babel-parser/src/plugins/flow/index.js index 94169d697ee5..36eb19a7368b 100644 --- a/packages/babel-parser/src/plugins/flow/index.js +++ b/packages/babel-parser/src/plugins/flow/index.js @@ -1350,9 +1350,7 @@ export default (superClass: Class): Class => return this.finishNode(node, "FunctionTypeParam"); } - flowParseFunctionTypeParams( - params: N.FlowFunctionTypeParam[] = [], - ): { + flowParseFunctionTypeParams(params: N.FlowFunctionTypeParam[] = []): { params: N.FlowFunctionTypeParam[], rest: ?N.FlowFunctionTypeParam, _this: ?N.FlowFunctionTypeParam, @@ -3131,7 +3129,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 a/packages/babel-parser/src/plugins/typescript/index.js b/packages/babel-parser/src/plugins/typescript/index.js index f57a4e912421..542c3bc282dd 100644 --- a/packages/babel-parser/src/plugins/typescript/index.js +++ b/packages/babel-parser/src/plugins/typescript/index.js @@ -537,13 +537,11 @@ export default (superClass: Class): Class => this.expect(tt.parenL); signature.parameters = this.tsParseBindingListForSignature(); if (returnTokenRequired) { - signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation( - returnToken, - ); + signature.typeAnnotation = + this.tsParseTypeOrTypePredicateAnnotation(returnToken); } else if (this.match(returnToken)) { - signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation( - returnToken, - ); + signature.typeAnnotation = + this.tsParseTypeOrTypePredicateAnnotation(returnToken); } } diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 0f58039dd221..c3af5a3fd226 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -1176,9 +1176,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 a/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js b/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js index d860d884e82d..e19a775524cf 100644 --- a/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js +++ b/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js @@ -33,9 +33,10 @@ const WARNING_CALLS = new WeakSet(); */ function applyEnsureOrdering(path) { // TODO: This should probably also hoist computed properties. - const decorators = (path.isClass() - ? [path].concat(path.get("body.body")) - : path.get("properties") + const decorators = ( + path.isClass() + ? [path].concat(path.get("body.body")) + : path.get("properties") ).reduce((acc, prop) => acc.concat(prop.node.decorators || []), []); const identDecorators = decorators.filter( @@ -47,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 a/packages/babel-plugin-proposal-object-rest-spread/src/index.js b/packages/babel-plugin-proposal-object-rest-spread/src/index.js index 7305e9635fee..86e5290b8467 100644 --- a/packages/babel-plugin-proposal-object-rest-spread/src/index.js +++ b/packages/babel-plugin-proposal-object-rest-spread/src/index.js @@ -371,11 +371,8 @@ export default declare((api, opts) => { path.isObjectPattern(), ); - const [ - impureComputedPropertyDeclarators, - argument, - callExpression, - ] = createObjectRest(objectPatternPath, file, ref); + const [impureComputedPropertyDeclarators, argument, callExpression] = + createObjectRest(objectPatternPath, file, ref); if (pureGetters) { removeUnusedExcludedKeys(objectPatternPath); @@ -454,11 +451,8 @@ export default declare((api, opts) => { ]), ); - const [ - impureComputedPropertyDeclarators, - argument, - callExpression, - ] = createObjectRest(leftPath, file, t.identifier(refName)); + const [impureComputedPropertyDeclarators, argument, callExpression] = + createObjectRest(leftPath, file, t.identifier(refName)); if (impureComputedPropertyDeclarators.length > 0) { nodes.push( diff --git a/packages/babel-plugin-proposal-optional-chaining/src/transform.js b/packages/babel-plugin-proposal-optional-chaining/src/transform.js index 8bd82a56cb1e..656b4ea09e6c 100644 --- a/packages/babel-plugin-proposal-optional-chaining/src/transform.js +++ b/packages/babel-plugin-proposal-optional-chaining/src/transform.js @@ -169,8 +169,9 @@ export function transform( // i.e. `?.b` in `(a?.b.c)()` if (i === 0 && parentIsCall) { // `(a?.b)()` to `(a == null ? undefined : a.b.bind(a))()` - const object = skipTransparentExprWrappers(replacementPath.get("object")) - .node; + const object = skipTransparentExprWrappers( + replacementPath.get("object"), + ).node; let baseRef; if (!pureGetters || !isSimpleMemberExpression(object)) { // memoize the context object when getters are not always pure diff --git a/packages/babel-plugin-transform-classes/src/transformClass.js b/packages/babel-plugin-transform-classes/src/transformClass.js index 5244e6b64022..ea57e999d71f 100644 --- a/packages/babel-plugin-transform-classes/src/transformClass.js +++ b/packages/babel-plugin-transform-classes/src/transformClass.js @@ -610,9 +610,8 @@ export default function transformClass( annotateAsPure(arg); } - const param = classState.scope.generateUidIdentifierBasedOnNode( - superName, - ); + const param = + classState.scope.generateUidIdentifierBasedOnNode(superName); closureParams.push(param); closureArgs.push(arg); diff --git a/packages/babel-plugin-transform-modules-amd/src/index.js b/packages/babel-plugin-transform-modules-amd/src/index.js index 8abd469222d1..737ef30a146c 100644 --- a/packages/babel-plugin-transform-modules-amd/src/index.js +++ b/packages/babel-plugin-transform-modules-amd/src/index.js @@ -38,13 +38,8 @@ function injectWrapper(path, wrapper) { export default declare((api, options) => { api.assertVersion(7); - const { - allowTopLevelThis, - strict, - strictMode, - importInterop, - noInterop, - } = options; + const { allowTopLevelThis, strict, strictMode, importInterop, noInterop } = + options; const constantReexports = api.assumption("constantReexports") ?? options.loose; diff --git a/packages/babel-plugin-transform-parameters/src/params.js b/packages/babel-plugin-transform-parameters/src/params.js index 335a8e884241..aac3e64bb485 100644 --- a/packages/babel-plugin-transform-parameters/src/params.js +++ b/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 a/packages/babel-plugin-transform-react-display-name/src/index.js b/packages/babel-plugin-transform-react-display-name/src/index.js index dd4f190d87b9..f19c4dd0555f 100644 --- a/packages/babel-plugin-transform-react-display-name/src/index.js +++ b/packages/babel-plugin-transform-react-display-name/src/index.js @@ -25,9 +25,8 @@ export default declare(api => { } } - const isCreateClassCallExpression = t.buildMatchMemberExpression( - "React.createClass", - ); + const isCreateClassCallExpression = + t.buildMatchMemberExpression("React.createClass"); const isCreateClassAddon = callee => callee.name === "createReactClass"; function isCreateClass(node) { diff --git a/packages/babel-plugin-transform-react-jsx-source/src/index.js b/packages/babel-plugin-transform-react-jsx-source/src/index.js index d68649955df0..0f5bee8a3bf9 100644 --- a/packages/babel-plugin-transform-react-jsx-source/src/index.js +++ b/packages/babel-plugin-transform-react-jsx-source/src/index.js @@ -68,9 +68,8 @@ export default declare(api => { if (!state.fileNameIdentifier) { const fileName = state.filename || ""; - const fileNameIdentifier = path.scope.generateUidIdentifier( - FILE_NAME_VAR, - ); + const fileNameIdentifier = + path.scope.generateUidIdentifier(FILE_NAME_VAR); const scope = path.hub.getScope(); if (scope) { scope.push({ diff --git a/packages/babel-standalone/src/generated/plugins.js b/packages/babel-standalone/src/generated/plugins.js index bcf2a29fb33b..8d0b9b6c5dae 100644 --- a/packages/babel-standalone/src/generated/plugins.js +++ b/packages/babel-standalone/src/generated/plugins.js @@ -262,7 +262,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 a/packages/babel-standalone/test/babel.js b/packages/babel-standalone/test/babel.js index 106e687b6986..a221ff970909 100644 --- a/packages/babel-standalone/test/babel.js +++ b/packages/babel-standalone/test/babel.js @@ -58,8 +58,9 @@ const require = createRequire(import.meta.url); ], sourceType: "script", }; - const output = Babel.transformFromAst(ast, "42", { presets: ["es2015"] }) - .code; + const output = Babel.transformFromAst(ast, "42", { + presets: ["es2015"], + }).code; expect(output).toBe("42;"); }); diff --git a/packages/babel-traverse/src/path/conversion.ts b/packages/babel-traverse/src/path/conversion.ts index 5e401415c14e..d92de9b7e978 100644 --- a/packages/babel-traverse/src/path/conversion.ts +++ b/packages/babel-traverse/src/path/conversion.ts @@ -191,13 +191,8 @@ function hoistFunctionEnvironment( ); } - const { - thisPaths, - argumentsPaths, - newTargetPaths, - superProps, - superCalls, - } = getScopeInformation(fnPath); + const { thisPaths, argumentsPaths, newTargetPaths, superProps, superCalls } = + getScopeInformation(fnPath); // Convert all super() calls in the constructor, if super is used in an arrow. if (inConstructor && superCalls.length > 0) { diff --git a/packages/babel-traverse/src/path/evaluation.ts b/packages/babel-traverse/src/path/evaluation.ts index 163e11d9932f..09b509f1b6c2 100644 --- a/packages/babel-traverse/src/path/evaluation.ts +++ b/packages/babel-traverse/src/path/evaluation.ts @@ -432,9 +432,7 @@ function evaluateQuasis(path, quasis: Array, state, raw = false) { * */ -export function evaluate( - this: NodePath, -): { +export function evaluate(this: NodePath): { confident: boolean; value: any; deopt?: NodePath; diff --git a/packages/babel-traverse/src/path/introspection.ts b/packages/babel-traverse/src/path/introspection.ts index 91a0906d83ea..bd569e77e33b 100644 --- a/packages/babel-traverse/src/path/introspection.ts +++ b/packages/babel-traverse/src/path/introspection.ts @@ -175,9 +175,9 @@ export function referencesImport( ? t.isStringLiteral(this.node.property, { value: importName }) : (this.node.property as t.Identifier).name === importName) ) { - const object = (this as NodePath< - t.MemberExpression | t.OptionalMemberExpression - >).get("object"); + const object = ( + this as NodePath + ).get("object"); return ( object.isReferencedIdentifier() && object.referencesImport(moduleSource, "*") diff --git a/packages/babel-types/scripts/generators/docs.js b/packages/babel-types/scripts/generators/docs.js index 1b2b8e2d5d0c..f7b82e56d394 100644 --- a/packages/babel-types/scripts/generators/docs.js +++ b/packages/babel-types/scripts/generators/docs.js @@ -202,8 +202,7 @@ const aliasDescriptions = { FlowDeclaration: "A cover of Flow declarations.", FlowPredicate: "A cover of Flow predicates.", FlowType: "A cover of Flow type annotations.", - For: - "A cover of [ForStatement](https://tc39.es/ecma262/#sec-for-statement)s and [ForXStatement](#forxstatement)s.", + For: "A cover of [ForStatement](https://tc39.es/ecma262/#sec-for-statement)s and [ForXStatement](#forxstatement)s.", ForXStatement: "A cover of [ForInStatements and ForOfStatements](https://tc39.es/ecma262/#sec-for-in-and-for-of-statements).", Function: @@ -212,10 +211,8 @@ const aliasDescriptions = { "A cover of AST nodes that start an execution context with new [VariableEnvironment](https://tc39.es/ecma262/#table-additional-state-components-for-ecmascript-code-execution-contexts). In other words, they define the scope of `var` declarations. FunctionParent did not include `Program` since Babel 7.", Immutable: "A cover of immutable objects and JSX elements. An object is [immutable](https://tc39.es/ecma262/#immutable-prototype-exotic-object) if no other properties can be defined once created.", - JSX: - "A cover of AST nodes defined for [JSX](https://facebook.github.io/jsx/).", - LVal: - "A cover of left hand side expressions used in the `left` of assignment expressions and [ForXStatement](#forxstatement)s. ", + JSX: "A cover of AST nodes defined for [JSX](https://facebook.github.io/jsx/).", + LVal: "A cover of left hand side expressions used in the `left` of assignment expressions and [ForXStatement](#forxstatement)s. ", Literal: "A cover of [Literal](https://tc39.es/ecma262/#sec-primary-expression-literals)s, [Regular Expression Literal](https://tc39.es/ecma262/#sec-primary-expression-regular-expression-literals)s and [Template Literal](https://tc39.es/ecma262/#sec-template-literals)s.", Loop: "A cover of loop statements.", diff --git a/packages/babel-types/src/modifications/prependToMemberExpression.ts b/packages/babel-types/src/modifications/prependToMemberExpression.ts index 804e72d082c2..5988bb2d025f 100644 --- a/packages/babel-types/src/modifications/prependToMemberExpression.ts +++ b/packages/babel-types/src/modifications/prependToMemberExpression.ts @@ -5,7 +5,7 @@ import type * as t from ".."; * Prepend a node to a member expression. */ export default function prependToMemberExpression< - T extends Pick + T extends Pick, >(member: T, prepend: t.MemberExpression["object"]): T { member.object = memberExpression(prepend, member.object); diff --git a/packages/babel-types/src/validators/is.ts b/packages/babel-types/src/validators/is.ts index b6b2f3be7f67..a73a0940748a 100644 --- a/packages/babel-types/src/validators/is.ts +++ b/packages/babel-types/src/validators/is.ts @@ -12,7 +12,7 @@ export default function is( export default function is< T extends t.Node["type"], - P extends Extract + P extends Extract, >(type: T, n: t.Node | null | undefined, required: Partial

): n is P; export default function is

( diff --git a/yarn.lock b/yarn.lock index 929edbed633a..fbb792b4a47c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5646,7 +5646,7 @@ __metadata: lint-staged: ^9.2.0 lodash: ^4.17.21 mergeiterator: ^1.2.5 - prettier: ^2.2.1 + prettier: 2.3.0 rollup: ^2.47.0 rollup-plugin-dts: ^2.0.0 rollup-plugin-node-polyfills: ^0.2.1 @@ -12403,12 +12403,12 @@ fsevents@^1.2.7: languageName: node linkType: hard -"prettier@npm:^2.2.1": - version: 2.2.1 - resolution: "prettier@npm:2.2.1" +"prettier@npm:2.3.0": + version: 2.3.0 + resolution: "prettier@npm:2.3.0" bin: prettier: bin-prettier.js - checksum: 92c6c9f4b87eba1f28466edee57dd18c80d00b858edda77d46d1950d20e6e302b68ee255fc91133ba931e63c4577b5ae30da194d9626a8f3c0177778b91bf056 + checksum: 652640cc8b71bc5277cfb8bf6f161783ca588efcf683c3d630837b39da8d57fef35c9e00ae5855a8e3c75136c42274046c913cc2b2d2968558315f31c6a26981 languageName: node linkType: hard