diff options
author | w0rp <devw0rp@gmail.com> | 2017-11-22 23:23:14 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-11-22 23:23:14 +0000 |
commit | 5160f814d929e0936c3d920087e0c4d16040ae9c (patch) | |
tree | 185d2cf775d027a29f23534a54415626608fbbbe /test/fixers | |
parent | 6318a08e08716d460f8441457813875495050023 (diff) | |
download | ale-5160f814d929e0936c3d920087e0c4d16040ae9c.zip |
Fix #988 - Support --fix-dry-run for ESLint by processing the JSON output
Diffstat (limited to 'test/fixers')
-rw-r--r-- | test/fixers/test_eslint_fixer_callback.vader | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/fixers/test_eslint_fixer_callback.vader b/test/fixers/test_eslint_fixer_callback.vader index 8a5eaa4e..afb267a2 100644 --- a/test/fixers/test_eslint_fixer_callback.vader +++ b/test/fixers/test_eslint_fixer_callback.vader @@ -69,6 +69,18 @@ Execute(The version check should be correct): \ }, \ ale#fixers#eslint#Fix(bufnr('')) +Execute(--fix-dry-run should be used for 4.9.0 and up): + call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js') + + AssertEqual + \ { + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json', + \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput', + \ }, + \ ale#fixers#eslint#ApplyFixForVersion(bufnr(''), ['4.9.0']) + Execute(--fix-to-stdout should be used for eslint_d): call ale#test#SetFilename('../eslint-test-files/app-with-eslint-d/testfile.js') @@ -114,3 +126,27 @@ Execute(The version number should be cached): \ 'command': '', \ }, \ ale#fixers#eslint#Fix(bufnr('')) + + " Call it again without the version output. We should use the newer command. + AssertEqual + \ { + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json', + \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput', + \ }, + \ ale#fixers#eslint#ApplyFixForVersion(bufnr(''), []) + +Execute(The --fix-dry-run post-processor should handle JSON output correctly): + AssertEqual + \ [], + \ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), []) + AssertEqual + \ [], + \ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), ['']) + AssertEqual + \ [], + \ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), ['[{}]']) + AssertEqual + \ ['foo', 'bar'], + \ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), ['[{"output": "foo\nbar"}]']) |