Skip to content

Commit

Permalink
fix: rewrite pipes starting with quote blocks. closes #82
Browse files Browse the repository at this point in the history
  • Loading branch information
novaugust committed Oct 27, 2023
1 parent ebfdf63 commit 104e052
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## main

### Fixes

* rewrite pipes starting with `quote` blocks like we do with `case|if|cond|with` blocks (#82, h/t @SteffenDE)

## v0.9.6

### Breaking Change
Expand Down
2 changes: 1 addition & 1 deletion lib/style/pipes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Styler.Style.Pipes do
alias Styler.Style
alias Styler.Zipper

@blocks ~w(case if with cond for unless)a
@blocks ~w(case if with cond for unless quote)a

def run({{:|>, _, _}, _} = zipper, ctx) do
case fix_pipe_start(zipper) do
Expand Down
22 changes: 22 additions & 0 deletions test/style/pipes_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,28 @@ defmodule Styler.Style.PipesTest do
"""
)
end

test "rewrites quote" do
assert_style(
"""
quote do
foo
end
|> bar()
|> baz()
""",
"""
quote_result =
quote do
foo
end
quote_result
|> bar()
|> baz()
"""
)
end
end

describe "single pipe issues" do
Expand Down

0 comments on commit 104e052

Please sign in to comment.