mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 13:34:46 +08:00
Add support for astro (#4780)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--neovim-06-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--neovim-06-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
* feat: prettier for astro * feat: eslint for astro * feat: doc for astro
This commit is contained in:
11
ale_linters/astro/eslint.vim
Normal file
11
ale_linters/astro/eslint.vim
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
" Author: Hyuksang Kwon <gwonhyuksang@gmail.com>
|
||||||
|
" Description: eslint for astro files
|
||||||
|
|
||||||
|
call ale#linter#Define('astro', {
|
||||||
|
\ 'name': 'eslint',
|
||||||
|
\ 'output_stream': 'both',
|
||||||
|
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
|
||||||
|
\ 'cwd': function('ale#handlers#eslint#GetCwd'),
|
||||||
|
\ 'command': function('ale#handlers#eslint#GetCommand'),
|
||||||
|
\ 'callback': 'ale#handlers#eslint#HandleJSON',
|
||||||
|
\})
|
||||||
@@ -137,7 +137,7 @@ let s:default_registry = {
|
|||||||
\ },
|
\ },
|
||||||
\ 'eslint': {
|
\ 'eslint': {
|
||||||
\ 'function': 'ale#fixers#eslint#Fix',
|
\ 'function': 'ale#fixers#eslint#Fix',
|
||||||
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
\ 'suggested_filetypes': ['javascript', 'typescript', 'astro'],
|
||||||
\ 'description': 'Apply eslint --fix to a file.',
|
\ 'description': 'Apply eslint --fix to a file.',
|
||||||
\ },
|
\ },
|
||||||
\ 'mix_format': {
|
\ 'mix_format': {
|
||||||
@@ -152,7 +152,7 @@ let s:default_registry = {
|
|||||||
\ },
|
\ },
|
||||||
\ 'prettier': {
|
\ 'prettier': {
|
||||||
\ 'function': 'ale#fixers#prettier#Fix',
|
\ 'function': 'ale#fixers#prettier#Fix',
|
||||||
\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'svelte', 'html', 'yaml', 'openapi', 'ruby'],
|
\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'svelte', 'html', 'yaml', 'openapi', 'ruby', 'astro'],
|
||||||
\ 'description': 'Apply prettier to a file.',
|
\ 'description': 'Apply prettier to a file.',
|
||||||
\ },
|
\ },
|
||||||
\ 'prettier_eslint': {
|
\ 'prettier_eslint': {
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
|
|||||||
\ 'openapi': 'yaml',
|
\ 'openapi': 'yaml',
|
||||||
\ 'html': 'html',
|
\ 'html': 'html',
|
||||||
\ 'ruby': 'ruby',
|
\ 'ruby': 'ruby',
|
||||||
|
\ 'astro': 'astro',
|
||||||
\}
|
\}
|
||||||
|
|
||||||
for l:filetype in l:filetypes
|
for l:filetype in l:filetypes
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ let s:default_ale_linter_aliases = {
|
|||||||
" NOTE: Update the g:ale_linters documentation when modifying this.
|
" NOTE: Update the g:ale_linters documentation when modifying this.
|
||||||
let s:default_ale_linters = {
|
let s:default_ale_linters = {
|
||||||
\ 'apkbuild': ['apkbuild_lint', 'secfixes_check'],
|
\ 'apkbuild': ['apkbuild_lint', 'secfixes_check'],
|
||||||
|
\ 'astro': ['eslint'],
|
||||||
\ 'csh': ['shell'],
|
\ 'csh': ['shell'],
|
||||||
\ 'elixir': ['credo', 'dialyxir', 'dogma'],
|
\ 'elixir': ['credo', 'dialyxir', 'dogma'],
|
||||||
\ 'go': ['gofmt', 'golangci-lint', 'gopls', 'govet'],
|
\ 'go': ['gofmt', 'golangci-lint', 'gopls', 'govet'],
|
||||||
|
|||||||
16
doc/ale-astro.txt
Normal file
16
doc/ale-astro.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
===============================================================================
|
||||||
|
ALE Astro Integration *ale-astro-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
eslint *ale-astro-eslint*
|
||||||
|
|
||||||
|
See |ale-javascript-eslint| for information about the available options.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
prettier *ale-astro-prettier*
|
||||||
|
|
||||||
|
See |ale-javascript-prettier| for information about the available options.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
@@ -37,6 +37,9 @@ Notes:
|
|||||||
* ASM
|
* ASM
|
||||||
* `gcc`
|
* `gcc`
|
||||||
* `llvm-mc`
|
* `llvm-mc`
|
||||||
|
* Astro
|
||||||
|
* `eslint`
|
||||||
|
* `prettier`
|
||||||
* AVRA
|
* AVRA
|
||||||
* `avra`
|
* `avra`
|
||||||
* Awk
|
* Awk
|
||||||
|
|||||||
@@ -2899,6 +2899,9 @@ documented in additional help files.
|
|||||||
asm.....................................|ale-asm-options|
|
asm.....................................|ale-asm-options|
|
||||||
gcc...................................|ale-asm-gcc|
|
gcc...................................|ale-asm-gcc|
|
||||||
llvm_mc...............................|ale-asm-llvm_mc|
|
llvm_mc...............................|ale-asm-llvm_mc|
|
||||||
|
astro...................................|ale-astro-options|
|
||||||
|
eslint................................|ale-astro-eslint|
|
||||||
|
prettier..............................|ale-astro-prettier|
|
||||||
avra....................................|ale-avra-options|
|
avra....................................|ale-avra-options|
|
||||||
avra..................................|ale-avra-avra|
|
avra..................................|ale-avra-avra|
|
||||||
awk.....................................|ale-awk-options|
|
awk.....................................|ale-awk-options|
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ formatting.
|
|||||||
* ASM
|
* ASM
|
||||||
* [gcc](https://gcc.gnu.org)
|
* [gcc](https://gcc.gnu.org)
|
||||||
* [llvm-mc](https://llvm.org)
|
* [llvm-mc](https://llvm.org)
|
||||||
|
* Astro
|
||||||
|
* [eslint](http://eslint.org/)
|
||||||
|
* [prettier](https://github.com/prettier/prettier)
|
||||||
* AVRA
|
* AVRA
|
||||||
* [avra](https://github.com/Ro5bert/avra)
|
* [avra](https://github.com/Ro5bert/avra)
|
||||||
* Awk
|
* Awk
|
||||||
|
|||||||
@@ -304,3 +304,18 @@ Execute(The eslint_d post-processor should handle failing to connect properly):
|
|||||||
\ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
|
\ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
|
||||||
\ 'Could not connect',
|
\ 'Could not connect',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
Execute(The executable path should be correct for astro app):
|
||||||
|
call ale#test#SetFilename('../test-files/eslint/astro-app/src/pages/index.astro')
|
||||||
|
|
||||||
|
" eslint_d output with an older eslint version is used here.
|
||||||
|
GivenCommandOutput ['v4.4.1 (eslint_d v5.1.0)']
|
||||||
|
AssertFixer
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app'),
|
||||||
|
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||||
|
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app/node_modules/eslint/bin/eslint.js'))
|
||||||
|
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app/.eslintrc.js'))
|
||||||
|
\ . ' --fix %t',
|
||||||
|
\ }
|
||||||
|
|||||||
@@ -293,6 +293,20 @@ Execute(Should set --parser based on first filetype of multiple filetypes):
|
|||||||
\ . ' --stdin-filepath %s --stdin',
|
\ . ' --stdin-filepath %s --stdin',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
Execute(Should set --parser based on first filetype of multiple filetypes):
|
||||||
|
call ale#test#SetFilename('../test-files/prettier/testfile')
|
||||||
|
|
||||||
|
set filetype=astro
|
||||||
|
|
||||||
|
GivenCommandOutput ['1.6.0']
|
||||||
|
AssertFixer
|
||||||
|
\ {
|
||||||
|
\ 'cwd': '%s:h',
|
||||||
|
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||||
|
\ . ' --parser astro'
|
||||||
|
\ . ' --stdin-filepath %s --stdin',
|
||||||
|
\ }
|
||||||
|
|
||||||
Execute(Should set --parser for experimental language, Handlebars):
|
Execute(Should set --parser for experimental language, Handlebars):
|
||||||
call ale#test#SetFilename('../test-files/prettier/testfile.hbs')
|
call ale#test#SetFilename('../test-files/prettier/testfile.hbs')
|
||||||
|
|
||||||
|
|||||||
@@ -76,3 +76,12 @@ Execute(eslint.js should be run from a containing project with .yarn/sdks):
|
|||||||
AssertLinter b:executable,
|
AssertLinter b:executable,
|
||||||
\ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
|
\ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
|
||||||
\ . ale#Escape(b:executable) . b:args
|
\ . ale#Escape(b:executable) . b:args
|
||||||
|
|
||||||
|
Execute(astro directories should be detected correctly):
|
||||||
|
call ale#test#SetFilename('../test-files/eslint/astro-app/src/pages/index.astro')
|
||||||
|
|
||||||
|
let b:executable = ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app/node_modules/eslint/bin/eslint.js')
|
||||||
|
AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/eslint/astro-app')
|
||||||
|
AssertLinter b:executable,
|
||||||
|
\ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
|
||||||
|
\ . ale#Escape(b:executable) . b:args
|
||||||
|
|||||||
0
test/test-files/eslint/astro-app/.eslintrc.js
Normal file
0
test/test-files/eslint/astro-app/.eslintrc.js
Normal file
0
test/test-files/eslint/astro-app/node_modules/eslint/bin/eslint.js
generated
vendored
Normal file
0
test/test-files/eslint/astro-app/node_modules/eslint/bin/eslint.js
generated
vendored
Normal file
17
test/test-files/eslint/astro-app/package.json
Normal file
17
test/test-files/eslint/astro-app/package.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "astro-app",
|
||||||
|
"type": "module",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "astro dev",
|
||||||
|
"start": "astro dev",
|
||||||
|
"build": "astro check && astro build",
|
||||||
|
"preview": "astro preview",
|
||||||
|
"astro": "astro"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"astro": "^4.8.3",
|
||||||
|
"@astrojs/check": "^0.7.0",
|
||||||
|
"typescript": "^5.4.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
16
test/test-files/eslint/astro-app/src/pages/index.astro
Normal file
16
test/test-files/eslint/astro-app/src/pages/index.astro
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width" />
|
||||||
|
<meta name="generator" content={Astro.generator} />
|
||||||
|
<title>Astro</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Astro</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
3
test/test-files/eslint/astro-app/tsconfig.json
Normal file
3
test/test-files/eslint/astro-app/tsconfig.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "astro/tsconfigs/strict"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user