Releases: adobe/elixir-styler
v1.4.0
Improvements
Alias Lifting
This release taught Styler to try just that little bit harder when doing alias lifting.
-
general improvements around conflict detection, lifting in more correct places and fewer incorrect places (#193, h/t @jsw800)
-
use knowledge of existing aliases to shorten invocations (#201, h/t me)
example:
alias A.B.C A.B.C.foo()
becomes:
alias A.B.C C.foo()
Struct Updates => Map Updates
1.19 deprecates struct update syntax in favor of map update syntax.
# This
%Struct{x | y}
# Styles to this
%{x | y}
WARNING Double check your diffs to make sure your variable is pattern matching against the same struct if you want to harness 1.19's type checking features. Apologies to folks who hoped Styler would do this step for you <3 (#199, h/t @SteffenDE)
Ex1.17+
- Replace
:timer.units(x)
with the newto_timeout(unit: x)
forhours|minutes|seconds
(This style is only applied if you're on 1.17+)
Fixes
pipes
: handle pipifying when the first arg is itself a pipe:c(a |> b, d)
=>a |> b() |> c(d)
(#214, h/t @kybishop)pipes
: handle pipifying nested functionsd(c(a |> b))
=>a |> b |> c() |> d
(#216, h/t @emkguts)with
: fix a stabbywith
, else: (_ -> :ok)
being rewritten to a case (#219, h/t @iamhassangm)
v1.3.3
Improvements
-
with do: body
and variations with no arrows in the head will be rewritten to justbody
(or...head statements; body
) -
# styler:sort
will sort arbitrary ast nodes within ado end
block:Given:
# styler:sort my_macro "some arg" do another_macro :q another_macro :w another_macro :e another_macro :r another_macro :t another_macro :y end
We get:
# styler:sort my_macro "some arg" do another_macro :e another_macro :q another_macro :r another_macro :t another_macro :w another_macro :y end
Fixes
- fix a bug in comment-movement when multiple
# styler:sort
directives are added to a file at the same time
v1.3.2
v1.3.1
v1.3.0
# styler:sort
Styler's first comment directive
Styler will now keep a user-designated list or wordlist (~w
sigil) sorted as part of formatting via the use of "comment directives". Elements of the list are sorted by their string representation.
The intention is to remove comments to humans, like # Please keep this list sorted!
, in favor of comments to robots: # styler:sort
. Personally speaking, Styler is much better at alphabetical-order than I ever will be.
To use the new directive, put it on the line before a list or wordlist.
This example:
# styler:sort
[:c, :a, :b]
# styler:sort
~w(a list of words)
# styler:sort
@country_codes ~w(
en_US
po_PO
fr_CA
ja_JP
)
# styler:sort
a_var =
[
Modules,
In,
A,
List
]
Would yield:
# styler:sort
[:a, :b, :c]
# styler:sort
~w(a list of words)
# styler:sort
@country_codes ~w(
en_US
fr_CA
ja_JP
po_PO
)
# styler:sort
a_var =
[
A,
In,
List,
Modules
]
v1.2.1
1.2.1
Sure enough, the new pipify feature had a bug. Thanks @paulswartz for the issue
Fixes
|>
don't pipify when the call is itself in a pipe (aka don't toucha |> b(c |> d() |>e()) |> f()
) (Closes #204, h/t @paulswartz)
v1.2.0
Improvements
pipes
: pipe-ifies when first arg to a function is a pipe. reach out if this happens in unstylish places in your code (Closes #133)pipes
: unpiping assignments will make the assignment one-line when possible (Closes #181)deprecations
: 1.18 deprecationsList.zip
=>Enum.zip
first..last = range
=>first..last//_ = range
(this may actually be from 1.17?)
Fixes
pipes
: optimizations are less likely to move comments (Closes #176)
Improve config sorting comment handling
Improvements
- Config Sorting: improve comment handling when only sorting a few nodes (Closes #187)
v1.1.1
Improvements
unless
: rewriteunless a |> b |> c
asunless !(a |> b() |> c())
rather thanunless a |> b() |> c() |> Kernel.!()
(h/t @GregMefford)
v1.1.0
Improvements
The big change here is the rewrite/removal of unless
due to unless "eventually" being deprecated. Thanks to @janpieper and @ypconstante for bringing this up in #190.
unless
: rewrite allunless
toif
(#190)pipes
: optimize|> Stream.{each|map}(fun) |> Stream.run()
to|> Enum.each(fun)