jfmengels / elm-review-unused

Provides elm-review rules to detect unused elements in your Elm project
https://package.elm-lang.org/packages/jfmengels/elm-review-unused/latest/
BSD 3-Clause "New" or "Revised" License
23 stars 12 forks source link

Fixes type aliases not being reported when they don't alias a record #49

Closed jfmengels closed 3 years ago

jfmengels commented 3 years ago

Fixes #48

@smucode Could you please check whether this works well for you? You can run the following:

elm-review --template jfmengels/elm-review-unused/preview#type-alias-through-constructor --rules NoUnused.Variables

(If need be, use --ignore-dirs or --ignore-files)

smucode commented 3 years ago

Nice, it seems to find unused type aliases that are not records just fine. 👍

But, there seems to be some issue when i use --fix-all. Probably not a regression though, as now i ran it on some lib code we don't usually run it on. This is specifically with documentation comments. The unused functions are removed, but not the doc comments, and that seems to trip up the elm compiler.

I am getting stuck because this line starts with the { symbol:

53| {-| -}
    ^
When a line has no spaces at the beginning, I expect it to be a declaration like
one of these:

    greet : String -> String
    greet name =
      "Hello " ++ name ++ "!"

    type User = Anonymous | LoggedIn String

If this is not supposed to be a declaration, try adding some spaces before it?

Apart from that, this seems to be working great :)

jfmengels commented 3 years ago

Thanks for checking! Would you be able to provide an SSCCE of that behaviour? :thinking:

I will wait on merging this until that is figured out, because that is a problematic regression.

The fact that it ran on files you're not used to running it on is likely due to the fact that the files/folders you ignored in your config are not ignored when you run with --template (but you can use --ignore-dirs and --ignore-files if you want).

jfmengels commented 3 years ago

I can't reproduce this :thinking:

If you try again:

smucode commented 3 years ago

After upgrading elm-review to version 2.5.5 every single one of the 197 errors it found were fixed just fine. Amazing :) 🥇

jfmengels commented 3 years ago

Alright, thanks for checking!

jfmengels commented 3 years ago

I'll try to release this at the end of today, and otherwise after my holidays 😁

jfmengels commented 3 years ago

Released in v1.1.17!