Fix block statement code style. (#3493)

This commit is contained in:
Logan Smyth 2016-05-02 18:15:37 -07:00 committed by Henry Zhu
parent bf5de6bcb7
commit 9843c87573
12 changed files with 16 additions and 16 deletions

View File

@ -21,7 +21,7 @@ if (argSeparator > -1) {
}
getV8Flags(function (err, v8Flags) {
babelArgs.forEach(function(arg){
babelArgs.forEach(function(arg) {
let flag = arg.split("=")[0];
switch (flag) {

View File

@ -26,7 +26,7 @@ export default new Plugin({
}
if (!hasChange) return;
node.body = sortBy(node.body, function(bodyNode){
node.body = sortBy(node.body, function(bodyNode) {
let priority = bodyNode && bodyNode._blockHoist;
if (priority == null) priority = 1;
if (priority === true) priority = 2;

View File

@ -4,7 +4,7 @@ import * as t from "babel-types";
const SUPER_THIS_BOUND = Symbol("super this bound");
const superVisitor = {
CallExpression(path){
CallExpression(path) {
if (!path.get("callee").isSuper()) return;
const {node} = path;
@ -71,7 +71,7 @@ function remap(path, key) {
return false;
});
if (shadowFunction && fnPath.isProgram() && !shadowFunction.isProgram()){
if (shadowFunction && fnPath.isProgram() && !shadowFunction.isProgram()) {
// If the shadow wasn't found, take the closest function as a backup.
// This is a bit of a hack, but it will allow the parameter transforms to work properly
// without introducing yet another shadow-controlling flag.
@ -92,7 +92,7 @@ function remap(path, key) {
fnPath.setData(key, id);
if (key === "this" && fnPath.isMethod({kind: "constructor"})){
if (key === "this" && fnPath.isMethod({kind: "constructor"})) {
fnPath.scope.push({ id });
fnPath.traverse(superVisitor, { id });

View File

@ -8,7 +8,7 @@ export default function ({ types: t }) {
return {
visitor: {
ExportDefaultDeclaration(path){
ExportDefaultDeclaration(path) {
if (!path.get("declaration").isClassDeclaration()) return;
let { node } = path;

View File

@ -327,14 +327,14 @@ export default function ({ types: t }) {
return {
visitor: {
ExportNamedDeclaration(path){
ExportNamedDeclaration(path) {
let declaration = path.get("declaration");
if (!declaration.isVariableDeclaration()) return;
if (!variableDeclarationHasPattern(declaration.node)) return;
let specifiers = [];
for (let name in path.getOuterBindingIdentifiers(path)){
for (let name in path.getOuterBindingIdentifiers(path)) {
let id = t.identifier(name);
specifiers.push(t.exportSpecifier(id, id));
}

View File

@ -146,7 +146,7 @@ function getOuterFnExpr(funPath) {
let node = funPath.node;
t.assertFunction(node);
if (!node.id){
if (!node.id) {
// Default-exported function declarations, and function expressions may not
// have a name to reference, so we explicitly add one.
node.id = funPath.scope.parent.generateUidIdentifier("callee");

View File

@ -13,7 +13,7 @@ import "babel-regenerator-runtime";
import "core-js/fn/regexp/escape";
let DEFINE_PROPERTY = "defineProperty";
function define(O, key, value){
function define(O, key, value) {
O[key] || Object[DEFINE_PROPERTY](O, key, {
writable: true,
configurable: true,
@ -24,6 +24,6 @@ function define(O, key, value){
define(String.prototype, "padLeft", "".padStart);
define(String.prototype, "padRight", "".padEnd);
"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function(key){
"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function(key) {
[][key] && define(Array, key, Function.call.bind([][key]));
});

View File

@ -36,7 +36,7 @@ let maps = {};
let cwd = process.cwd();
function getRelativePath(filename){
function getRelativePath(filename) {
return path.relative(cwd, filename);
}

View File

@ -104,7 +104,7 @@ export default class TraversalContext {
for (let path of queue) {
path.resync();
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this){
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
// The context might already have been pushed when this path was inserted and queued.
// If we always re-pushed here, we could get duplicates and risk leaving contexts
// on the stack after the traversal has completed, which could break things.

View File

@ -221,7 +221,7 @@ export function requeue(pathToQueue = this) {
}
}
export function _getQueueContexts(){
export function _getQueueContexts() {
let path = this;
let contexts = this.contexts;
while (!contexts.length) {

View File

@ -219,7 +219,7 @@ function ensureEntranceObjects(obj) {
}
}
function ensureCallbackArrays(obj){
function ensureCallbackArrays(obj) {
if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];
if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];
}

View File

@ -119,7 +119,7 @@ export function isReferenced(node: Object, parent: Object): boolean {
case "ClassExpression":
return parent.id !== node;
// yes: class { [NODE](){} }
// yes: class { [NODE]() {} }
case "ClassMethod":
case "ObjectMethod":
return parent.key === node && parent.computed;