diff options
author | w0rp <devw0rp@gmail.com> | 2018-09-17 17:32:57 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-09-17 17:32:57 +0100 |
commit | ddb3e6d57acfc9081f8c6846d896542014e3024b (patch) | |
tree | 744aff906ad68b7f729f826c9c3bddaa9ec780d3 | |
parent | a4a4bba884bee9714fcfe70d049e0844ac288743 (diff) | |
download | ale-ddb3e6d57acfc9081f8c6846d896542014e3024b.zip |
Handle failing to connect to eslint_d
-rw-r--r-- | autoload/ale/fixers/eslint.vim | 2 | ||||
-rw-r--r-- | autoload/ale/handlers/eslint.vim | 7 | ||||
-rw-r--r-- | test/fixers/test_eslint_fixer_callback.vader | 7 | ||||
-rw-r--r-- | test/handler/test_eslint_handler.vader | 12 |
4 files changed, 27 insertions, 1 deletions
diff --git a/autoload/ale/fixers/eslint.vim b/autoload/ale/fixers/eslint.vim index 36f47510..ea5b2a63 100644 --- a/autoload/ale/fixers/eslint.vim +++ b/autoload/ale/fixers/eslint.vim @@ -25,7 +25,7 @@ endfunction function! ale#fixers#eslint#ProcessEslintDOutput(buffer, output) abort " If the output is an error message, don't use it. for l:line in a:output[:10] - if l:line =~# '^Error:' + if l:line =~# '\v^Error:|^Could not connect' return [] endif endfor diff --git a/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim index bc10ec21..eda033e4 100644 --- a/autoload/ale/handlers/eslint.vim +++ b/autoload/ale/handlers/eslint.vim @@ -99,6 +99,13 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort \}] endif + if a:lines == ['Could not connect'] + return [{ + \ 'lnum': 1, + \ 'text': 'Could not connect to eslint_d. Try updating eslint_d or killing it.', + \}] + endif + " Matches patterns line the following: " " /path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle] diff --git a/test/fixers/test_eslint_fixer_callback.vader b/test/fixers/test_eslint_fixer_callback.vader index be33825c..774595e3 100644 --- a/test/fixers/test_eslint_fixer_callback.vader +++ b/test/fixers/test_eslint_fixer_callback.vader @@ -170,3 +170,10 @@ Execute(The eslint_d post-processor should handle error messages correctly): \ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [ \ 'Error: No ESLint configuration found.', \ ]) + +Execute(The eslint_d post-processor should handle failing to connect properly): + AssertEqual + \ [], + \ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [ + \ 'Could not connect', + \ ]) diff --git a/test/handler/test_eslint_handler.vader b/test/handler/test_eslint_handler.vader index 2e8bfd2a..4a57927b 100644 --- a/test/handler/test_eslint_handler.vader +++ b/test/handler/test_eslint_handler.vader @@ -365,3 +365,15 @@ Execute(eslint should handle react errors correctly): \ ale#handlers#eslint#Handle(bufnr(''), [ \ '/path/editor-help.jsx:59:9: Property should be placed on the same line as the component declaration [Error/react/jsx-first-prop-new-line]', \ ]) + +Execute(Failing to connect to eslint_d should be handled correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'text': 'Could not connect to eslint_d. Try updating eslint_d or killing it.', + \ }, + \ ], + \ ale#handlers#eslint#Handle(bufnr(''), [ + \ 'Could not connect', + \ ]) |