Skip to content

Releases: adobe/elixir-styler

v1.4.0

21 Feb 19:10
Compare
Choose a tag to compare

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 new to_timeout(unit: x) for hours|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 functions d(c(a |> b)) => a |> b |> c() |> d (#216, h/t @emkguts)
  • with: fix a stabby with , else: (_ -> :ok) being rewritten to a case (#219, h/t @iamhassangm)

v1.3.3

21 Jan 23:55
Compare
Choose a tag to compare

Improvements

  • with do: body and variations with no arrows in the head will be rewritten to just body (or ...head statements; body)

  • # styler:sort will sort arbitrary ast nodes within a do 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

14 Jan 20:27
Compare
Choose a tag to compare

# styler:sort will sort key values, like:

# given 
%{
  z: ...,
  # styler:sort
  b: ~w(a list to be sorted)
}

# styled
%{
  z: ...,
  # styler:sort
  b: ~w(a be list sorted to)
}

v1.3.1

13 Jan 19:52
Compare
Choose a tag to compare
  • # styler: sort can now be used with defstruct and maps
  • # styler: sort doesn't blow up on keyword lists anymore :X

v1.3.0

13 Jan 19:14
Compare
Choose a tag to compare

# 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

22 Nov 20:45
Compare
Choose a tag to compare

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 touch a |> b(c |> d() |>e()) |> f()) (Closes #204, h/t @paulswartz)

v1.2.0

20 Nov 19:24
Compare
Choose a tag to compare

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 deprecations
    • List.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

18 Oct 18:30
Compare
Choose a tag to compare

Improvements

  • Config Sorting: improve comment handling when only sorting a few nodes (Closes #187)

v1.1.1

18 Oct 18:30
Compare
Choose a tag to compare

Improvements

  • unless: rewrite unless a |> b |> c as unless !(a |> b() |> c()) rather than unless a |> b() |> c() |> Kernel.!() (h/t @GregMefford)

v1.1.0

18 Oct 18:30
Compare
Choose a tag to compare

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 all unless to if (#190)
  • pipes: optimize |> Stream.{each|map}(fun) |> Stream.run() to |> Enum.each(fun)

Fixes

  • pipes: optimizations reducing 2 pipes to 1 no longer squeeze all pipes onto one line (#180)
  • if: fix infinite loop rewriting negated if with empty do body if x != y, do: (), else: :ok (#196, h/t @itamm15)