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
19 stars 9 forks source link

Add Html.Attributes.classList simplifications #82

Closed lue-bird closed 1 year ago

lue-bird commented 1 year ago
Html.Attributes.classList [ x, y, ( z, False ) ]
--> Html.Attributes.classList [ x, y ]

Html.Attributes.classList (x :: ( y, False ) :: zs)
--> Html.Attributes.classList (x :: zs)

Html.Attributes.classList (List.singleton ( y, False ))
--> Html.Attributes.classList []

Html.Attributes.classList (List.singleton ( onlyOneThing, True ))
--> Html.Attributes.class onlyOneThing

Html.Attributes.classList [ ( onlyOneThing, True ) ]
--> Html.Attributes.class onlyOneThing

Only the first and last simplifications are shown in the summary.

lue-bird commented 1 year ago

fix this replacement module name issue before we merge this

How about we go the patch fix implementation route I suggested for this PR and overhaul all fixes in the import lookup PR?

I guess that doesn't work because classList and class can have different necessary qualification.

Let's do it as you suggested: me branching the import lookup first, then merging this. (That said, I'm not a git wizard; leaving this branch open and catching up later seems oof)

whether you need to add an import

I don't actually think elm-review-siplifiy should import stuff to fix things at all but I guess it could be useful somewhere, in which case your suggestion to return whether an import is needed and store a location to place imports at in the CheckInfo seems good.

IMO this can be easily introduced once needed, tho.