diff --git a/package.json b/package.json index b1978242ab..b9070b1012 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "mocha": "^3.0.0", "nyc": "^11.0.3", "output-file-sync": "^2.0.0", - "prettier": "1.7.3", + "prettier": "1.9.1", "pump": "^1.0.2", "rimraf": "^2.4.3", "semver": "^5.0.0", diff --git a/packages/babel-core/src/config/build-config-chain.js b/packages/babel-core/src/config/build-config-chain.js index 27d6ac99c0..00cdfab2d0 100644 --- a/packages/babel-core/src/config/build-config-chain.js +++ b/packages/babel-core/src/config/build-config-chain.js @@ -88,7 +88,9 @@ class ConfigChainBuilder { mergeConfigFile(file: ConfigFile, envName: string) { if (this.seenFiles.has(file)) { throw new Error( - `Cycle detected in Babel configuration file through "${file.filepath}".`, + `Cycle detected in Babel configuration file through "${ + file.filepath + }".`, ); } diff --git a/packages/babel-core/src/config/option-assertions.js b/packages/babel-core/src/config/option-assertions.js index 8cdb7a5000..facdbbf345 100644 --- a/packages/babel-core/src/config/option-assertions.js +++ b/packages/babel-core/src/config/option-assertions.js @@ -191,9 +191,9 @@ function assertPluginTarget( typeof value !== "function" ) { throw new Error( - `.${key}[${index}]${inArray - ? `[0]` - : ""} must be a string, object, function`, + `.${key}[${index}]${ + inArray ? `[0]` : "" + } must be a string, object, function`, ); } return value; diff --git a/packages/babel-helper-fixtures/src/index.js b/packages/babel-helper-fixtures/src/index.js index 3b664801c4..9d02acdc4c 100644 --- a/packages/babel-helper-fixtures/src/index.js +++ b/packages/babel-helper-fixtures/src/index.js @@ -164,7 +164,9 @@ export default function get(entryLoc): Array { if (minimumVersion == null) { throw new Error( - `'minNodeVersion' has invalid semver format: ${taskOpts.minNodeVersion}`, + `'minNodeVersion' has invalid semver format: ${ + taskOpts.minNodeVersion + }`, ); } diff --git a/packages/babel-plugin-transform-modules-amd/src/index.js b/packages/babel-plugin-transform-modules-amd/src/index.js index 9749f35447..fe1744f4b3 100644 --- a/packages/babel-plugin-transform-modules-amd/src/index.js +++ b/packages/babel-plugin-transform-modules-amd/src/index.js @@ -25,16 +25,16 @@ export default function(api, options) { let moduleName = this.getModuleName(); if (moduleName) moduleName = t.stringLiteral(moduleName); - const { - meta, - headers, - } = rewriteModuleStatementsAndPrepareHeader(path, { - loose, - strict, - strictMode, - allowTopLevelThis, - noInterop, - }); + const { meta, headers } = rewriteModuleStatementsAndPrepareHeader( + path, + { + loose, + strict, + strictMode, + allowTopLevelThis, + noInterop, + }, + ); const amdArgs = []; const importNames = []; diff --git a/packages/babel-plugin-transform-modules-commonjs/src/index.js b/packages/babel-plugin-transform-modules-commonjs/src/index.js index b0066a9774..b6607a8144 100644 --- a/packages/babel-plugin-transform-modules-commonjs/src/index.js +++ b/packages/babel-plugin-transform-modules-commonjs/src/index.js @@ -113,17 +113,17 @@ export default function(api, options) { let moduleName = this.getModuleName(); if (moduleName) moduleName = t.stringLiteral(moduleName); - const { - meta, - headers, - } = rewriteModuleStatementsAndPrepareHeader(path, { - exportName: "exports", - loose, - strict, - strictMode, - allowTopLevelThis, - noInterop, - }); + const { meta, headers } = rewriteModuleStatementsAndPrepareHeader( + path, + { + exportName: "exports", + loose, + strict, + strictMode, + allowTopLevelThis, + noInterop, + }, + ); for (const [source, metadata] of meta.source) { const loadExpr = t.callExpression(t.identifier("require"), [ diff --git a/packages/babel-plugin-transform-modules-umd/src/index.js b/packages/babel-plugin-transform-modules-umd/src/index.js index e9c249eb50..d55df24fd8 100644 --- a/packages/babel-plugin-transform-modules-umd/src/index.js +++ b/packages/babel-plugin-transform-modules-umd/src/index.js @@ -130,16 +130,16 @@ export default function(api, options) { let moduleName = this.getModuleName(); if (moduleName) moduleName = t.stringLiteral(moduleName); - const { - meta, - headers, - } = rewriteModuleStatementsAndPrepareHeader(path, { - loose, - strict, - strictMode, - allowTopLevelThis, - noInterop, - }); + const { meta, headers } = rewriteModuleStatementsAndPrepareHeader( + path, + { + loose, + strict, + strictMode, + allowTopLevelThis, + noInterop, + }, + ); const amdArgs = []; const commonjsArgs = []; diff --git a/packages/babel-preset-env/scripts/build-data.js b/packages/babel-preset-env/scripts/build-data.js index b477b8ac44..4fe5b2f191 100644 --- a/packages/babel-preset-env/scripts/build-data.js +++ b/packages/babel-preset-env/scripts/build-data.js @@ -54,16 +54,15 @@ const byTestSuite = suite => browser => { : true; }; -const compatSources = [ - "es6", - "es2016plus", - "esnext", -].reduce((result, source) => { - const data = require(`compat-table/data-${source}`); - data.browsers = pickBy(envs, byTestSuite(source)); - result.push(data); - return result; -}, []); +const compatSources = ["es6", "es2016plus", "esnext"].reduce( + (result, source) => { + const data = require(`compat-table/data-${source}`); + data.browsers = pickBy(envs, byTestSuite(source)); + result.push(data); + return result; + }, + [] +); const interpolateAllResults = (rawBrowsers, tests) => { const interpolateResults = res => { diff --git a/packages/babel-preset-env/src/index.js b/packages/babel-preset-env/src/index.js index ed572ae626..dac89702d3 100644 --- a/packages/babel-preset-env/src/index.js +++ b/packages/babel-preset-env/src/index.js @@ -56,36 +56,36 @@ export const isPluginRequired = ( return true; } - const isRequiredForEnvironments: Array< - string, - > = targetEnvironments.filter(environment => { - // Feature is not implemented in that environment - if (!plugin[environment]) { - return true; - } + const isRequiredForEnvironments: Array = targetEnvironments.filter( + environment => { + // Feature is not implemented in that environment + if (!plugin[environment]) { + return true; + } - const lowestImplementedVersion: string = plugin[environment]; - const lowestTargetedVersion: string = supportedEnvironments[environment]; - // If targets has unreleased value as a lowest version, then don't require a plugin. - if (isUnreleasedVersion(lowestTargetedVersion, environment)) { - return false; - // Include plugin if it is supported in the unreleased environment, which wasn't specified in targets - } else if (isUnreleasedVersion(lowestImplementedVersion, environment)) { - return true; - } + const lowestImplementedVersion: string = plugin[environment]; + const lowestTargetedVersion: string = supportedEnvironments[environment]; + // If targets has unreleased value as a lowest version, then don't require a plugin. + if (isUnreleasedVersion(lowestTargetedVersion, environment)) { + return false; + // Include plugin if it is supported in the unreleased environment, which wasn't specified in targets + } else if (isUnreleasedVersion(lowestImplementedVersion, environment)) { + return true; + } - if (!semver.valid(lowestTargetedVersion)) { - throw new Error( - // eslint-disable-next-line max-len - `Invalid version passed for target "${environment}": "${lowestTargetedVersion}". Versions must be in semver format (major.minor.patch)`, + if (!semver.valid(lowestTargetedVersion)) { + throw new Error( + // eslint-disable-next-line max-len + `Invalid version passed for target "${environment}": "${lowestTargetedVersion}". Versions must be in semver format (major.minor.patch)`, + ); + } + + return semver.gt( + semverify(lowestImplementedVersion), + lowestTargetedVersion, ); - } - - return semver.gt( - semverify(lowestImplementedVersion), - lowestTargetedVersion, - ); - }); + }, + ); return isRequiredForEnvironments.length > 0; }; diff --git a/packages/babel-template/src/formatters.js b/packages/babel-template/src/formatters.js index ccb7433112..e665e343be 100644 --- a/packages/babel-template/src/formatters.js +++ b/packages/babel-template/src/formatters.js @@ -37,20 +37,20 @@ export const statements: Formatter< Array, > = makeStatementFormatter(body => body); -export const statement: Formatter< - BabelNodeStatement, -> = makeStatementFormatter(body => { - // We do this validation when unwrapping since the replacement process - // could have added or removed statements. - if (body.length === 0) { - throw new Error("Found nothing to return."); - } - if (body.length > 1) { - throw new Error("Found multiple statements but wanted one"); - } +export const statement: Formatter = makeStatementFormatter( + body => { + // We do this validation when unwrapping since the replacement process + // could have added or removed statements. + if (body.length === 0) { + throw new Error("Found nothing to return."); + } + if (body.length > 1) { + throw new Error("Found multiple statements but wanted one"); + } - return body[0]; -}); + return body[0]; + }, +); export const expression: Formatter = { code: str => `(\n${str}\n)`, diff --git a/packages/babel-template/src/populate.js b/packages/babel-template/src/populate.js index d4fa00dec1..9f8a25f145 100644 --- a/packages/babel-template/src/populate.js +++ b/packages/babel-template/src/populate.js @@ -38,7 +38,9 @@ export default function populatePlaceholders( (replacements && replacements[placeholder.name]) || null, ); } catch (e) { - e.message = `babel-template placeholder "${placeholder.name}": ${e.message}`; + e.message = `babel-template placeholder "${placeholder.name}": ${ + e.message + }`; throw e; } }); diff --git a/packages/babel-traverse/src/index.js b/packages/babel-traverse/src/index.js index 3b95648570..db1898f5d5 100644 --- a/packages/babel-traverse/src/index.js +++ b/packages/babel-traverse/src/index.js @@ -24,7 +24,9 @@ export default function traverse( if (parent.type !== "Program" && parent.type !== "File") { throw new Error( "You must pass a scope and parentPath unless traversing a Program/File. " + - `Instead of that you tried to traverse a ${parent.type} node without ` + + `Instead of that you tried to traverse a ${ + parent.type + } node without ` + "passing scope and parentPath.", ); } diff --git a/packages/babel-types/src/builders/builder.js b/packages/babel-types/src/builders/builder.js index 45c30c2f26..7458eb1c92 100644 --- a/packages/babel-types/src/builders/builder.js +++ b/packages/babel-types/src/builders/builder.js @@ -8,7 +8,9 @@ export default function builder(type: string, ...args: Array): Object { const countArgs = args.length; if (countArgs > keys.length) { throw new Error( - `${type}: Too many arguments passed. Received ${countArgs} but can receive no more than ${keys.length}`, + `${type}: Too many arguments passed. Received ${countArgs} but can receive no more than ${ + keys.length + }`, ); } diff --git a/packages/babel-types/src/definitions/utils.js b/packages/babel-types/src/definitions/utils.js index d87826a30a..75aa6841d6 100644 --- a/packages/babel-types/src/definitions/utils.js +++ b/packages/babel-types/src/definitions/utils.js @@ -61,9 +61,10 @@ export function assertNodeType(...types: Array): Function { if (!valid) { throw new TypeError( - `Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify( - types, - )} ` + `but instead got ${JSON.stringify(val && val.type)}`, + `Property ${key} of ${ + node.type + } expected node to be of a type ${JSON.stringify(types)} ` + + `but instead got ${JSON.stringify(val && val.type)}`, ); } } @@ -86,9 +87,10 @@ export function assertNodeOrValueType(...types: Array): Function { if (!valid) { throw new TypeError( - `Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify( - types, - )} ` + `but instead got ${JSON.stringify(val && val.type)}`, + `Property ${key} of ${ + node.type + } expected node to be of a type ${JSON.stringify(types)} ` + + `but instead got ${JSON.stringify(val && val.type)}`, ); } } diff --git a/packages/babylon/src/parser/expression.js b/packages/babylon/src/parser/expression.js index 7c0edbadac..f16bb48206 100644 --- a/packages/babylon/src/parser/expression.js +++ b/packages/babylon/src/parser/expression.js @@ -885,7 +885,9 @@ export default class ExpressionParser extends LValParser { if (node.property.name !== propertyName) { this.raise( node.property.start, - `The only valid meta property for ${meta.name} is ${meta.name}.${propertyName}`, + `The only valid meta property for ${meta.name} is ${ + meta.name + }.${propertyName}`, ); } diff --git a/packages/babylon/src/plugins/typescript.js b/packages/babylon/src/plugins/typescript.js index 73b185ecb5..cd9e7fc353 100644 --- a/packages/babylon/src/plugins/typescript.js +++ b/packages/babylon/src/plugins/typescript.js @@ -151,9 +151,9 @@ export default (superClass: Class): Class => } /** - * If !expectSuccess, returns undefined instead of failing to parse. - * If expectSuccess, parseElement should always return a defined value. - */ + * If !expectSuccess, returns undefined instead of failing to parse. + * If expectSuccess, parseElement should always return a defined value. + */ tsParseDelimitedListWorker( kind: ParsingContext, parseElement: () => ?T, diff --git a/scripts/generate-interfaces.js b/scripts/generate-interfaces.js index 1e8864754d..9fc78bfd73 100644 --- a/scripts/generate-interfaces.js +++ b/scripts/generate-interfaces.js @@ -124,9 +124,9 @@ for (const type in t.NODE_FIELDS) { } for (let i = 0; i < t.TYPES.length; i++) { - let decl = `declare function is${t.TYPES[ - i - ]}(node: Object, opts?: ?Object): boolean`; + let decl = `declare function is${ + t.TYPES[i] + }(node: Object, opts?: ?Object): boolean`; if (t.NODE_FIELDS[t.TYPES[i]]) { decl += ` %checks (node instanceof ${NODE_PREFIX}${t.TYPES[i]})`; diff --git a/yarn.lock b/yarn.lock index c6a7306f2d..62ee2db133 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5059,9 +5059,9 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier@1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.3.tgz#8e6974725273914b1c47439959dd3d3ba53664b6" +prettier@1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.9.1.tgz#41638a0d47c1efbd1b7d5a742aaa5548eab86d70" pretty-format@^21.2.1: version "21.2.1"