dense-analysis / ale

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

json linting with jq doesn't report errors correctly #4765

Open glennie opened 5 months ago

glennie commented 5 months ago

Information

VIM version

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 11 2024 20:38:16) Included patches: 1-16

Operating System: Linux (Debian GNU/Linux trixie/sid)

What went wrong

When editing json files using jq for linting, ALE doesn't report the errors correctly.

  1. Enabled jq for in g:ale_linters for json
  2. Edited a json file with errors

As you can see the details below, jq returns jq: parse error: Expected separator between values at line L, column C for each error. But, in file ale_linters/json/jq.vim(line 8), the regexp to catch the errors/warning is let s:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' (note the ^ in the regexp). Therefore, jq's output is not properly parsed.

using let s:pattern = 'parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' (without ^ in the regexp) gives me expected results, but I'm not sure whether it is correct way to fix it.

:ALEInfo

ALEInfo Ouput Current Filetype: json Available Linters: ['cspell', 'eslint', 'jq', 'jsonlint', 'spectral', 'vscodejson'] Enabled Linters: ['jq'] Ignored Linters: [] Suggested Fixers: 'clang-format' - Fix C, C++, C#, CUDA, Java, JavaScript, JSON, ObjectiveC and Protobuf files with clang-format. 'dprint' - Pluggable and configurable code formatting platform 'fixjson' - Fix JSON files with fixjson. 'jq' - Fix JSON files with jq. 'prettier' - Apply prettier to a file. 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. Linter Variables: let g:ale_json_jq_executable = 'jq' let g:ale_json_jq_filters = '.' let g:ale_json_jq_options = '. --slurp --monochrome-output' Global Variables: let g:ale_cache_executable_check_failures = 0 let g:ale_change_sign_column_color = 1 let g:ale_command_wrapper = '' let g:ale_completion_delay = v:null let g:ale_completion_enabled = 0 let g:ale_completion_max_suggestions = 20 let g:ale_disable_lsp = 'auto' let g:ale_echo_cursor = 1 let g:ale_echo_msg_error_str = '✗' let g:ale_echo_msg_format = '%severity%: [%linter%, %code%] %s' let g:ale_echo_msg_info_str = '💡' let g:ale_echo_msg_warning_str = '⚠' let g:ale_enabled = 1 let g:ale_fix_on_save = 0 let g:ale_fixers = {'cmake': ['cmakeformat'], 'javascript.jsx': ['prettier', 'eslint'], 'markdown': ['dprint'], 'puppet': ['puppetlint'], 'terraform': ['terraform'], 'sh': ['shfmt'], 'graphql': ['prettier', 'eslint'], 'html': ['prettier'], '*': ['remove_trailing_lines', 'trim_whitespace'], 'javascript': ['prettier', 'eslint'], 'rust': ['rustfmt'], 'css': ['prettier'], 'python': ['yapf']} let g:ale_history_enabled = 1 let g:ale_info_default_mode = 'preview' let g:ale_history_log_output = 1 let g:ale_keep_list_window_open = 0 let g:ale_lint_delay = 1000 let g:ale_lint_on_enter = 1 let g:ale_lint_on_filetype_changed = 1 let g:ale_lint_on_insert_leave = 1 let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'always' let g:ale_linter_aliases = {'jinja2': 'jinja', 'dockerfile': 'Dockerfile'} let g:ale_linters = {'rust': ['rls'], 'puppet': ['puppetlint'], 'sh': ['shellcheck'], 'html': ['htmlhint'], 'terraform': ['terraform'], 'go': ['golint', 'go vet'], 'markdown': ['vale'], 'Dockerfile': ['hadolint'], 'yaml': ['yamllint'], 'python': ['pylint', 'pycodestyle', 'flake8', 'pydocstyle'], 'jinja': ['j2lint'], 'javascript.jsx': ['eslint', 'flow'], 'graphql': ['eslint', 'flow'], 'php': ['phpan'], 'ansible': ['ansible-lint'], 'javascript': ['eslint', 'flow'], 'json': ['jq'], 'dockerfile': ['hadolint'], 'yaml.ansible': ['ansible-lint', 'yamllint'], 'css': ['stylelint']} let g:ale_linters_explicit = 0 let g:ale_linters_ignore = {'json': ['prettier']} let g:ale_list_vertical = 0 let g:ale_list_window_size = 3 let g:ale_loclist_msg_format = '%severity%: [%linter%, %code%] %s' let g:ale_max_buffer_history_size = 20 let g:ale_max_signs = -1 let g:ale_maximum_file_size = v:null let g:ale_open_list = 1 let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_root = {} let g:ale_set_balloons = 0 let g:ale_set_highlights = 1 let g:ale_set_loclist = 0 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_info = '💡' let g:ale_sign_offset = 1000000 let g:ale_sign_style_error = '✗' let g:ale_sign_style_warning = '⚠' let g:ale_sign_warning = '⚠' let g:ale_sign_highlight_linenrs = 0 let g:ale_type_map = {} let g:ale_use_neovim_diagnostics_api = 0 let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 'all' let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History: (executable check - success) jq (finished - exit code 5) ['/bin/bash', '-c', '''jq'' < ''/tmp/vSr5vTa/4/manifest.json'''] <<>> jq: parse error: Expected separator between values at line 16, column 18 <<>>