diff --git a/src/pipe.lsc b/src/pipe.lsc index 7d3f24e..f33a7e2 100644 --- a/src/pipe.lsc +++ b/src/pipe.lsc @@ -6,6 +6,9 @@ import { } from 'ast-loc-utils' export transformPipeOperator(path) -> - { node: { left, right } } = path + { node: { left, right, reversed } } = path loc = getSurroundingLoc([left, right]) - path.replaceWith(t.callExpression(right, [left])~atLoc(loc)) + if not reversed: + path.replaceWith(t.callExpression(right, [left])~atLoc(loc)) + else: + path.replaceWith(t.callExpression(left, [right])~atLoc(loc)) diff --git a/test/fixtures/pipe-call/basic/actual.js b/test/fixtures/pipe-call/basic/actual.js index f7ad5ea..a741dd9 100644 --- a/test/fixtures/pipe-call/basic/actual.js +++ b/test/fixtures/pipe-call/basic/actual.js @@ -1 +1,3 @@ a |> b |> c + +a <| b <| c diff --git a/test/fixtures/pipe-call/basic/expected.js b/test/fixtures/pipe-call/basic/expected.js index 70e6a8c..b499bfa 100644 --- a/test/fixtures/pipe-call/basic/expected.js +++ b/test/fixtures/pipe-call/basic/expected.js @@ -1 +1,3 @@ -c(b(a)); \ No newline at end of file +c(b(a)); + +a(b(c)); \ No newline at end of file diff --git a/test/fixtures/pipe-call/recompose-pattern/actual.js b/test/fixtures/pipe-call/recompose-pattern/actual.js new file mode 100644 index 0000000..e385e6b --- /dev/null +++ b/test/fixtures/pipe-call/recompose-pattern/actual.js @@ -0,0 +1,6 @@ +MyComponent = pure <| + withSomething(stuff) <| + withSomethingElse(stuff) <| + (props) -> +
{props.thing}
+ diff --git a/test/fixtures/pipe-call/recompose-pattern/expected.js b/test/fixtures/pipe-call/recompose-pattern/expected.js new file mode 100644 index 0000000..2486714 --- /dev/null +++ b/test/fixtures/pipe-call/recompose-pattern/expected.js @@ -0,0 +1,3 @@ +const MyComponent = pure(withSomething(stuff)(withSomethingElse(stuff)(function (props) { + return
{props.thing}
; +}))); \ No newline at end of file