jfmengels / elm-review-simplify

Provides elm-review rules to simplify your Elm code
https://package.elm-lang.org/packages/jfmengels/elm-review-simplify/latest/
BSD 3-Clause "New" or "Revised" License
20 stars 9 forks source link

Add record access simplifications for application of record access function #206

Closed lue-bird closed 11 months ago

lue-bird commented 11 months ago

Detect applying or piping into .field as record access (in the following only showing application) as part of #162 and a few more.

{ record | field = .field record }
--> record

{ record | field = .field record, other = x }
--> { record | other = x }

.field { field = a }
--> a

.field { record | field = a }
--> a

.field { record | otherField = a }
--> record.field

.field (if c then yay else nay)
--> if c then yay.field else nay.field

.field (let x = y in z)
--> let x = y in z.field
github-actions[bot] commented 11 months ago

The branch can be tried out by running:

elm-review --template jfmengels/elm-review-simplify/preview