Make eslint respect the ale_warn_about_trailing_whitespace setting
This commit is contained in:
parent
3303f596e5
commit
7943bfab96
@ -143,6 +143,11 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort
|
|||||||
" The code can be something like 'Error/foo/bar', or just 'Error'
|
" The code can be something like 'Error/foo/bar', or just 'Error'
|
||||||
if !empty(get(l:split_code, 1))
|
if !empty(get(l:split_code, 1))
|
||||||
let l:obj.code = join(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
|
endif
|
||||||
|
|
||||||
for l:col_match in ale#util#GetMatches(l:text, s:col_end_patterns)
|
for l:col_match in ale#util#GetMatches(l:text, s:col_end_patterns)
|
||||||
|
@ -1,15 +1,23 @@
|
|||||||
Before:
|
Before:
|
||||||
Save g:ale_javascript_eslint_suppress_eslintignore
|
Save g:ale_javascript_eslint_suppress_eslintignore
|
||||||
Save g:ale_javascript_eslint_suppress_missing_config
|
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_eslintignore = 0
|
||||||
let g:ale_javascript_eslint_suppress_missing_config = 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:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
unlet! b:ale_javascript_eslint_suppress_eslintignore
|
unlet! b:ale_javascript_eslint_suppress_eslintignore
|
||||||
unlet! b:ale_javascript_eslint_suppress_missing_config
|
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
|
unlet! g:config_error_lines
|
||||||
|
|
||||||
Execute(The eslint handler should parse lines correctly):
|
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(''), [
|
\ ale#handlers#eslint#Handle(bufnr(''), [
|
||||||
\ 'Could not connect',
|
\ '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]',
|
||||||
|
\ ])
|
||||||
|
Loading…
Reference in New Issue
Block a user