jfmengels / elm-review

Analyzes Elm projects, to help find mistakes before your users find them.
https://package.elm-lang.org/packages/jfmengels/elm-review/latest/
Other
252 stars 13 forks source link

Replace `isInSourceDirectories` with `directory : Metadata -> Directory` #123

Closed lue-bird closed 2 years ago

lue-bird commented 2 years ago
isInSourceDirectories : Metadata -> Bool

isInSourceDirectories only seems useful to check whether it's a test or not. More useful would be

type Directory
    = TestDirectory
    | SourceDirectory String

directory : Metadata -> Directory -- or simply the path `String`

Allowing functionality similar to for example filterErrorsForFiles – checking the directory origin while still building the review rule to treat modules differently based on directory

jfmengels commented 2 years ago

Can you give some examples of what you'd do with this, or wish to do? I'm not sure I see what scenarios this enables that isInSourceDirectories can't already help with.

lue-bird commented 2 years ago

Seeing whether you are in the default src directory or in a private package/name directory or in a test directory or in a generated directory, etc.

Concrete example: I'm building a rule that should be able to not allow any file from within a package directory to import from outside of it

jfmengels commented 2 years ago

I recently added withFilePath (in master, not published yet), which gives you the relative path from elm.json.

Would that suit your need?

lue-bird commented 2 years ago

very neat! :tada: Looks perfect

jfmengels commented 2 years ago

This has been released in v2.8.0.