summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/handlers/eslint.vim31
1 files changed, 24 insertions, 7 deletions
diff --git a/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim
index 3397ab5e..d1a3b60f 100644
--- a/autoload/ale/handlers/eslint.vim
+++ b/autoload/ale/handlers/eslint.vim
@@ -7,6 +7,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)
+call ale#Set('javascript_eslint_suppress_missing_config', 0)
function! ale#handlers#eslint#FindConfig(buffer) abort
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
@@ -64,7 +65,7 @@ function! s:AddHintsForTypeScriptParsingErrors(output) abort
endfor
endfunction
-function! ale#handlers#eslint#Handle(buffer, lines) abort
+function! s:CheckForBadConfig(buffer, lines) abort
let l:config_error_pattern = '\v^ESLint couldn''t find a configuration file'
\ . '|^Cannot read config file'
\ . '|^.*Configuration for rule .* is invalid'
@@ -73,15 +74,31 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort
" Look for a message in the first few lines which indicates that
" a configuration file couldn't be found.
for l:line in a:lines[:10]
- if len(matchlist(l:line, l:config_error_pattern)) > 0
- return [{
- \ 'lnum': 1,
- \ 'text': 'eslint configuration error (type :ALEDetail for more information)',
- \ 'detail': join(a:lines, "\n"),
- \}]
+ let l:match = matchlist(l:line, l:config_error_pattern)
+
+ if len(l:match) > 0
+ " Don't show the missing config error if we've disabled it.
+ if ale#Var(a:buffer, 'javascript_eslint_suppress_missing_config')
+ \&& l:match[0] is# 'ESLint couldn''t find a configuration file'
+ return 0
+ endif
+
+ return 1
endif
endfor
+ return 0
+endfunction
+
+function! ale#handlers#eslint#Handle(buffer, lines) abort
+ if s:CheckForBadConfig(a:buffer, a:lines)
+ return [{
+ \ 'lnum': 1,
+ \ 'text': 'eslint configuration error (type :ALEDetail for more information)',
+ \ 'detail': join(a:lines, "\n"),
+ \}]
+ endif
+
" Matches patterns line the following:
"
" /path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]