Skip to content

Commit 6896d97

Browse files
committed
ship struct update to map update changes after all
1 parent d015a99 commit 6896d97

File tree

4 files changed

+17
-29
lines changed

4 files changed

+17
-29
lines changed

CHANGELOG.md

+7-10
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,9 @@ This release taught Styler to try just that little bit harder when doing alias l
3737
C.bar()
3838
C.baz()
3939

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)
40+
#### Struct Updates => Map Updates
4641

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.
42+
1.19 deprecates struct update syntax in favor of map update syntax.
4843

4944
```elixir
5045
# This
@@ -53,15 +48,17 @@ This release taught Styler to try just that little bit harder when doing alias l
5348
%{x | y}
5449
```
5550

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.
51+
**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)
52+
53+
#### Ex1.17+
5754

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
55+
- 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+)
5956

6057
### Fixes
6158

6259
- `pipes`: handle pipifying when the first arg is itself a pipe: `c(a |> b, d)` => `a |> b() |> c(d)` (#214, h/t @kybishop)
6360
- `pipes`: handle pipifying nested functions `d(c(a |> b))` => `a |> b |> c() |> d` (#216, h/t @emkguts)
64-
- `with`: correctly handle a stabby `with` `, else: (_ -> :ok)` being rewritten to a case (#219, h/t @iamhassangm)
61+
- `with`: fix a stabby `with` `, else: (_ -> :ok)` being rewritten to a case (#219, h/t @iamhassangm)
6562

6663
## 1.3.3
6764

docs/deprecations.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ This is covered by the Elixir Formatter with the `--migrate` flag, but Styler br
2525

2626
Rewrite `unless x` to `if !x`
2727

28-
### 1.19
28+
### Change Struct Updates to Map Updates
2929

30-
#### Change Struct Updates to Map Updates (Experimental)
31-
32-
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.
30+
1.19 deprecates struct update syntax in favor of map update syntax.
3331

3432
```elixir
3533
# This
@@ -38,9 +36,7 @@ Rewrite `unless x` to `if !x`
3836
%{x | y}
3937
```
4038

41-
**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.
42-
43-
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
39+
**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.
4440

4541
### 1.18
4642

lib/style/deprecations.ex

+3-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ defmodule Styler.Style.Deprecations do
6565
end
6666
end
6767

68-
if Version.match?(System.version(), ">= 1.19.0-dev") do
69-
# Struct update syntax was deprecated `%Foo{x | y} => %{x | y}`
70-
defp style({:%, _, [_struct, {:%{}, _, [{:|, _, _}]} = update]}), do: update
71-
end
68+
# Struct update syntax is deprecated in 1.19
69+
# `%Foo{x | y} => %{x | y}`
70+
defp style({:%, _, [_struct, {:%{}, _, [{:|, _, _}]} = update]}), do: update
7271

7372
# For ranges where `start > stop`, you need to explicitly include the step
7473
# Enum.slice(enumerable, 1..-2) => Enum.slice(enumerable, 1..-2//1)

test/style/deprecations_test.exs

+4-8
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ defmodule Styler.Style.DeprecationsTest do
116116
end
117117
end
118118

119+
test "struct update, deprecated in 1.19" do
120+
assert_style "%Foo{widget | bar: :baz}", "%{widget | bar: :baz}"
121+
end
122+
119123
describe "1.16+" do
120124
@describetag skip: Version.match?(System.version(), "< 1.16.0-dev")
121125

@@ -145,12 +149,4 @@ defmodule Styler.Style.DeprecationsTest do
145149
assert_style "a |> x() |> :timer.seconds()"
146150
end
147151
end
148-
149-
describe "1.19+" do
150-
@describetag skip: Version.match?(System.version(), "< 1.19.0-dev")
151-
152-
test "struct update" do
153-
assert_style "%Foo{widget | bar: :baz}", "%{widget | bar: :baz}"
154-
end
155-
end
156152
end

0 commit comments

Comments
 (0)