diff options
author | w0rp <devw0rp@gmail.com> | 2019-05-17 20:45:25 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-05-17 20:45:25 +0100 |
commit | e6745a38118068dbfe8246041de17a5f5c5bf149 (patch) | |
tree | f743d54b6f9df970d1fb8665d8d6e27f077d2f73 /test/fixers | |
parent | e5ea809094fd1d521ac88516f5b4b6870e656f3a (diff) | |
download | ale-e6745a38118068dbfe8246041de17a5f5c5bf149.zip |
Fix #1989 - Use ESlint options for fixers too
Diffstat (limited to 'test/fixers')
-rw-r--r-- | test/fixers/test_eslint_fixer_callback.vader | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/test/fixers/test_eslint_fixer_callback.vader b/test/fixers/test_eslint_fixer_callback.vader index 7ea9c2cf..ad80bdd5 100644 --- a/test/fixers/test_eslint_fixer_callback.vader +++ b/test/fixers/test_eslint_fixer_callback.vader @@ -19,6 +19,131 @@ Execute(The executable path should be correct): \ . ' --fix %t', \ } +Execute(The ESLint fixer shouldn't run if no configuration file can be found): + call ale#test#SetFilename('../no-configuration') + AssertFixerNotExecuted + +Execute(The ESLint fixer should use a config file option if set for old versions): + call ale#test#SetFilename('../no-configuration') + let b:ale_javascript_eslint_options = '-c /foo.cfg' + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('eslint') . ' -c /foo.cfg --fix %t', + \ } + + let b:ale_javascript_eslint_options = '--bar -c /foo.cfg' + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('eslint') . ' --bar -c /foo.cfg --fix %t', + \ } + + let b:ale_javascript_eslint_options = '--config /foo.cfg' + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('eslint') . ' --config /foo.cfg --fix %t', + \ } + + let b:ale_javascript_eslint_options = '--bar --config /foo.cfg' + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('eslint') . ' --bar --config /foo.cfg --fix %t', + \ } + +Execute(The ESLint fixer should use a -c file option if set for eslint_d): + let b:ale_javascript_eslint_executable = '/bin/eslint_d' + GivenCommandOutput ['v3.19.0 (eslint_d v4.2.0)'] + call ale#test#SetFilename('../no-configuration') + let b:ale_javascript_eslint_options = '-c /foo.cfg' + + AssertFixer + \ { + \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput', + \ 'command': ale#Escape('/bin/eslint_d') + \ . ' -c /foo.cfg' + \ . ' --stdin-filename %s --stdin --fix-to-stdout' + \ } + + let b:ale_javascript_eslint_options = '--bar -c /foo.cfg' + + AssertFixer + \ { + \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput', + \ 'command': ale#Escape('/bin/eslint_d') + \ . ' --bar -c /foo.cfg' + \ . ' --stdin-filename %s --stdin --fix-to-stdout' + \ } + + let b:ale_javascript_eslint_options = '--config /foo.cfg' + + AssertFixer + \ { + \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput', + \ 'command': ale#Escape('/bin/eslint_d') + \ . ' --config /foo.cfg' + \ . ' --stdin-filename %s --stdin --fix-to-stdout' + \ } + + let b:ale_javascript_eslint_options = '--bar --config /foo.cfg' + + AssertFixer + \ { + \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput', + \ 'command': ale#Escape('/bin/eslint_d') + \ . ' --bar --config /foo.cfg' + \ . ' --stdin-filename %s --stdin --fix-to-stdout' + \ } + +Execute(The ESLint fixer should use a config file option if set for new versions): + GivenCommandOutput ['4.9.0'] + call ale#test#SetFilename('../no-configuration') + let b:ale_javascript_eslint_options = '-c /foo.cfg' + + AssertFixer + \ { + \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput', + \ 'command': ale#Escape('eslint') + \ . ' -c /foo.cfg' + \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json' + \ } + + let b:ale_javascript_eslint_options = '--bar -c /foo.cfg' + + AssertFixer + \ { + \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput', + \ 'command': ale#Escape('eslint') + \ . ' --bar -c /foo.cfg' + \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json' + \ } + + let b:ale_javascript_eslint_options = '--config /foo.cfg' + + AssertFixer + \ { + \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput', + \ 'command': ale#Escape('eslint') + \ . ' --config /foo.cfg' + \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json' + \ } + + let b:ale_javascript_eslint_options = '--bar --config /foo.cfg' + + AssertFixer + \ { + \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput', + \ 'command': ale#Escape('eslint') + \ . ' --bar --config /foo.cfg' + \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json' + \ } + Execute(The lower priority configuration file in a nested directory should be preferred): call ale#test#SetFilename('../eslint-test-files/react-app/subdir-with-config/testfile.js') @@ -31,6 +156,31 @@ Execute(The lower priority configuration file in a nested directory should be pr \ . ' --fix %t', \ } +Execute(--config in options should override configuration file detection for old versions): + call ale#test#SetFilename('../eslint-test-files/react-app/subdir-with-config/testfile.js') + + let b:ale_javascript_eslint_options = '--config /foo.cfg' + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ . ' --config /foo.cfg' + \ . ' --fix %t', + \ } + + let b:ale_javascript_eslint_options = '-c /foo.cfg' + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ . ' -c /foo.cfg' + \ . ' --fix %t', + \ } + Execute(package.json should be used as a last resort): call ale#test#SetFilename('../eslint-test-files/react-app/subdir-with-package-json/testfile.js') |