Run prettier

This commit is contained in:
Brian Ng
2017-06-27 12:15:00 -05:00
parent 93cc22dae1
commit e4b35f680d
307 changed files with 6742 additions and 4080 deletions

View File

@@ -24,9 +24,21 @@ function collect(value, previousValue): Array<string> {
/* eslint-disable max-len */
program.option("-e, --eval [script]", "Evaluate script");
program.option("-p, --print [code]", "Evaluate script and print result");
program.option("-o, --only [globs]", "A comma-separated list of glob patterns to compile", collect);
program.option("-i, --ignore [globs]", "A comma-separated list of glob patterns to skip compiling", collect);
program.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js,.es,.jsx,.mjs]", collect);
program.option(
"-o, --only [globs]",
"A comma-separated list of glob patterns to compile",
collect,
);
program.option(
"-i, --ignore [globs]",
"A comma-separated list of glob patterns to skip compiling",
collect,
);
program.option(
"-x, --extensions [extensions]",
"List of extensions to hook into [.es6,.js,.es,.jsx,.mjs]",
collect,
);
program.option("-w, --plugins [string]", "", collect);
program.option("-b, --presets [string]", "", collect);
/* eslint-enable max-len */
@@ -55,23 +67,28 @@ const replPlugin = ({ types: t }) => ({
VariableDeclaration(path) {
if (path.node.kind !== "var") {
throw path.buildCodeFrameError("Only `var` variables are supported in the REPL");
throw path.buildCodeFrameError(
"Only `var` variables are supported in the REPL",
);
}
},
Program(path) {
if (path.get("body").some((child) => child.isExpressionStatement())) return;
if (path.get("body").some(child => child.isExpressionStatement())) return;
// If the executed code doesn't evaluate to a value,
// prevent implicit strict mode from printing 'use strict'.
path.pushContainer("body", t.expressionStatement(t.identifier("undefined")));
path.pushContainer(
"body",
t.expressionStatement(t.identifier("undefined")),
);
},
},
});
//
const _eval = function (code, filename) {
const _eval = function(code, filename) {
code = code.trim();
if (!code) return undefined;
@@ -113,7 +130,7 @@ if (program.eval || program.print) {
let i = 0;
let ignoreNext = false;
args.some(function (arg, i2) {
args.some(function(arg, i2) {
if (ignoreNext) {
ignoreNext = false;
return;
@@ -133,7 +150,9 @@ if (program.eval || program.print) {
// make the filename absolute
const filename = args[0];
if (!path.isAbsolute(filename)) args[0] = path.join(process.cwd(), filename);
if (!path.isAbsolute(filename)) {
args[0] = path.join(process.cwd(), filename);
}
// add back on node and concat the sliced args
process.argv = ["node"].concat(args);