You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* ignore no-paren, no-body function heads. closesadobe#185
* minor optimization
* Wrap up 1.0.0 docs overhaul
* 1.0.0
* Add missing documentation. Closesadobe#188
* update readme link
* add more verbiage re styler can add bugs. Closesadobe#186
* reword warning to list examples of breakages
* Update styles.md
Fixed example for "drop superfluous _..."
* Add Stream.run optimizations, fix optimizations shrinking pipes to one line (Closesadobe#180)
* fix infinite loop rewriting negated if with empty do body. closesadobe#196
* Remove unless from codebases (adobe#194)
* use `not` over `!` when rewriting `unless a (> >= < <= in) b`
* actually, lets only do `not` for `in`
* v1.1.0
* update version in readme
* Don't pipe into `Kernel.!` when rewriting unless with pipes
* configs: improve comment handling when moving a small number of nodes. Closesadobe#187
* v1.1.2
* pipes: improve comment behaviour in optimizations (Closesadobe#176)
* One-line unpiped assignments (adobe#197)
Closesadobe#181
* Pipify: `d(a |> b |> c)` => `a |> b() |> c() |> d()`(adobe#198)
Closesadobe#133
* 1.18 hard deprecations (adobe#203)
* `List.zip` => `Enum.zip`
* `first..last = range` => `first..last//_ = range`
* docs and changelog
* docs prep for 1.2
* v1.2.0
* correct docs on Enum.into
* Fix pipifying pipes-in-pipes (Closesadobe#204)
* v1.2.1
* introduce `# styler:sort` comment directive (adobe#205)
closesadobe#167
* styler:sort - handle tuples
* mix format :X
* style:sort - dont dedupe
* docs and fix a typo
* fiddle with private apis to ease iex playing
* remove Zipper.reduce/3 - bugged, but more importantly unused
* Maintain comment-node relations when applying `#styler:sort` directive (adobe#207)
Co-authored-by: Greg Mefford <gmefford@adobe.com>
Closesadobe#167
* v1.3.0
* correct changelog
* fix twople bug in sort directive, add map sorting
* v1.3.1
* defstruct with list literal
* ci: update elixir and erlang versions
* sort directive: sort values of keys. Closesadobe#208
* v1.3.2
* fix comments bug in styler:sort directive
* styler:sort arbitrary ast within do end blocks
* improve `with` statement replacements
* v1.3.3
* alias lifting: shrink when alias already exists. closesadobe#201
* alias lifting: be better about conflicts. Closesadobe#193
* improve alias lift collision case
* remove vestigial with rewriting head
* pipes: handle pipifying functions whose first arg is itself a pipe. closesadobe#193
* cleanup the messes left in the previous commit 🙈
* correct issue number in change log
* test against 1.18
* 1.18 warnings + formatting
* no one saw that right?
* ex1.17+: replace `:timer.units(x)` with the new `to_timeout(unit: x)` for `hours|minutes|seconds`
Closesadobe#218
* 1.18+: change struct updates to map updates. Closesadobe#199
* ensure test works across versions
* fix `with` rewrites when keyword with an else stab (adobe#220)
Closesadobe#219
fixes for both <1.17 and >=1.17
* pipify nested function calls with pipe as the first argument. closesadobe#216
* change struct update deprecation to ex1.19+
* docs docs docs docs docs!
* ship struct update to map update changes after all
* v1.4.0
* Add OTP26/27 but only run for 1.17/1.18
* fix `with` redundant body + non-arrow behind redundant clause. Closesadobe#221
* link to quokka
* rewrite `to_timeout(unit: x * m)` to use larger units in some cases
* defs test describe formatting
* dont crash on invalid defs
* fix CI for older elixir
* v1.4.1
* if: drop empty do bodies. Closesadobe#227
* Fix large comment block mangling bug when ordering sibling AST (adobe#232)
Closesadobe#230
* if: treat is_nil as a negator
* Revert "if: treat is_nil as a negator"
This reverts commit 50ae386.
* Revert "if: drop empty do bodies. Closesadobe#227"
This reverts commit 6b42462.
* v1.4.2
* changelog: fix GH md formatting issues
* optimize zipper performance
* We still don't want moduledoc false in modules without it
* Remove missed conflict
---------
Co-authored-by: Matt Enlow <enlow@adobe.com>
Co-authored-by: Kem Tekinay <ktekinay@mactechnologies.com>
Co-authored-by: Matt Enlow <matt@novaugust.net>
Co-authored-by: Theodor Fiedler <theo.fie@gmail.com>
Co-authored-by: Fabian Becker <fbecker@adobe.com>
Co-authored-by: Jesse Herrick <jesse@remote.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+225Lines changed: 225 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,231 @@
4
4
they can and will change without that change being reflected in Styler's semantic version.
5
5
## main
6
6
7
+
## 1.4.2
8
+
9
+
### Fixes
10
+
11
+
- fix comment misplacement for large comment blocks in config files and `# styler:sort` (#230, h/t @cschmatzler)
12
+
13
+
## 1.4.1
14
+
15
+
### Improvements
16
+
17
+
-`to_timeout/1` rewrites to use the next largest unit in some simple instances
18
+
19
+
```elixir
20
+
# before
21
+
to_timeout(second:60* m)
22
+
to_timeout(day:7)
23
+
# after
24
+
to_timeout(minute: m)
25
+
to_timeout(week:1)
26
+
```
27
+
28
+
### Fixes
29
+
30
+
- fixed styler raising when encountering invalid function definition ast
31
+
32
+
## 1.4.0
33
+
34
+
-A very nice change inalias lifting means Styler will make sure that your code is _using_ the aliases that it's specified.
35
+
- Shoutout to the smartrent folks for finding pipifying recursion issues
36
+
- Elixir 1.17 improvements and fixes
37
+
- Elixir 1.19-dev: delete struct updates
38
+
39
+
Read on for details.
40
+
41
+
### Improvements
42
+
43
+
#### Alias Lifting
44
+
45
+
This release taught Styler to try just that little bit harder when doing alias lifting.
46
+
47
+
- general improvements around conflict detection, lifting in more correct places and fewer incorrect places (#193, h/t @jsw800)
48
+
- use knowledge of existing aliases to shorten invocations (#201, h/t me)
49
+
50
+
example:
51
+
52
+
alias A.B.C
53
+
54
+
A.B.C.foo()
55
+
A.B.C.bar()
56
+
A.B.C.baz()
57
+
58
+
becomes:
59
+
60
+
alias A.B.C
61
+
62
+
C.foo()
63
+
C.bar()
64
+
C.baz()
65
+
66
+
#### Struct Updates => Map Updates
67
+
68
+
1.19 deprecates struct update syntax in favor of map update syntax.
69
+
70
+
```elixir
71
+
# This
72
+
%Struct{x | y}
73
+
# Styles to this
74
+
%{x | y}
75
+
```
76
+
77
+
**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)
78
+
79
+
#### Ex1.17+
80
+
81
+
-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+)
82
+
83
+
### Fixes
84
+
85
+
- `pipes`: handle pipifying when the first arg is itself a pipe: `c(a |> b, d)` => `a |> b() |> c(d)` (#214, h/t @kybishop)
- `with`: fix a stabby `with` `, else: (_ -> :ok)` being rewritten to a case (#219, h/t @iamhassangm)
88
+
89
+
## 1.3.3
90
+
91
+
### Improvements
92
+
93
+
- `with do: body` and variations with no arrows in the head will be rewritten to just `body`
94
+
- `# styler:sort` will sort arbitrary ast nodes within a `do end` block:
95
+
96
+
Given:
97
+
98
+
# styler:sort
99
+
my_macro "some arg" do
100
+
another_macro :q
101
+
another_macro :w
102
+
another_macro :e
103
+
another_macro :r
104
+
another_macro :t
105
+
another_macro :y
106
+
end
107
+
108
+
We get
109
+
110
+
# styler:sort
111
+
my_macro "some arg" do
112
+
another_macro :e
113
+
another_macro :q
114
+
another_macro :r
115
+
another_macro :t
116
+
another_macro :w
117
+
another_macro :y
118
+
end
119
+
120
+
### Fixes
121
+
122
+
- fix a bug in comment-movement when multiple `# styler:sort` directives are added to a file at the same time
123
+
124
+
## 1.3.2
125
+
126
+
### Improvements
127
+
128
+
- `# styler:sort` can be used to sort values of key-value pairs. eg, sort the value of a single key in a map (Closes #208, h/t @ypconstante)
129
+
130
+
## 1.3.1
131
+
132
+
### Improvements
133
+
134
+
- `# styler:sort` now works with maps and the `defstruct` macro
135
+
136
+
### Fixes
137
+
138
+
- `# styler:sort` no longer blows up on keyword lists :X
139
+
140
+
## 1.3.0
141
+
142
+
### Improvements
143
+
144
+
#### `# styler:sort` Styler's first comment directive
145
+
146
+
Styler will now keep a user-designated list orwordlist (`~w` sigil) sorted as part of formatting via the use of comments. Elements of the list are sorted by their string representation.
147
+
148
+
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.
149
+
150
+
Touse the new directive, put it on the line before a list or wordlist.
151
+
152
+
Thisexample:
153
+
154
+
```elixir
155
+
# styler:sort
156
+
[:c, :a, :b]
157
+
158
+
# styler:sort
159
+
~w(a list of words)
160
+
161
+
# styler:sort
162
+
@country_codes~w(
163
+
en_US
164
+
po_PO
165
+
fr_CA
166
+
ja_JP
167
+
)
168
+
169
+
# styler:sort
170
+
a_var =
171
+
[
172
+
Modules,
173
+
In,
174
+
A,
175
+
List
176
+
]
177
+
```
178
+
179
+
Would yield:
180
+
181
+
```elixir
182
+
# styler:sort
183
+
[:a, :b, :c]
184
+
185
+
# styler:sort
186
+
~w(a list of words)
187
+
188
+
# styler:sort
189
+
@country_codes~w(
190
+
en_US
191
+
fr_CA
192
+
ja_JP
193
+
po_PO
194
+
)
195
+
196
+
# styler:sort
197
+
a_var =
198
+
[
199
+
A,
200
+
In,
201
+
List,
202
+
Modules
203
+
]
204
+
```
205
+
206
+
## 1.2.1
207
+
208
+
### Fixes
209
+
210
+
*`|>` 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)
211
+
212
+
## 1.2.0
213
+
214
+
### Improvements
215
+
216
+
*`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)
217
+
*`pipes`: unpiping assignments will make the assignment one-line when possible (Closes #181)
- replaces strings with sigils when the string has many escaped quotes
22
-
- ... and so much more
23
-
24
-
[See our Rewrites documentation on hexdocs](https://hexdocs.pm/styler/styles.html)
14
+
Styler fixes a plethora of elixir style and optimization issues automatically as part of mix format.
15
+
16
+
[See Styler's documentation on Hex](https://hexdocs.pm/styler/styles.html) for the comprehensive list of its features.
17
+
18
+
The fastest way to see what all it can do you for you is to just try it out in your codebase... but here's a list of a few features to help you decide if you're interested in Styler:
19
+
20
+
- sorts and organizes `import`/`alias`/`require` and other [module directives](docs/module_directives.md)
21
+
- keeps lists, sigils, and even arbitrary code sorted with the `# styler:sort`[comment directive](docs/comment_directives.md)
@@ -75,10 +76,54 @@ Styler's only current configuration option is `:alias_lifting_exclude`, which ac
75
76
76
77
#### No Credo-Style Enable/Disable
77
78
78
-
Styler [will not add configuration](https://github.com/adobe/elixir-styler/pull/127#issuecomment-1912242143) for ad-hoc enabling/disabling of rewrites. Sorry! Its implementation simply does not support that approach. There are however many forks out there that have attempted this; please explore the [Github forks tab](https://github.com/adobe/elixir-styler/forks) to see if there's a project that suits your needs or that you can draw inspiration from.
79
+
Styler [will not add configuration](https://github.com/adobe/elixir-styler/pull/127#issuecomment-1912242143) for ad-hoc enabling/disabling of rewrites. Sorry!
80
+
81
+
However, Smartrent has a fork of Styler named [Quokka](https://github.com/smartrent/quokka) that allows for finegrained control of Styler. Maybe it's what you're looking for. If not, you can always fork it or Styler as a starting point for your own tool!
79
82
80
83
Ultimately Styler is @adobe's internal tool that we're happy to share with the world. We're delighted if you like it as is, and just as excited if it's a starting point for you to make something even better for yourself.
81
84
85
+
## WARNING: Styler can change the behaviour of your program!
86
+
87
+
In some cases, this can introduce bugs. It goes without saying, but look over your changes before committing to main :)
88
+
89
+
A simple example of a way Styler changes the behaviour of code is the following rewrite:
90
+
91
+
```elixir
92
+
# Before: this case statement...
93
+
case foo do
94
+
true->:ok
95
+
false->:error
96
+
end
97
+
98
+
# After: ... is rewritten by Styler to be an if statement!.
99
+
if foo do
100
+
:ok
101
+
else
102
+
:error
103
+
end
104
+
```
105
+
106
+
These programs are not semantically equivalent. The former would raise if `foo` returned any value other than `true` or `false`, while the latter blissfully completes.
107
+
108
+
However, Styler is about _style_, and the `if` statement is (in our opinion) of much better style. If the exception behaviour was intentional on the code author's part, they should have written the program like this:
109
+
110
+
```elixir
111
+
case foo do
112
+
true->:ok
113
+
false->:error
114
+
other ->raise"expected `true` or `false`, got: #{inspect other}"
115
+
end
116
+
```
117
+
118
+
Also good style! But Styler assumes that most of the time people just meant the `if` equivalent of the code, and so makes that change. If issues like this bother you, Styler probably isn't the tool you're looking for.
0 commit comments