Skip to content

Commit

Permalink
chore(utils): refactors ast utils
Browse files Browse the repository at this point in the history
refactored ast utils
  • Loading branch information
pranshuchittora committed Jun 4, 2019
1 parent 71a58b6 commit 9f35073
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions packages/utils/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function createLiteral(j: JSCodeshift, val: valueType): Node {
literalVal = true;
}
// 'false' => false
if (val === "false") {
else if (val === "false") {
literalVal = false;
}
// '1' => 1
Expand Down Expand Up @@ -585,11 +585,7 @@ function parseTopScope(j: JSCodeshift, ast: Node, value: string[], action: strin
);
return false; // TODO: debug later
}
if (value) {
return ast.find(j.Program).filter((p: Node): boolean => createTopScopeProperty(p));
} else {
return ast;
}
return value ? ast.find(j.Program).filter((p: Node): boolean => createTopScopeProperty(p)) : ast;
}

/**
Expand Down Expand Up @@ -632,11 +628,7 @@ function parseMerge(j: JSCodeshift, ast: Node, value: string, action: string): b
(p.value as Node).body[bodyLength - 1] = newVal;
return false; // TODO: debug later
}
if (value) {
return ast.find(j.Program).filter((p: Node): boolean => createMergeProperty(p));
} else {
return ast;
}
return value ? ast.find(j.Program).filter((p: Node): boolean => createMergeProperty(p)) : ast;
}

export {
Expand Down

0 comments on commit 9f35073

Please sign in to comment.