mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-16 01:07:06 +08:00
Close #2281 - Separate cwd commands from commands
Working directories are now set seperately from the commands so they can later be swapped out when running linters over projects is supported, and also better support filename mapping for running linters on other machines in future.
This commit is contained in:
76
test/command_callback/test_eslint_command_callback.vader
Normal file
76
test/command_callback/test_eslint_command_callback.vader
Normal file
@@ -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('../eslint-test-files/react-app/subdir/testfile.js')
|
||||
|
||||
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')
|
||||
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files/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('../eslint-test-files/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 . '/../eslint-test-files/react-app')
|
||||
AssertLinter b:executable, ale#Escape(b:executable) . b:args
|
||||
|
||||
Execute(other app directories should be detected correctly):
|
||||
call ale#test#SetFilename('../eslint-test-files/other-app/subdir/testfile.js')
|
||||
|
||||
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/node_modules/.bin/eslint')
|
||||
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files')
|
||||
AssertLinter b:executable, ale#Escape(b:executable) . b:args
|
||||
|
||||
Execute(use-global should override other app directories):
|
||||
call ale#test#SetFilename('../eslint-test-files/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 . '/../eslint-test-files')
|
||||
AssertLinter b:executable, ale#Escape(b:executable) . b:args
|
||||
|
||||
Execute(eslint_d should be detected correctly):
|
||||
call ale#test#SetFilename('../eslint-test-files/app-with-eslint-d/testfile.js')
|
||||
|
||||
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d')
|
||||
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files/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('../eslint-test-files/react-app/subdir/testfile.js')
|
||||
|
||||
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')
|
||||
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files/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('../eslint-test-files/react-app/subdir-with-package-json/testfile.js')
|
||||
|
||||
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')
|
||||
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files/react-app')
|
||||
AssertLinter b:executable,
|
||||
\ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
|
||||
\ . ale#Escape(b:executable) . b:args
|
||||
Reference in New Issue
Block a user