elm-lang / elm-make

A build tool for Elm projects
BSD 3-Clause "New" or "Revised" License
175 stars 45 forks source link

Warnings and errors are collected into two separate json objects when using --report=json flag #42

Closed bbugh closed 9 years ago

bbugh commented 9 years ago

Hey, I made the Elm Linter package for Sublime Text 3, https://github.com/bbugh/SublimeLinter-contrib-elm-make :cake:

Problem: When using a file that generates both a warning and an error, the json reporter outputs two separate json objects, which makes parsing challenging. Since the issues are already tagged as "warning" or "error" and have identical fields, it seems like a bug to output two separate objects.

Reproduction: Most of the time if there is an error and a warning, the compiler will simply ignore the warnings and output the errors. However, sometimes when the compiler decides to have both an error and the warning in the output, it will output two separate json objects. Unfortunately this only shows up intermittently and I am unable to reproduce a simple test case to demonstrate it. Here is an example that shows somewhat what the context would look like:

-- an unused module warning
import Http.Events

-- a cannot find type error
main : Potato
main =
  text "potato"

Although that is a contrived example, this is a real sample output:

[{"tag":"unused import","overview":"Module `Html.Events` is unused.","details":"","region":{"start":{"line":6,"column":1},"end":{"line":6,"column":19}},"type":"warning","file":"LintTest.elm"}]
[{"tag":"TYPE MISMATCH","overview":"The 1st argument to function `start` has an unexpected type.","subregion":{"start":{"line":48,"column":18},"end":{"line":48,"column":72}},"details":"As I infer the type of values flowing through your program, I see a conflict\nbetween these two types:\n\n    Model\n\n    Action","region":{"start":{"line":48,"column":3},"end":{"line":48,"column":72}},"type":"error","file":"LintTest.elm"}]

Desire: The json report would output as one single json object, which would make parsing much easier.

texastoland commented 9 years ago

All the JSON issues could be collected into a meta issue c.f. #26, #38.

evancz commented 9 years ago

Closing in favor of #47 which will solve this and some other stuff.