Run prettier
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import explode from "babel-helper-explode-assignable-expression";
|
||||
import * as t from "babel-types";
|
||||
|
||||
export default function (opts: {
|
||||
build: Function;
|
||||
operator: string;
|
||||
}): Object {
|
||||
export default function(opts: { build: Function, operator: string }): Object {
|
||||
const visitor = {};
|
||||
|
||||
function isAssignment(node) {
|
||||
@@ -15,7 +12,7 @@ export default function (opts: {
|
||||
return t.assignmentExpression("=", left, right);
|
||||
}
|
||||
|
||||
visitor.ExpressionStatement = function (path, file) {
|
||||
visitor.ExpressionStatement = function(path, file) {
|
||||
// hit the `AssignmentExpression` one below
|
||||
if (path.isCompletionRecord()) return;
|
||||
|
||||
@@ -25,24 +22,28 @@ export default function (opts: {
|
||||
const nodes = [];
|
||||
const exploded = explode(expr.left, nodes, file, path.scope, true);
|
||||
|
||||
nodes.push(t.expressionStatement(
|
||||
buildAssignment(exploded.ref, opts.build(exploded.uid, expr.right))
|
||||
));
|
||||
nodes.push(
|
||||
t.expressionStatement(
|
||||
buildAssignment(exploded.ref, opts.build(exploded.uid, expr.right)),
|
||||
),
|
||||
);
|
||||
|
||||
path.replaceWithMultiple(nodes);
|
||||
};
|
||||
|
||||
visitor.AssignmentExpression = function (path, file) {
|
||||
visitor.AssignmentExpression = function(path, file) {
|
||||
const { node, scope } = path;
|
||||
if (!isAssignment(node)) return;
|
||||
|
||||
const nodes = [];
|
||||
const exploded = explode(node.left, nodes, file, scope);
|
||||
nodes.push(buildAssignment(exploded.ref, opts.build(exploded.uid, node.right)));
|
||||
nodes.push(
|
||||
buildAssignment(exploded.ref, opts.build(exploded.uid, node.right)),
|
||||
);
|
||||
path.replaceWithMultiple(nodes);
|
||||
};
|
||||
|
||||
visitor.BinaryExpression = function (path) {
|
||||
visitor.BinaryExpression = function(path) {
|
||||
const { node } = path;
|
||||
if (node.operator === opts.operator) {
|
||||
path.replaceWith(opts.build(node.left, node.right));
|
||||
|
||||
Reference in New Issue
Block a user