diff options
author | w0rp <devw0rp@gmail.com> | 2017-10-28 12:11:33 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-10-28 12:11:33 +0100 |
commit | 6e681d9066bde1f2a6b7583fa91e9c94cfffb11e (patch) | |
tree | 811758c00556cb82c26b650bd9452a31be62e1c0 /autoload | |
parent | 0e848b608cc5fe9188e779c75c1b3acf3804c585 (diff) | |
download | ale-6e681d9066bde1f2a6b7583fa91e9c94cfffb11e.zip |
Fix #971 - Add an option for turning errors about missing eslint config files off.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/handlers/eslint.vim | 31 |
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] |