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

Question about `Review.Rule.newModuleRuleSchemaUsingContextCreator` #166

Open lue-bird opened 11 months ago

lue-bird commented 11 months ago

Review.Rule.newModuleRuleSchema allows adding for example a withElmJsonModuleVisitor. However, newModuleRuleSchemaUsingContextCreator cannot be used with that visitor because the resulting schema doesn't have the phantom field canCollectProjectData : ().

As far as I can see, it is not possible to access the Elm.Project.Project/ElmJsonKey using a ContextCreator or any other method.

First, is this intentional somehow? Converting it to a project rule seems easy enough (and the result is probably nicer anyway). And if not, should we add the phantom field in v3? Or would it be nicer to introduce something like withElmJson etc for the ContextCreator?

Edit: I can see that the current implementation of fromModuleRuleSchema would not allow the first suggested change easily. I'll try to poke a bit to see if this is necessary.

jfmengels commented 11 months ago

This is intentional yes, people should write a project rule instead. I usually remember the reason, but for some reason I can't put my finger on it now :disappointed_relieved:

lue-bird commented 11 months ago

If you do remember the reason some future time by chance, it would be nice to add the reason to the documentation of newModuleRuleUsingContextCreator.