summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold Chand <creativenull@outlook.com>2021-10-01 20:51:22 -0400
committerGitHub <noreply@github.com>2021-10-02 09:51:22 +0900
commit19b0f72c237b861d46cefbc30a745da401e10c65 (patch)
treed68dc6cf815ebb77b36fa959e2c755acd6bf6b21
parent708e810414d124b17b0c42e872b387a7a6c2ea85 (diff)
downloadale-19b0f72c237b861d46cefbc30a745da401e10c65.zip
feat: add deno lsp for javascript (#3924)
* feat(js/deno): add deno lsp * fix(doc/typescript): typo * feat(doc/javascript): add deno lsp information * feat(doc/supported-tools): add deno to js list, sorted * fix(doc/javascript): update ToC and supported tools w/ deno
-rw-r--r--ale_linters/javascript/deno.vim11
-rw-r--r--doc/ale-javascript.txt5
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale-typescript.txt2
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/linter/test_javascript_deno_lsp.vader79
-rw-r--r--test/test-files/javascript_deno/custom_import_map.json3
-rw-r--r--test/test-files/javascript_deno/import_map.json3
-rw-r--r--test/test-files/javascript_deno/main.js1
-rw-r--r--test/test-files/javascript_deno/tsconfig.json16
11 files changed, 122 insertions, 1 deletions
diff --git a/ale_linters/javascript/deno.vim b/ale_linters/javascript/deno.vim
new file mode 100644
index 00000000..659eb855
--- /dev/null
+++ b/ale_linters/javascript/deno.vim
@@ -0,0 +1,11 @@
+" Author: Arnold Chand <creativenull@outlook.com>
+" Description: Deno lsp linter for JavaScript files.
+
+call ale#linter#Define('javascript', {
+\ 'name': 'deno',
+\ 'lsp': 'stdio',
+\ 'executable': function('ale#handlers#deno#GetExecutable'),
+\ 'command': '%e lsp',
+\ 'project_root': function('ale#handlers#deno#GetProjectRoot'),
+\ 'initialization_options': function('ale#handlers#deno#GetInitializationOptions'),
+\})
diff --git a/doc/ale-javascript.txt b/doc/ale-javascript.txt
index 13059eaa..acd886c9 100644
--- a/doc/ale-javascript.txt
+++ b/doc/ale-javascript.txt
@@ -24,6 +24,11 @@ To this: >
<
===============================================================================
+deno *ale-javascript-deno*
+
+Check the docs over at |ale-typescript-deno|.
+
+===============================================================================
eslint *ale-javascript-eslint*
g:ale_javascript_eslint_executable *g:ale_javascript_eslint_executable*
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index fec6937e..fb244c88 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -249,6 +249,7 @@ Notes:
* `javalsp`
* `uncrustify`
* JavaScript
+ * `deno`
* `eslint`
* `fecs`
* `flow`
diff --git a/doc/ale-typescript.txt b/doc/ale-typescript.txt
index e2ee49c2..8984e183 100644
--- a/doc/ale-typescript.txt
+++ b/doc/ale-typescript.txt
@@ -23,7 +23,7 @@ g:ale_deno_lsp_project_root *g:ale_deno_lsp_project_root*
executing the following steps in the given order:
1. Find an ancestor directory containing a tsconfig.json.
- 2. Find an ancestory irectory containing a .git folder.
+ 2. Find an ancestory directory containing a .git folder.
3. Use the directory of the current buffer (if the buffer was opened from
a file).
diff --git a/doc/ale.txt b/doc/ale.txt
index 1da2d4a1..15ebb5ed 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2811,6 +2811,7 @@ documented in additional help files.
eclipselsp............................|ale-java-eclipselsp|
uncrustify............................|ale-java-uncrustify|
javascript..............................|ale-javascript-options|
+ deno..................................|ale-javascript-deno|
eslint................................|ale-javascript-eslint|
fecs..................................|ale-javascript-fecs|
flow..................................|ale-javascript-flow|
diff --git a/supported-tools.md b/supported-tools.md
index 774029e0..49a83d75 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -258,6 +258,7 @@ formatting.
* [javalsp](https://github.com/georgewfraser/vscode-javac)
* [uncrustify](https://github.com/uncrustify/uncrustify)
* JavaScript
+ * [deno](https://deno.land/)
* [eslint](http://eslint.org/)
* [fecs](http://fecs.baidu.com/)
* [flow](https://flowtype.org/)
diff --git a/test/linter/test_javascript_deno_lsp.vader b/test/linter/test_javascript_deno_lsp.vader
new file mode 100644
index 00000000..965ce600
--- /dev/null
+++ b/test/linter/test_javascript_deno_lsp.vader
@@ -0,0 +1,79 @@
+Before:
+ let g:ale_deno_importMap = 'import_map.json'
+ let g:ale_deno_unstable = 0
+ let g:ale_deno_executable = 'deno'
+ let g:ale_deno_lsp_project_root = ''
+
+ runtime autoload/ale/handlers/deno.vim
+ call ale#assert#SetUpLinterTest('javascript', 'deno')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(Should set deno lsp for JavaScript projects using stable Deno API):
+ AssertLSPOptions {
+ \ 'enable': v:true,
+ \ 'lint': v:true,
+ \ 'unstable': v:false,
+ \ 'importMap': ''
+ \}
+
+Execute(Should set deno lsp using unstable Deno API if enabled by user):
+ let g:ale_deno_unstable = 1
+
+ AssertLSPOptions {
+ \ 'enable': v:true,
+ \ 'lint': v:true,
+ \ 'unstable': v:true,
+ \ 'importMap': ''
+ \}
+
+Execute(Should set the default importMap filepath):
+ call ale#test#SetFilename('../test-files/javascript_deno/main.js')
+
+ AssertLSPOptions {
+ \ 'enable': v:true,
+ \ 'lint': v:true,
+ \ 'unstable': v:false,
+ \ 'importMap': ale#path#Simplify(g:dir . '/../test-files/javascript_deno/import_map.json')
+ \}
+
+Execute(Should set the importMap filepath from user defined importMap):
+ let g:ale_deno_importMap = 'custom_import_map.json'
+ call ale#test#SetFilename('../test-files/javascript_deno/main.js')
+
+ AssertLSPOptions {
+ \ 'enable': v:true,
+ \ 'lint': v:true,
+ \ 'unstable': v:false,
+ \ 'importMap': ale#path#Simplify(g:dir . '/../test-files/javascript_deno/custom_import_map.json')
+ \}
+
+Execute(Should set the importMap filepath from user defined importMap with unstable API):
+ let g:ale_deno_importMap = 'custom_import_map.json'
+ let g:ale_deno_unstable = 1
+ call ale#test#SetFilename('../test-files/javascript_deno/main.js')
+
+ AssertLSPOptions {
+ \ 'enable': v:true,
+ \ 'lint': v:true,
+ \ 'unstable': v:true,
+ \ 'importMap': ale#path#Simplify(g:dir . '/../test-files/javascript_deno/custom_import_map.json')
+ \}
+
+Execute(Should find project root containing tsconfig.json):
+ call ale#test#SetFilename('../test-files/javascript_deno/main.js')
+
+ AssertLSPLanguage 'javascript'
+ AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/javascript_deno')
+
+Execute(Should use user-specified project root):
+ let g:ale_deno_lsp_project_root = '/'
+
+ call ale#test#SetFilename('../test-files/javascript_deno/main.js')
+
+ AssertLSPLanguage 'javascript'
+ AssertLSPProject '/'
+
+Execute(Check Deno LSP command):
+ AssertLinter 'deno', ale#Escape('deno') . ' lsp'
diff --git a/test/test-files/javascript_deno/custom_import_map.json b/test/test-files/javascript_deno/custom_import_map.json
new file mode 100644
index 00000000..9f5a19a1
--- /dev/null
+++ b/test/test-files/javascript_deno/custom_import_map.json
@@ -0,0 +1,3 @@
+{
+ "imports": {}
+}
diff --git a/test/test-files/javascript_deno/import_map.json b/test/test-files/javascript_deno/import_map.json
new file mode 100644
index 00000000..9f5a19a1
--- /dev/null
+++ b/test/test-files/javascript_deno/import_map.json
@@ -0,0 +1,3 @@
+{
+ "imports": {}
+}
diff --git a/test/test-files/javascript_deno/main.js b/test/test-files/javascript_deno/main.js
new file mode 100644
index 00000000..accefceb
--- /dev/null
+++ b/test/test-files/javascript_deno/main.js
@@ -0,0 +1 @@
+console.log("Hello World");
diff --git a/test/test-files/javascript_deno/tsconfig.json b/test/test-files/javascript_deno/tsconfig.json
new file mode 100644
index 00000000..152b034e
--- /dev/null
+++ b/test/test-files/javascript_deno/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "allowJs": true,
+ "esModuleInterop": true,
+ "experimentalDecorators": true,
+ "inlineSourceMap": true,
+ "isolatedModules": true,
+ "jsx": "react",
+ "lib": ["deno.window"],
+ "module": "esnext",
+ "strict": true,
+ "target": "esnext",
+ "useDefineForClassFields": true
+ },
+ "includes": ["main.js"]
+}