diff --git a/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim index bc7c0321..5183f4cd 100644 --- a/autoload/ale/handlers/eslint.vim +++ b/autoload/ale/handlers/eslint.vim @@ -143,6 +143,11 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort " The code can be something like 'Error/foo/bar', or just 'Error' if !empty(get(l:split_code, 1)) let l:obj.code = join(l:split_code[1:], '/') + + if l:obj.code is# 'no-trailing-spaces' + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + continue + endif endif for l:col_match in ale#util#GetMatches(l:text, s:col_end_patterns) diff --git a/test/handler/test_eslint_handler.vader b/test/handler/test_eslint_handler.vader index 1bb438a6..01dd2c8f 100644 --- a/test/handler/test_eslint_handler.vader +++ b/test/handler/test_eslint_handler.vader @@ -1,15 +1,23 @@ Before: Save g:ale_javascript_eslint_suppress_eslintignore Save g:ale_javascript_eslint_suppress_missing_config + Save g:ale_warn_about_trailing_whitespace + Save g:ale_warn_about_trailing_blank_lines let g:ale_javascript_eslint_suppress_eslintignore = 0 let g:ale_javascript_eslint_suppress_missing_config = 0 + let g:ale_warn_about_trailing_whitespace = 1 + let g:ale_warn_about_trailing_blank_lines = 1 + unlet! b:ale_warn_about_trailing_whitespace + unlet! b:ale_warn_about_trailing_blank_lines After: Restore unlet! b:ale_javascript_eslint_suppress_eslintignore unlet! b:ale_javascript_eslint_suppress_missing_config + unlet! b:ale_warn_about_trailing_whitespace + unlet! b:ale_warn_about_trailing_blank_lines unlet! g:config_error_lines Execute(The eslint handler should parse lines correctly): @@ -394,3 +402,37 @@ Execute(Failing to connect to eslint_d should be handled correctly): \ ale#handlers#eslint#Handle(bufnr(''), [ \ 'Could not connect', \ ]) + +Execute(Disabling warnings about trailing spaces should work): + silent! noautocmd file foo.ts + + AssertEqual + \ [ + \ { + \ 'lnum': 182, + \ 'col': 22, + \ 'code': 'no-trailing-spaces', + \ 'type': 'E', + \ 'text': 'Trailing spaces not allowed.', + \ }, + \ ], + \ ale#handlers#eslint#Handle(bufnr(''), [ + \ 'foo.js:182:22: Trailing spaces not allowed. [Error/no-trailing-spaces]', + \ ]) + + let g:ale_warn_about_trailing_whitespace = 0 + + AssertEqual + \ [], + \ ale#handlers#eslint#Handle(bufnr(''), [ + \ 'foo.js:182:22: Trailing spaces not allowed. [Error/no-trailing-spaces]', + \ ]) + + let g:ale_warn_about_trailing_whitespace = 1 + let b:ale_warn_about_trailing_whitespace = 0 + + AssertEqual + \ [], + \ ale#handlers#eslint#Handle(bufnr(''), [ + \ 'foo.js:182:22: Trailing spaces not allowed. [Error/no-trailing-spaces]', + \ ])