dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.55k stars 1.43k forks source link

Missing details from flow errors #900

Closed cideM closed 5 years ago

cideM commented 7 years ago

Not sure if this is an issue with vim-flow or ale. In e.g., Visual Studio Code I see more detailed error messages. Running :ALEDetail in neovim does not help. This is what I see in neovim: Imgur

Here is VSC: Imgur

And here is ALEInfo:


 Current Filetype: javascript.jsx
Available Linters: ['eslint', 'flow', 'jscs', 'jshint', 'standard', 'xo']
  Enabled Linters: ['eslint', 'flow']
 Linter Variables:

let g:ale_javascript_eslint_executable = 'eslint'
let g:ale_javascript_eslint_options = ''
let g:ale_javascript_eslint_use_global = 0
let g:ale_javascript_flow_executable = 'flow'
let g:ale_javascript_flow_use_global = 0
 Global Variables:

let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%s'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'javascript': ['eslint', 'flow']}
let g:ale_open_list = 1
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 1
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = 'λ'
let g:ale_sign_offset = 1000000
let g:ale_sign_warning = 'Λ'
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_warn_about_trailing_whitespace = 1
  Command History:
(started) ['/bin/bash', '-c', '''/home/yuuki/tiniestfinance/node_modules/eslint/bin/eslint.js'' -f unix --stdin --stdin-file
name ''/home/yuuki/tiniestfinance/src/App.js'' < ''/tmp/nvimzGdi0r/2/App.js''']
(started) ['/bin/bash', '-c', '''flow'' --version; echo']
(finished - exit code 0) ['/bin/bash', '-c', '''/home/yuuki/tiniestfinance/node_modules/eslint/bin/eslint.js'' -f unix --std
in --stdin-filename ''/home/yuuki/tiniestfinance/src/App.js'' < ''/tmp/nvimzGdi0r/5/App.js''']
<<<NO OUTPUT RETURNED>>>
(finished - exit code 0) ['/bin/bash', '-c', '''flow'' --version; echo']
(finished - exit code 0) ['/bin/bash', '-c', '''flow'' check-contents --respect-pragma --json --from ale ''/home/yuuki/tinie
stfinance/src/App.js'' < ''/tmp/nvimzGdi0r/6/App.js''; echo']
<<<OUTPUT STARTS>>>
{"flowVersion":"0.53.1","errors":[{"extra":[{"message":[{"context":null,"descr":"Property `handleOnSubmit` is incompatible:"
,"type":"Blame","path":"","line":0,"endline":0,"start":1,"end":0}],"children":[{"message":[{"context":"  handleOnSubmit = as
ync () => {","descr":"Promise","type":"Blame","loc":{"source":"/home/yuuki/tiniestfinance/src/App.js","type":"SourceFile","s
tart":{"line":73,"column":31,"offset":1787},"end":{"line":73,"column":31,"offset":1788}},"path":"/home/yuuki/tiniestfinance/
src/App.js","line":73,"endline":73,"start":31,"end":31},{"context":null,"descr":"This type is incompatible with","type":"Com
ment","path":"","line":0,"endline":0,"start":1,"end":0},{"context":"  handleOnSubmit: (event?: Event) => void,","descr":"und
efined","type":"Blame","loc":{"source":"/home/yuuki/tiniestfinance/src/App.js","type":"SourceFile","start":{"line":14,"colum
n":38,"offset":356},"end":{"line":14,"column":41,"offset":360}},"path":"/home/yuuki/tiniestfinance/src/App.js","line":14,"en
dline":14,"start":38,"end":41}]}]}],"kind":"infer","level":"error","suppressions":[],"message":[{"context":"
<Continue","descr":"props of React element `Continue`","type":"Blame","loc":{"source":"/home/yuuki/tiniestfinance/src/App.js
","type":"SourceFile","start":{"line":105,"column":17,"offset":2823},"end":{"line":112,"column":18,"offset":3181}},"path":"/
home/yuuki/tiniestfinance/src/App.js","line":105,"endline":112,"start":17,"end":18},{"context":null,"descr":"This type is in
compatible with the expected param type of","type":"Comment","path":"","line":0,"endline":0,"start":1,"end":0},{"context":"}
: ContinueProps) => {","descr":"object type","type":"Blame","loc":{"source":"/home/yuuki/tiniestfinance/src/App.js","type":"
SourceFile","start":{"line":29,"column":4,"offset":634},"end":{"line":29,"column":16,"offset":647}},"path":"/home/yuuki/tini
estfinance/src/App.js","line":29,"endline":29,"start":4,"end":16}]}],"passed":false}
<<<OUTPUT ENDS>>>

Pretty JSON

{
  "flowVersion": "0.53.1",
  "errors": [
    {
      "extra": [
        {
          "message": [
            {
              "context": "null",
              "descr": "Property `handleOnSubmit` is incompatible:",
              "type": "Blame",
              "path": "",
              "line": 0,
              "endline": 0,
              "start": 1,
              "end": 0
            }
          ],
          "children": [
            {
              "message": [
                {
                  "context": "handleOnSubmit = async () => {",
                  "descr": "Promise",
                  "type": "Blame",
                  "loc": {
                    "source": "/home/yuuki/tiniestfinance/src/App.js",
                    "type": "SourceFile",
                    "start": {
                      "line": 73,
                      "column": 31,
                      "offset": 1787
                    },
                    "end": {
                      "line": 73,
                      "column": 31,
                      "offset": 1788
                    }
                  },
                  "path": "/home/yuuki/tiniestfinance/src/App.js",
                  "line": 73,
                  "endline": 73,
                  "start": 31,
                  "end": 31
                },
                {
                  "context": "null",
                  "descr": "This type is incompatible with",
                  "type": "Comment",
                  "path": "",
                  "line": 0,
                  "endline": 0,
                  "start": 1,
                  "end": 0
                },
                {
                  "context": "  handleOnSubmit: (event?: Event) => void,",
                  "descr": "undefined",
                  "type": "Blame",
                  "loc": {
                    "source": "/home/yuuki/tiniestfinance/src/App.js",
                    "type": "SourceFile",
                    "start": {
                      "line": 14,
                      "column": 38,
                      "offset": 356
                    },
                    "end": {
                      "line": 14,
                      "column": 41,
                      "offset": 360
                    }
                  },
                  "path": "/home/yuuki/tiniestfinance/src/App.js",
                  "line": 14,
                  "endline": 14,
                  "start": 38,
                  "end": 41
                }
              ]
            }
          ]
        }
      ],
      "kind": "infer",
      "level": "error",
      "suppressions": [],
      "message": [
        {
          "context": "<Continue",
          "descr": "props of React element `Continue`",
          "type": "Blame",
          "loc": {
            "source": "/home/yuuki/tiniestfinance/src/App.js",
            "type": "SourceFile",
            "start": {
              "line": 105,
              "column": 17,
              "offset": 2823
            },
            "end": {
              "line": 112,
              "column": 18,
              "offset": 3181
            }
          },
          "path": "/home/yuuki/tiniestfinance/src/App.js",
          "line": 105,
          "endline": 112,
          "start": 17,
          "end": 18
        },
        {
          "context": null,
          "descr": "This type is incompatible with the expected param type of",
          "type": "Comment",
          "path": "",
          "line": 0,
          "endline": 0,
          "start": 1,
          "end": 0
        },
        {
          "context": "}: ContinueProps) => {",
          "descr": "object type",
          "type": "Blame",
          "loc": {
            "source": "/home/yuuki/tiniestfinance/src/App.js",
            "type": "SourceFile",
            "start": {
              "line": 29,
              "column": 4,
              "offset": 634
            },
            "end": {
              "line": 29,
              "column": 16,
              "offset": 647
            }
          },
          "path": "/home/yuuki/tiniestfinance/src/App.js",
          "line": 29,
          "endline": 29,
          "start": 4,
          "end": 16
        }
      ]
    }
  ],
  "passed": false
}
w0rp commented 7 years ago

The information might be included in the JSON above there somewhere.

cideM commented 7 years ago

I updated the initial post with the entire output of ALEInfo

cideM commented 7 years ago

I looked at the source code for the flow.vim file and even though I have no experience in vim scripting it seems like Ale simply does not parse the extra field. It parses for l:error in get(l:flow_output, 'errors', []) and then for l:message in l:error.message but the details I am missing are in error.extra.message not error.message.

Update

I looked at the VSC flow plugin and it contains types for the old error format and the new format. So bottom line: vim.flow just needs to be updated.

I might take a shot at a PR although considering my lack of expertise in all things (neo)vim internals we'll see how it goes.

w0rp commented 7 years ago

Probably true.

cideM commented 7 years ago

I created a fork with the added functionality in a commit. I am going to play around with it a bit, before a PR, as I can't find a lot of documentation on how flow reports errors.

w0rp commented 7 years ago

Okay, sounds good.

cideM commented 5 years ago

This issue was never closed but it was fixed by https://github.com/w0rp/ale/pull/946

w0rp commented 5 years ago

Thank you for closing this.