Suppress warning about .eslintignore'd file (#836)
* Suppress warning about .eslintignore'd file * Fix slightly ironic lint error * Lock error suppression behind a variable; add docs and tests
This commit is contained in:
parent
1a524ca63e
commit
2f19cf874b
4 changed files with 56 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
call ale#Set('javascript_eslint_options', '')
|
||||
call ale#Set('javascript_eslint_executable', 'eslint')
|
||||
call ale#Set('javascript_eslint_use_global', 0)
|
||||
call ale#Set('javascript_eslint_suppress_eslintignore', 0)
|
||||
|
||||
function! ale#handlers#eslint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_eslint', [
|
||||
|
@ -82,6 +83,12 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort
|
|||
let l:type = 'Error'
|
||||
let l:text = l:match[3]
|
||||
|
||||
if ale#Var(a:buffer, 'javascript_eslint_suppress_eslintignore')
|
||||
if l:text is# 'File ignored because of a matching ignore pattern. Use "--no-ignore" to override.'
|
||||
continue
|
||||
endif
|
||||
endif
|
||||
|
||||
" Take the error type from the output if available.
|
||||
if !empty(l:match[4])
|
||||
let l:type = split(l:match[4], '/')[0]
|
||||
|
|
|
@ -50,6 +50,16 @@ g:ale_javascript_eslint_use_global *g:ale_javascript_eslint_use_global*
|
|||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
g:ale_javascript_eslint_suppress_eslintignore
|
||||
*g:ale_javascript_eslint_suppress_eslintignore*
|
||||
*b:ale_javascript_eslint_suppress_eslintignore*
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
This variable can be set to disable the warning that linting is disabled on
|
||||
the current file due to being covered by `.eslintignore`.
|
||||
|
||||
|
||||
===============================================================================
|
||||
prettier *ale-javascript-prettier*
|
||||
|
||||
|
|
1
test/eslint-test-files/eslintignore/ignored.js
Normal file
1
test/eslint-test-files/eslintignore/ignored.js
Normal file
|
@ -0,0 +1 @@
|
|||
var foo = "bar";
|
38
test/test_eslint_suppress_eslintignore.vader
Normal file
38
test/test_eslint_suppress_eslintignore.vader
Normal file
|
@ -0,0 +1,38 @@
|
|||
Before:
|
||||
Save g:ale_javascript_eslint_suppress_eslintignore
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
runtime ale_linters/javascript/eslint.vim
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(eslint should warn about ignored file):
|
||||
call ale#test#SetFilename('eslint-test-files/eslintignore/ignore.js')
|
||||
|
||||
AssertEqual
|
||||
\ [{
|
||||
\ 'lnum': 0,
|
||||
\ 'col': 0,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'File ignored because of a matching ignore pattern. Use "--no-ignore" to override. [Warning]'
|
||||
\ }],
|
||||
\ ale#handlers#eslint#Handle(347, [
|
||||
\ '/path/to/some/ignored.js:0:0: File ignored because of a matching ignore pattern. Use "--no-ignore" to override. [Warning]',
|
||||
\ ])
|
||||
|
||||
|
||||
Execute(eslint should not warn about ignored file when configured):
|
||||
let g:ale_javascript_eslint_suppress_eslintignore = 1
|
||||
|
||||
call ale#test#SetFilename('eslint-test-files/eslintignore/ignore.js')
|
||||
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale#handlers#eslint#Handle(347, [
|
||||
\ '/path/to/some/ignored.js:0:0: File ignored because of a matching ignore pattern. Use "--no-ignore" to override. [Warning]',
|
||||
\ ])
|
Reference in a new issue