Bump prettier (#289)

This commit is contained in:
Brian Ng 2017-05-19 15:40:19 -05:00 committed by GitHub
parent e1cb75989f
commit 37c8da674a
12 changed files with 129 additions and 163 deletions

View File

@ -17,6 +17,7 @@
"curly": ["error", "multi-line"],
"func-call-spacing": "error",
"key-spacing": "error",
"no-multi-spaces": "error"
"no-multi-spaces": "error",
"flowtype/generic-spacing": "off"
}
}

View File

@ -79,7 +79,7 @@
"lodash": "^4.17.4",
"mocha": "^3.2.0",
"nyc": "^10.1.2",
"prettier": "^0.22.0",
"prettier": "1.3.1",
"rimraf": "^2.6.1"
},
"babel": {

View File

@ -16,13 +16,10 @@ const electronToChromiumKeys = Object.keys(
electronToChromiumVersions
).reverse();
const chromiumToElectronMap = electronToChromiumKeys.reduce(
(all, electron) => {
const chromiumToElectronMap = electronToChromiumKeys.reduce((all, electron) => {
all[electronToChromiumVersions[electron]] = +electron;
return all;
},
{}
);
}, {});
const chromiumToElectronVersions = Object.keys(chromiumToElectronMap);
const findClosestElectronVersion = targetVersion => {
@ -51,12 +48,11 @@ const renameTests = (tests, getName) =>
const envs = require("compat-table/environments");
const byTestSuite = suite =>
browser => {
const byTestSuite = suite => browser => {
return Array.isArray(browser.test_suites)
? browser.test_suites.indexOf(suite) > -1
: true;
};
};
const es6 = require("compat-table/data-es6");
es6.browsers = pickBy(envs, byTestSuite("es6"));
@ -163,20 +159,24 @@ const compatibilityTests = flattenDeep(
return test.subtests
? [test, renameTests(test.subtests, name => test.name + " / " + name)]
: test;
}))
})
)
);
const getLowestImplementedVersion = ({ features }, env) => {
const tests = flatten(
compatibilityTests
.filter(test => {
return features.indexOf(test.name) >= 0 ||
return (
features.indexOf(test.name) >= 0 ||
// for features === ["DataView"]
// it covers "DataView (Int8)" and "DataView (UInt8)"
(features.length === 1 && test.name.indexOf(features[0]) === 0);
(features.length === 1 && test.name.indexOf(features[0]) === 0)
);
})
.map(test => {
const isBuiltIn = test.category === "built-ins" ||
const isBuiltIn =
test.category === "built-ins" ||
test.category === "built-in extensions";
return test.subtests

View File

@ -14,15 +14,12 @@ export const logMessage = (message, context) => {
export const logPlugin = (plugin, targets, list, context) => {
const envList = list[plugin] || {};
const filteredList = Object.keys(targets).reduce(
(a, b) => {
const filteredList = Object.keys(targets).reduce((a, b) => {
if (!envList[b] || semver.lt(targets[b], semverify(envList[b]))) {
a[b] = prettifyVersion(targets[b]);
}
return a;
},
{},
);
}, {});
const formattedTargets = JSON.stringify(filteredList)
.replace(/\,/g, ", ")

View File

@ -23,8 +23,9 @@ export const isPluginRequired = (
return true;
}
const isRequiredForEnvironments: Array<string> = targetEnvironments.filter(
environment => {
const isRequiredForEnvironments: Array<
string,
> = targetEnvironments.filter(environment => {
// Feature is not implemented in that environment
if (!plugin[environment]) {
return true;
@ -44,8 +45,7 @@ export const isPluginRequired = (
semverify(lowestImplementedVersion),
lowestTargetedVersion,
);
},
);
});
return isRequiredForEnvironments.length > 0;
};
@ -172,7 +172,8 @@ export default function buildPreset(
// NOTE: not giving spec here yet to avoid compatibility issues when
// babel-plugin-transform-es2015-modules-commonjs gets its spec mode
transformations.forEach(pluginName =>
plugins.push([require(`babel-plugin-${pluginName}`), { spec, loose }]));
plugins.push([require(`babel-plugin-${pluginName}`), { spec, loose }]),
);
const regenerator = transformations.has("transform-regenerator");
@ -206,7 +207,8 @@ Using polyfills with \`${useBuiltIns}\` option:`,
regenerator,
onDebug: (polyfills, context) => {
polyfills.forEach(polyfill =>
logPlugin(polyfill, polyfillTargets, builtInsList, context));
logPlugin(polyfill, polyfillTargets, builtInsList, context),
);
},
};

View File

@ -23,8 +23,7 @@ const semverMin = (first: ?string, second: string): string => {
};
const getLowestVersions = (browsers: Array<string>): Targets => {
return browsers.reduce(
(all: Object, browser: string): Object => {
return browsers.reduce((all: Object, browser: string): Object => {
const [browserName, browserVersion] = browser.split(" ");
const normalizedBrowserName = browserNameMap[browserName];
@ -44,9 +43,7 @@ const getLowestVersions = (browsers: Array<string>): Targets => {
} catch (e) {}
return all;
},
{},
);
}, {});
};
const outputDecimalWarning = (decimalTargets: Array<Object>): void => {
@ -57,7 +54,8 @@ const outputDecimalWarning = (decimalTargets: Array<Object>): void => {
console.log("Warning, the following targets are using a decimal version:");
console.log("");
decimalTargets.forEach(({ target, value }) =>
console.log(` ${target}: ${value}`));
console.log(` ${target}: ${value}`),
);
console.log("");
console.log(
"We recommend using a string for minor/patch versions to avoid numbers like 6.10",

View File

@ -28,13 +28,15 @@ export default function({ types: t }: { types: Object }): Plugin {
}
function isRequire(path: Object): boolean {
return t.isExpressionStatement(path.node) &&
return (
t.isExpressionStatement(path.node) &&
t.isCallExpression(path.node.expression) &&
t.isIdentifier(path.node.expression.callee) &&
path.node.expression.callee.name === "require" &&
path.node.expression.arguments.length === 1 &&
t.isStringLiteral(path.node.expression.arguments[0]) &&
isPolyfillSource(path.node.expression.arguments[0].value);
isPolyfillSource(path.node.expression.arguments[0].value)
);
}
function createImport(

View File

@ -38,8 +38,9 @@ const modulePathMap = {
};
const getModulePath = module => {
return modulePathMap[module] ||
`babel-polyfill/lib/core-js/modules/${module}`;
return (
modulePathMap[module] || `babel-polyfill/lib/core-js/modules/${module}`
);
};
export default function({ types: t }: { types: Object }): Plugin {
@ -82,13 +83,15 @@ export default function({ types: t }: { types: Object }): Plugin {
}
function isRequire(path: Object): boolean {
return t.isExpressionStatement(path.node) &&
return (
t.isExpressionStatement(path.node) &&
t.isCallExpression(path.node.expression) &&
t.isIdentifier(path.node.expression.callee) &&
path.node.expression.callee.name === "require" &&
path.node.expression.arguments.length === 1 &&
t.isStringLiteral(path.node.expression.arguments[0]) &&
isPolyfillSource(path.node.expression.arguments[0].value);
isPolyfillSource(path.node.expression.arguments[0].value)
);
}
const addAndRemovePolyfillImports = {

View File

@ -40,8 +40,7 @@ export const prettifyVersion = (version: string): string => {
};
export const prettifyTargets = (targets: Targets): Object => {
return Object.keys(targets).reduce(
(results, target) => {
return Object.keys(targets).reduce((results, target) => {
let value = targets[target];
if (typeof value === "string") {
@ -50,7 +49,5 @@ export const prettifyTargets = (targets: Targets): Object => {
results[target] = value;
return results;
},
{},
);
}, {});
};

View File

@ -56,8 +56,8 @@ const buildTest = opts => {
let stdout = "";
let stderr = "";
spawn.stdout.on("data", chunk => stdout += chunk);
spawn.stderr.on("data", chunk => stderr += chunk);
spawn.stdout.on("data", chunk => (stdout += chunk));
spawn.stderr.on("data", chunk => (stderr += chunk));
spawn.on("close", () => {
let err;

View File

@ -67,24 +67,18 @@ describe("normalize-options", () => {
describe("checkDuplicateIncludeExcludes", function() {
it("should throw if duplicate names in both", function() {
assert.throws(
() => {
assert.throws(() => {
checkDuplicateIncludeExcludes(
["transform-regenerator", "map"],
["transform-regenerator", "map"],
);
},
Error,
);
}, Error);
});
it("should not throw if no duplicate names in both", function() {
assert.doesNotThrow(
() => {
assert.doesNotThrow(() => {
checkDuplicateIncludeExcludes(["transform-regenerator"], ["map"]);
},
Error,
);
}, Error);
});
});
@ -100,12 +94,9 @@ describe("normalize-options", () => {
});
it("should not throw if no duplicate names in both", function() {
assert.doesNotThrow(
() => {
assert.doesNotThrow(() => {
checkDuplicateIncludeExcludes(["transform-regenerator"], ["map"]);
},
Error,
);
}, Error);
});
});
@ -135,21 +126,15 @@ describe("normalize-options", () => {
});
it("`true` option is invalid", () => {
assert.throws(
() => {
assert.throws(() => {
validateModulesOption(true);
},
Error,
);
}, Error);
});
it("array option is invalid", () => {
assert.throws(
() => {
assert.throws(() => {
assert(validateModulesOption([]));
},
Error,
);
}, Error);
});
});
describe("validateIncludesAndExcludes", function() {
@ -157,12 +142,9 @@ describe("normalize-options", () => {
assert.deepEqual(validateIncludesAndExcludes(), []);
});
it("should throw if not in features", function() {
assert.throws(
() => {
assert.throws(() => {
validateIncludesAndExcludes(["asdf"]);
},
Error,
);
}, Error);
});
});
});

View File

@ -178,18 +178,14 @@ assertion-error@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
ast-types@0.8.18:
version "0.8.18"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.18.tgz#c8b98574898e8914e9d8de74b947564a9fe929af"
ast-types@0.9.4:
version "0.9.4"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.4.tgz#410d1f81890aeb8e0a38621558ba5869ae53c91b"
ast-types@0.9.6:
version "0.9.6"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.6.tgz#102c9e9e9005d3e7e3829bf0c4fa24ee862ee9b9"
ast-types@0.9.8:
version "0.9.8"
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.8.tgz#6cb6a40beba31f49f20928e28439fc14a3dab078"
astquery@latest:
version "0.0.11"
resolved "https://registry.yarnpkg.com/astquery/-/astquery-0.0.11.tgz#1538c54d3f3a788c362942ef2bab139036fe9cdd"
@ -1609,10 +1605,6 @@ babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24
lodash "^4.2.0"
to-fast-properties "^1.0.1"
babylon@6.15.0:
version "6.15.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e"
babylon@7.0.0-beta.4:
version "7.0.0-beta.4"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.4.tgz#82db799d2667f61bbaf34456dbfa91c37613459d"
@ -1879,10 +1871,6 @@ color-name@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.2.tgz#5c8ab72b64bd2215d617ae9559ebb148475cf98d"
colors@>=0.6.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"
combined-stream@^1.0.5, combined-stream@~1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009"
@ -2563,13 +2551,9 @@ flow-bin@^0.46.0:
version "0.46.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.46.0.tgz#06ad7fe19dddb1042264438064a2a32fee12b872"
flow-parser@0.40.0:
version "0.40.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.40.0.tgz#b3444742189093323c4319c4fe9d35391f46bcbc"
dependencies:
ast-types "0.8.18"
colors ">=0.6.2"
minimist ">=0.2.0"
flow-parser@0.45.0:
version "0.45.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.45.0.tgz#aa29d4ae27f06aa02817772bba0fcbefef7e62f0"
for-in@^1.0.1:
version "1.0.2"
@ -3524,7 +3508,7 @@ minimist@0.0.8, minimist@~0.0.1:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
minimist@1.2.0, minimist@>=0.2.0, minimist@^1.2.0:
minimist@1.2.0, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
@ -3914,16 +3898,16 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
prettier@^0.22.0:
version "0.22.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-0.22.0.tgz#7b37c4480d0858180407e5a8e13f0f47da7385d2"
prettier@1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.3.1.tgz#fa0ea84b45ac0ba6de6a1e4cecdcff900d563151"
dependencies:
ast-types "0.9.4"
ast-types "0.9.8"
babel-code-frame "6.22.0"
babylon "6.15.0"
babylon "7.0.0-beta.8"
chalk "1.1.3"
esutils "2.0.2"
flow-parser "0.40.0"
flow-parser "0.45.0"
get-stdin "5.0.1"
glob "7.1.1"
jest-validate "19.0.0"
@ -4154,7 +4138,7 @@ repeating@^2.0.0:
dependencies:
is-finite "^1.0.0"
request@2.79.0:
request@2.79.0, request@^2.55.0:
version "2.79.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de"
dependencies:
@ -4179,7 +4163,7 @@ request@2.79.0:
tunnel-agent "~0.4.1"
uuid "^3.0.0"
request@^2.55.0, request@^2.81.0:
request@^2.81.0:
version "2.81.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
dependencies: