elm-lang / elm-make

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

JSON report content #99

Closed pauldijou closed 8 years ago

pauldijou commented 8 years ago

When reading the JSON from elm-make, for each warning / error, you have overview and details fields containing text info about the problem. Regarding the naming of the fields, I would expect the first one to be a "short" summary of the issue and the other one diving deeper on what exactly is the problem and how to eventually solve it. Sometime it's exactly that:

[{"tag":"missing type annotation",
"overview":"Top-level value `test` does not have a type annotation.",
"details":"I inferred the type annotation so you can copy it into your code:\n\ntest : number",
"region":{"start":{"line":6,"column":1},"end":{"line":6,"column":5}},
"type":"warning",
"file":"src/Test.elm"}]

If you only print overview, it's enough to understand the problem. But some other times, you are forced to use both of them or the message will not make any sense.

[{"tag":"SYNTAX PROBLEM",
"overview":"I need whitespace, but got stuck on what looks like a new declaration. You are\neither missing some stuff in the declaration above or just need to add some\nspaces here:",
"subregion":null,
"details":"I am looking for one of the following things:\n\n    whitespace",
"region":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},
"type":"error",
"file":"Main.elm"}]

As we can see, displaying only the overview will result in a truncated message missing the end. It's kind of a bummer if you are building a tool based on this report and only display the overview by default.

Also, I might be wrong, but it feels strange to have \n inside the JSON. It forces how to render the result while I consider JSON to be only about raw data. I would expect to have such newlines added when actually printing the message on the shell (or somewhere else).

evancz commented 8 years ago

Do you think this is covered by #98? If not, how would you summarize your request in a short sentence?

pauldijou commented 8 years ago

Don't think so. In short: overview and details should be standalone rather than being forced to concatenate them to have the full message (otherwise, only one field would be enough) and not contain any styling, only the raw message (no \n and no ).

evancz commented 8 years ago

Added to #98 with a summary of what I think the solution might be.