jfmengels / node-elm-review

CLI for elm-review
https://package.elm-lang.org/packages/jfmengels/elm-review/latest/
BSD 3-Clause "New" or "Revised" License
48 stars 25 forks source link

The CLI crashes in watch mode when suppression files are incorrect JSON #117

Open jfmengels opened 1 year ago

jfmengels commented 1 year ago

Ideally we don't want to crash in that case, we just want to report an error and wait for the file to be valid again.

To reproduce:

-- UNEXPECTED ERROR ------------------------------------------------------------

I ran into an unexpected error. Please open an issue at the following link:
  https://github.com/jfmengels/node-elm-review/issues/new

Please include this error message and as much detail as you can provide. If you
can, please provide a setup that makes it easy to reproduce the error. That will
make it much easier to fix the issue.

Below is the error that was encountered.
--------------------------------------------------------------------------------
SyntaxError: /Users/jengels/dev/humio/ui/review/suppressed/NoDeprecated.json: Unexpected token , in JSON at position 571
    at JSON.parse (<anonymous>)
    at _readFile (/Users/jengels/dev/my-project/ui/node_modules/jsonfile/index.js:25:16)

This might happen if someone touches the JSON file, or during a Git rebase when there are conflicts in a suppression file.

Expected behavior

In the same conditions, the CLI should not crash. It should show a nice error indicating that a suppressed errors file is invalid. Once that file is fixed, it should resume working like before.