mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 20:54:26 +08:00
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
This commit is contained in:
11
ale_linters/javascript/deno.vim
Normal file
11
ale_linters/javascript/deno.vim
Normal file
@@ -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'),
|
||||||
|
\})
|
||||||
@@ -23,6 +23,11 @@ To this: >
|
|||||||
/path/foo/bar/.eslintrc.js # extends: ["/path/foo/.base-eslintrc.js"]
|
/path/foo/bar/.eslintrc.js # extends: ["/path/foo/.base-eslintrc.js"]
|
||||||
<
|
<
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
deno *ale-javascript-deno*
|
||||||
|
|
||||||
|
Check the docs over at |ale-typescript-deno|.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
eslint *ale-javascript-eslint*
|
eslint *ale-javascript-eslint*
|
||||||
|
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ Notes:
|
|||||||
* `javalsp`
|
* `javalsp`
|
||||||
* `uncrustify`
|
* `uncrustify`
|
||||||
* JavaScript
|
* JavaScript
|
||||||
|
* `deno`
|
||||||
* `eslint`
|
* `eslint`
|
||||||
* `fecs`
|
* `fecs`
|
||||||
* `flow`
|
* `flow`
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ g:ale_deno_lsp_project_root *g:ale_deno_lsp_project_root*
|
|||||||
executing the following steps in the given order:
|
executing the following steps in the given order:
|
||||||
|
|
||||||
1. Find an ancestor directory containing a tsconfig.json.
|
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
|
3. Use the directory of the current buffer (if the buffer was opened from
|
||||||
a file).
|
a file).
|
||||||
|
|
||||||
|
|||||||
@@ -2811,6 +2811,7 @@ documented in additional help files.
|
|||||||
eclipselsp............................|ale-java-eclipselsp|
|
eclipselsp............................|ale-java-eclipselsp|
|
||||||
uncrustify............................|ale-java-uncrustify|
|
uncrustify............................|ale-java-uncrustify|
|
||||||
javascript..............................|ale-javascript-options|
|
javascript..............................|ale-javascript-options|
|
||||||
|
deno..................................|ale-javascript-deno|
|
||||||
eslint................................|ale-javascript-eslint|
|
eslint................................|ale-javascript-eslint|
|
||||||
fecs..................................|ale-javascript-fecs|
|
fecs..................................|ale-javascript-fecs|
|
||||||
flow..................................|ale-javascript-flow|
|
flow..................................|ale-javascript-flow|
|
||||||
|
|||||||
@@ -258,6 +258,7 @@ formatting.
|
|||||||
* [javalsp](https://github.com/georgewfraser/vscode-javac)
|
* [javalsp](https://github.com/georgewfraser/vscode-javac)
|
||||||
* [uncrustify](https://github.com/uncrustify/uncrustify)
|
* [uncrustify](https://github.com/uncrustify/uncrustify)
|
||||||
* JavaScript
|
* JavaScript
|
||||||
|
* [deno](https://deno.land/)
|
||||||
* [eslint](http://eslint.org/)
|
* [eslint](http://eslint.org/)
|
||||||
* [fecs](http://fecs.baidu.com/)
|
* [fecs](http://fecs.baidu.com/)
|
||||||
* [flow](https://flowtype.org/)
|
* [flow](https://flowtype.org/)
|
||||||
|
|||||||
79
test/linter/test_javascript_deno_lsp.vader
Normal file
79
test/linter/test_javascript_deno_lsp.vader
Normal file
@@ -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'
|
||||||
3
test/test-files/javascript_deno/custom_import_map.json
Normal file
3
test/test-files/javascript_deno/custom_import_map.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"imports": {}
|
||||||
|
}
|
||||||
3
test/test-files/javascript_deno/import_map.json
Normal file
3
test/test-files/javascript_deno/import_map.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"imports": {}
|
||||||
|
}
|
||||||
1
test/test-files/javascript_deno/main.js
Normal file
1
test/test-files/javascript_deno/main.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
console.log("Hello World");
|
||||||
16
test/test-files/javascript_deno/tsconfig.json
Normal file
16
test/test-files/javascript_deno/tsconfig.json
Normal file
@@ -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"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user