Ale: Flow 0.66 changed the error messages format

Created on 5 Mar 2018  Â·  17Comments  Â·  Source: dense-analysis/ale

Flow 0.66 changed the error messages format more here which now makes ale messages not very useful

bug

All 17 comments

The changelog claims that existing plugins should continue to work, until you pass a flag to use the new JSON format.

But that's not the case when I see the errors from ale here is my ale config & this is an example:

Flow 0.53.1

flow 0 53 1

Flow 0.66

flow 0 66

Sounds like they fucked up, then. I might have a look when I get the time, or someone else can create a pull request for it. I believe some version detection is already down for the linter, so it shouldn't be too hard to fix.

@ahmedelgabri What is changed to you? For me new errors became more descriptive in ale. Before I always should go to terminal to check which exact fields are missing.

@TrySound the error messages are not complete, if you check he article I linked to flow now with have something like footnotes or markers. And they are not always going be shown in full now, here is an example, check the second error. It's not as clear & maybe even gets cut off now

I'd say before they weren't full too

Ok, then maybe I'm missing something. But after the flow update some messages didn't seem to make much sense, I'll keep an eye on it again & see.

Also ALEDetail is useless now:

References: [1] [2]

Feel free to submit a pull request to fix it.

Ale newbie here.

Is there any chance we could try to format the error message output by ale to be multiline and as descriptive as command line (My error messages appear in 1 long line now, and they can be difficult to read)?

I tried taking a look at https://github.com/w0rp/ale/blob/master/ale_linters/javascript/flow.vim#L160 and got lost pretty quickly. Happy to take a stab at contributing if you have any ideas in mind.

If you want to show multiline you can try set cmdheight=<number> but I won't do this y default or even add it to the plugin to be honest.

@ahmedelgabri thanks for that suggestion! 👼

I thought about this further, I think what I'm hoping for is to be able to see something like below somehow within vim, either by using lopen or by using ALEDetails. Is it possible? Currently my error message gets appended in 1 long line.

image

Maybe I'm missing something?

If you set a 'detail' key for the loclist items with multiple lines, you can view the multi-line message in a window with :ALEDetail. I just realised that particular loclist key wasn't documented, so I updated the documentation.

@w0rp Thanks for the work-around! After reading through the docs you just added, I'm a little confused. What should detail should be set to?

Someone can modify the flow linter file in ALE to set detail to a multi-line string with a more descriptive message. If anyone knows how to build such a string from flow's JSON output, create a pull request for it. I don't know much about flow.

I think the problem is not related to how the loclist is configured but rather to some parts of the Flow output being ignored.

This is how the JSON returned by Flow looks:

{
  "flowVersion":"0.87.0",
  "jsonVersion":"1",
  "errors":[
    {
      "kind":"infer",
      "level":"error",
      "suppressions":[],
      "extra":[
        {
          "message":[
            {
              "context":null,
              "descr":"References:",
              "type":"Blame",
              "path":"",
              "line":0,
              "endline":0,
              "start":1,
              "end":0
            }
          ]
        },
        {
          "message":[
            {
              "context":"export type MyRecord = RecordOf<Props>;",
              "descr":"[1]",
              "type":"Blame",
              "loc":{
                "source":"/blah/types.js",
                "type":"SourceFile",
                "start":{"line":217,"column":44,"offset":5098},
                "end":{"line":217,"column":67,"offset":5122}
              },
              "path":"/blah/types.js",
              "line":217,
              "endline":217,
              "start":44,
              "end":67
            }
          ]
        }
      ],
      "message":[
        {
          "context":"        return !!(product && product.get && product.get('isGroup'));",
          "descr":"Cannot call `product.get` because: Either property `isGroup` is missing in `Props` [1] in type argument `K`. Or property `isGroup` is missing in `Props` [1] in type argument `K`.",
          "type":"Blame",
          "loc":{
            "source":"/blah/selectors.js",
            "type":"SourceFile",
            "start":{"line":176,"column":53,"offset":7087},
            "end":{"line":176,"column":55,"offset":7090}
          },
          "path":"/blah/selectors.js",
          "line":176,
          "endline":176,
          "start":53,
          "end":55
        }
      ]
    },
}

What's missing from the error message is what's under the extra key. The missing flow output should look like this:

     blah/types.js
 [1] 217│ export type MyRecord = RecordOf<Props>;

~Unfortunately I don't really understand how ale_linters#javascript#flow#Handle is being called or why it's only being passed the message key. It it were passed the entire JSON for the error, then some logic could be implemented inside the method to include those references at the bottom of the output.~

Looks like this las paragraph was wrong. Looking into it.

I've added a temporary fix for this in #2725.

This only works for the flow linter. flow-language-server seems to have the same problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

catbaron0 picture catbaron0  Â·  3Comments

kronos29296 picture kronos29296  Â·  4Comments

lervag picture lervag  Â·  3Comments

alexlafroscia picture alexlafroscia  Â·  4Comments

sublee picture sublee  Â·  3Comments