Migration from v1 to v2
I CAN'T RUN ELM-REVIEW V1 ANYMORE!
If you are trying to run v1 of the
elm-review CLI and it suddenly stopped working, I am very sorry about that!
Fortunately, there is an easy fix: updating the CLI to version
npm install -D email@example.com
The problem is that previous versions try to build an application behind the scenes, and installs the
jfmengels/elm-review package every time.
Those versions were not saying which version of
jfmengels/elm-review to use though, due to limitations of what
elm install offered and
elm-json offered at the time.
And now that v2 has been released, well it may well try to install a version of
jfmengels/elm-review that doesn't work for your project.
elm-json's author @zwilias was very responsive to this need, and version
1.0.2 now installs
1.0.0 <= x < 2.0.0. So kudos to him!
The API for the rules you created in v1 is pretty much the same in v2.
The differences are mostly functions and types that were renamed, and a single argument somewhere to add.
You fortunately won't have to change anything in the logic of your rule or tests.
newSchemais renamed to
newModuleRuleSchema. It now takes the initial context as a new argument. If you were using
withInitialContext, then you should use that function's value, otherwise you can use
fromSchemais renamed to
withInitialContexthas been removed, since the initial context is now supplied by
withFixeshas been removed. If you now want to add fixes to an error, use
errorWithFixinstead of error.
Errortype now has a type variable. You can replace all
Schemahas been renamed to
There are a lot of other API changes not related to creating rules, which are related to making everything work for the CLI. I am not going to describe these here because it's unlikely that someonetiuched that. If I am wrong about this and you did depend on these APIs, come talk to me or open an issue.
Folder structure change
The default folder structure has been updated, therefore I recommend removing your
review/ folder (at least the
elm.json) then running
elm-review init. Then you can copy paste what you had in your previous ReviewConfig into the new one.
In practice, you should be able to have a very similar configuration, but the following sections might make you change a few things.
Tests now included by default
If you were running
elm-review with arguments, I recommend removing them and to see if that works out.
tests/ directory is now included by default, so you might get errors from that. To ignore these errors for the moment, you can change the arguments to
elm-review, or use
Rule.ignoreErrorsForDirectories. I recommend having your tests reviewed after the migration phase.
Here are the changes for the review packages from
NoDebug rule is split into NoDebug.Log and NoDebug.TodoOrToString. Just remove the former and add the latter two rules to have the same.
NoUnused.CustomTypeConstructors now takes an argument, which you can replace by
There are now a lot of new rules that you can pick up from, so go check those out!