diff options
author | w0rp <devw0rp@gmail.com> | 2021-03-21 00:21:49 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2021-03-21 00:25:33 +0000 |
commit | f7852dbd0a063d6d82ee17a5057fea53cb79b21d (patch) | |
tree | 00b98a3c668af9313eedd6936475c81eeef7e9b8 /test/linter/test_eslint.vader | |
parent | 35caaecc9fc5822f0474e913d0b7655048fd30ee (diff) | |
download | ale-f7852dbd0a063d6d82ee17a5057fea53cb79b21d.zip |
#3633 - Move linter tests into test/linter
Diffstat (limited to 'test/linter/test_eslint.vader')
-rw-r--r-- | test/linter/test_eslint.vader | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/test/linter/test_eslint.vader b/test/linter/test_eslint.vader new file mode 100644 index 00000000..81518af9 --- /dev/null +++ b/test/linter/test_eslint.vader @@ -0,0 +1,76 @@ +Before: + call ale#assert#SetUpLinterTest('javascript', 'eslint') + runtime autoload/ale/handlers/eslint.vim + + let b:args = ' -f json --stdin --stdin-filename %s' + +After: + unlet! b:args + unlet! b:executable + + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinterCwd '' + AssertLinter 'eslint', ale#Escape('eslint') . b:args + +Execute(create-react-app directories should be detected correctly): + call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js') + + let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js') + AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/react-app') + AssertLinter b:executable, + \ (has('win32') ? ale#Escape('node.exe') . ' ' : '') + \ . ale#Escape(b:executable) . b:args + +Execute(use-global should override create-react-app detection): + call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js') + + let g:ale_javascript_eslint_use_global = 1 + let g:ale_javascript_eslint_executable = 'eslint_d' + + let b:executable = 'eslint_d' + AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/react-app') + AssertLinter b:executable, ale#Escape(b:executable) . b:args + +Execute(other app directories should be detected correctly): + call ale#test#SetFilename('../test-files/eslint/other-app/subdir/testfile.js') + + let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/node_modules/.bin/eslint') + AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint') + AssertLinter b:executable, ale#Escape(b:executable) . b:args + +Execute(use-global should override other app directories): + call ale#test#SetFilename('../test-files/eslint/other-app/subdir/testfile.js') + + let g:ale_javascript_eslint_use_global = 1 + let g:ale_javascript_eslint_executable = 'eslint_d' + + let b:executable = 'eslint_d' + AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint') + AssertLinter b:executable, ale#Escape(b:executable) . b:args + +Execute(eslint_d should be detected correctly): + call ale#test#SetFilename('../test-files/eslint/app-with-eslint-d/testfile.js') + + let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/app-with-eslint-d/node_modules/.bin/eslint_d') + AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/app-with-eslint-d') + AssertLinter b:executable, ale#Escape(b:executable) . b:args + +Execute(eslint.js executables should be run with node on Windows): + call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js') + + let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js') + AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/react-app') + AssertLinter b:executable, + \ (has('win32') ? ale#Escape('node.exe') . ' ' : '') + \ . ale#Escape(b:executable) . b:args + +Execute(eslint.js should be run from a containing project with eslint): + call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-package-json/testfile.js') + + let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js') + AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/react-app') + AssertLinter b:executable, + \ (has('win32') ? ale#Escape('node.exe') . ' ' : '') + \ . ale#Escape(b:executable) . b:args |