Run Prettier on all source files (#1648)

This commit updates `npm run format:all` to not only format .js files in
src/ and bin/, but also tests_config/ and scripts/, as well as all
jsfmt.spec.js files.

It also includes the result of running `npm run format:all`, except
changes to src/ and bin/.
master
Simon Lydell 2017-05-21 17:13:11 +02:00 committed by Christopher Chedeau
parent 226adb2e81
commit bc5186e544
17 changed files with 25 additions and 19 deletions

View File

@ -39,7 +39,7 @@
"test": "jest",
"format": "./bin/prettier.js --write",
"format:single": "npm run format -- src/printer.js",
"format:all": "npm run format -- index.js src/*.js bin/*.js",
"format:all": "npm run format -- index.js \"{src,bin,tests_config,scripts}/*.js\" \"tests/**/jsfmt.spec.js\"",
"build:docs": "rollup -c docs/rollup.config.js"
},
"jest": {

View File

@ -36,7 +36,7 @@ function syncTests(syncDir) {
"Couldn't find any files to copy.",
`Please make sure that \`${syncDir}\` exists and contains the flow tests.`
].join("\n")
)
);
}
const specContents = specFiles.reduce((obj, specFile) => {

View File

@ -1,2 +1,2 @@
run_spec(__dirname);
run_spec(__dirname, { trailingComma: 'all' });
run_spec(__dirname, { trailingComma: "all" });

View File

@ -1,2 +1,2 @@
run_spec(__dirname, null, ["typescript"]);
run_spec(__dirname, { bracketSpacing: false }, ["typescript"]);
run_spec(__dirname, { bracketSpacing: false }, ["typescript"]);

View File

@ -1,3 +1,3 @@
run_spec(__dirname);
// FIXME export_default_function_declaration_async.js flow != babylon output
run_spec(__dirname, { parser: "babylon" });
run_spec(__dirname, { parser: "babylon" });

View File

@ -1,2 +1,2 @@
run_spec(__dirname, null, ["typescript"]);
run_spec(__dirname, { bracketSpacing: false }, ["typescript"]);
run_spec(__dirname, { bracketSpacing: false }, ["typescript"]);

View File

@ -1,3 +1,3 @@
run_spec(__dirname);
// FIXME arrow.js flow != babylon output
run_spec(__dirname, { parser: "babylon" });
run_spec(__dirname, { parser: "babylon" });

View File

@ -1,2 +1,2 @@
run_spec(__dirname, null, ["babylon"]);
run_spec(__dirname, { trailingComma: 'all' }, ["babylon"]);
run_spec(__dirname, { trailingComma: "all" }, ["babylon"]);

View File

@ -1,2 +1,2 @@
run_spec(__dirname);
run_spec(__dirname, {trailingComma: 'all'});
run_spec(__dirname, { trailingComma: "all" });

View File

@ -1,3 +1,3 @@
run_spec(__dirname)
run_spec(__dirname);
// FIXME nbsp.js flow != babylon output, waiting for: https://github.com/babel/babylon/pull/344
run_spec(__dirname, { parser: "babylon" });

View File

@ -1,2 +1,2 @@
run_spec(__dirname);
run_spec(__dirname, { singleQuote: true });
run_spec(__dirname, { singleQuote: true });

View File

@ -1,2 +1,2 @@
run_spec(__dirname);
run_spec(__dirname, { tabWidth: 4 });
run_spec(__dirname, { tabWidth: 4 });

View File

@ -1,2 +1,2 @@
run_spec(__dirname, null, ["typescript"]);
run_spec(__dirname, {useTabs: true, tabWidth: 8}, ["typescript"]);
run_spec(__dirname, { useTabs: true, tabWidth: 8 }, ["typescript"]);

View File

@ -1,2 +1,2 @@
run_spec(__dirname, null, ["typescript"]);
run_spec(__dirname, { tabWidth: 4 }, ["typescript"]);
run_spec(__dirname, { tabWidth: 4 }, ["typescript"]);

View File

@ -1 +1 @@
run_spec(__dirname, {parser: "typescript"});
run_spec(__dirname, { parser: "typescript" });

View File

@ -1 +1 @@
run_spec(__dirname, {parser: "typescript"});
run_spec(__dirname, { parser: "typescript" });

View File

@ -5,7 +5,7 @@ const extname = require("path").extname;
const prettier = require("../");
const types = require("../src/ast-types");
const parser = require("../src/parser");
const massageAST = require('../src/clean-ast.js').massageAST;
const massageAST = require("../src/clean-ast.js").massageAST;
const AST_COMPARE = process.env["AST_COMPARE"];
const VERIFY_ALL_PARSERS = process.env["VERIFY_ALL_PARSERS"] || false;
@ -48,7 +48,10 @@ function run_spec(dirname, options, additionalParsers) {
let ppastMassaged;
let pperr = null;
try {
const ppast = parse(prettyprint(source, path, mergedOptions), mergedOptions)
const ppast = parse(
prettyprint(source, path, mergedOptions),
mergedOptions
);
ppastMassaged = massageAST(ppast);
} catch (e) {
pperr = e.stack;
@ -75,7 +78,10 @@ function stripLocation(ast) {
const newObj = {};
for (var key in ast) {
if (
key === "loc" || key === "range" || key === "raw" || key === "comments"
key === "loc" ||
key === "range" ||
key === "raw" ||
key === "comments"
) {
continue;
}