Skip to content

Commit ceb827a

Browse files
committed
change struct update deprecation to ex1.19+
1 parent a46c43f commit ceb827a

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

CHANGELOG.md

+27-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,16 @@ they can and will change without that change being reflected in Styler's semanti
55

66
## main
77

8-
### Improvements
9-
10-
#### Ex1.17+
11-
12-
- Replace `:timer.units(x)` with the new `to_timeout(unit: x)` for `hours|minutes|seconds`
13-
- Handle `, else: (_ -> x)` bugs introduced by `(_ -> x)` being termed a literal (#219, h/t @iamhassangm)
8+
## 1.4
149

15-
#### Ex1.18+
10+
- A very nice change in alias lifting means Styler will make sure that your code is _using_ the aliases that it's specified.
11+
- Shoutout to the smartrent folks for finding pipifying recursion issues
12+
- Elixir 1.17 improvements and fixes
13+
- Elixir 1.19-dev: delete struct updates
1614

17-
Delete deprecated struct update syntax in favor of map update syntax.
15+
Read on for details.
1816

19-
```elixir
20-
# This
21-
%Struct{x | y}
22-
# Styles to this
23-
%{x | y}
24-
```
25-
26-
**WARNING** Double check your diffs to make sure your variable is pattern matching against the same struct if you want to harness 1.18's type checking features. (#199, h/t @SteffenDE)
17+
### Improvements
2718

2819
#### Alias Lifting
2920

@@ -46,6 +37,26 @@ This release taught Styler to try just that little bit harder when doing alias l
4637
C.bar()
4738
C.baz()
4839

40+
#### Ex1.17+
41+
42+
- Replace `:timer.units(x)` with the new `to_timeout(unit: x)` for `hours|minutes|seconds`
43+
- Handle `, else: (_ -> x)` bugs introduced by `(_ -> x)` being termed a literal (#219, h/t @iamhassangm)
44+
45+
#### Ex1.19+ (experimental)
46+
47+
1.19 deprecates struct update syntax in favor of map update syntax. Styler will do this update for you if you're on Elixir 1.19.0-dev or later.
48+
49+
```elixir
50+
# This
51+
%Struct{x | y}
52+
# Styles to this
53+
%{x | y}
54+
```
55+
56+
**WARNING** Double check your diffs to make sure your variable is pattern matching against the same struct if you want to harness 1.18's type checking features.
57+
58+
A future version of Styler may be smart enough to do this check for you and perform the appropriate updates to the assignment location; no guarantees though. Track via #199, h/t @SteffenDE
59+
4960
### Fixes
5061

5162
- `pipes`: handle pipifying when the first arg is itself a pipe: `c(a |> b, d)` => `a |> b() |> c(d)` (#214, h/t @kybishop)

lib/style/deprecations.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ defmodule Styler.Style.Deprecations do
6565
end
6666
end
6767

68-
if Version.match?(System.version(), ">= 1.18.0-dev") do
68+
if Version.match?(System.version(), ">= 1.19.0-dev") do
6969
# Struct update syntax was deprecated `%Foo{x | y} => %{x | y}`
7070
defp style({:%, _, [_struct, {:%{}, _, [{:|, _, _}]} = update]}), do: update
7171
end

test/style/deprecations_test.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ defmodule Styler.Style.DeprecationsTest do
146146
end
147147
end
148148

149-
describe "1.18+" do
150-
@describetag skip: Version.match?(System.version(), "< 1.18.0-dev")
149+
describe "1.19+" do
150+
@describetag skip: Version.match?(System.version(), "< 1.19.0-dev")
151151

152152
test "struct update" do
153153
assert_style "%Foo{widget | bar: :baz}", "%{widget | bar: :baz}"

0 commit comments

Comments
 (0)