summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKevin Locke <kevin@kevinlocke.name>2019-12-17 10:43:09 -0700
committerKevin Locke <kevin@kevinlocke.name>2019-12-17 12:25:44 -0700
commit9ee57d4362918b7b21d5b22eb46a33a32f44ccda (patch)
treec42a3c78e7de48ddff25c4fe7a756fde31db4c55 /test
parent5f84325cd811ec179b7f3642652438c6a45b174d (diff)
downloadale-9ee57d4362918b7b21d5b22eb46a33a32f44ccda.zip
Run ESLint from project root dir where possible
ESLint 6 loads all plugins/configs/parsers relative to the project root which, by default, is the directory in which ESLint is invoked, as described in [ESLint RFC 2018-simplified-package-loading]. Therefore, ALE should run ESLint from the project root, when possible, so that dependencies will load. This commit does so. [ESLint RFC 2018-simplified-package-loading]: https://github.com/eslint/rfcs/blob/master/designs/2018-simplified-package-loading/README.md Fixes: #2787 Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Diffstat (limited to 'test')
-rw-r--r--test/test_eslint_executable_detection.vader16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/test_eslint_executable_detection.vader b/test/test_eslint_executable_detection.vader
index 64383dcb..c2071131 100644
--- a/test/test_eslint_executable_detection.vader
+++ b/test/test_eslint_executable_detection.vader
@@ -57,13 +57,25 @@ Execute(eslint.js executables should be run with node on Windows):
" We have to execute the file with node.
if has('win32')
AssertEqual
- \ ale#Escape('node.exe') . ' '
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app'))
+ \ . ale#Escape('node.exe') . ' '
\ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' -f json --stdin --stdin-filename %s',
\ ale#handlers#eslint#GetCommand(bufnr(''))
else
AssertEqual
- \ ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app'))
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' -f json --stdin --stdin-filename %s',
\ ale#handlers#eslint#GetCommand(bufnr(''))
endif
+
+Execute(eslint.js executables can be run outside project dir):
+ " Set filename above eslint-test-files (which contains node_modules)
+ call ale#test#SetFilename('testfile.js')
+
+ " cd "..." not present, since project root not found (from node_modules)
+ AssertEqual
+ \ ale#Escape(ale#handlers#eslint#GetExecutable(bufnr('')))
+ \ . ' -f json --stdin --stdin-filename %s',
+ \ ale#handlers#eslint#GetCommand(bufnr(''))