mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 05:24:46 +08:00
Add full support for biome (#4705)
* Revert "Add biome support for javascript (#4701)"
This reverts commit 8922478a83.
* Add support for biome
This commit is contained in:
10
ale_linters/javascript/biome.vim
Normal file
10
ale_linters/javascript/biome.vim
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
" Author: Filip Gospodinov <f@gospodinov.ch>
|
||||||
|
" Description: biome for JavaScript files
|
||||||
|
|
||||||
|
call ale#linter#Define('javascript', {
|
||||||
|
\ 'name': 'biome',
|
||||||
|
\ 'lsp': 'stdio',
|
||||||
|
\ 'executable': function('ale#handlers#biome#GetExecutable'),
|
||||||
|
\ 'command': function('ale#handlers#biome#GetCommand'),
|
||||||
|
\ 'project_root': function('ale#handlers#biome#GetProjectRoot'),
|
||||||
|
\})
|
||||||
10
ale_linters/typescript/biome.vim
Normal file
10
ale_linters/typescript/biome.vim
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
" Author: Filip Gospodinov <f@gospodinov.ch>
|
||||||
|
" Description: biome for TypeScript files
|
||||||
|
|
||||||
|
call ale#linter#Define('typescript', {
|
||||||
|
\ 'name': 'biome',
|
||||||
|
\ 'lsp': 'stdio',
|
||||||
|
\ 'executable': function('ale#handlers#biome#GetExecutable'),
|
||||||
|
\ 'command': function('ale#handlers#biome#GetCommand'),
|
||||||
|
\ 'project_root': function('ale#handlers#biome#GetProjectRoot'),
|
||||||
|
\})
|
||||||
@@ -37,6 +37,11 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['bib'],
|
\ 'suggested_filetypes': ['bib'],
|
||||||
\ 'description': 'Format bib files using bibclean.',
|
\ 'description': 'Format bib files using bibclean.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'biome': {
|
||||||
|
\ 'function': 'ale#fixers#biome#Fix',
|
||||||
|
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
||||||
|
\ 'description': 'Fix JavaScript and TypeScript using biome.',
|
||||||
|
\ },
|
||||||
\ 'black': {
|
\ 'black': {
|
||||||
\ 'function': 'ale#fixers#black#Fix',
|
\ 'function': 'ale#fixers#black#Fix',
|
||||||
\ 'suggested_filetypes': ['python'],
|
\ 'suggested_filetypes': ['python'],
|
||||||
@@ -651,11 +656,6 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['ruby'],
|
\ 'suggested_filetypes': ['ruby'],
|
||||||
\ 'description': 'A formatter for Ruby source code',
|
\ 'description': 'A formatter for Ruby source code',
|
||||||
\ },
|
\ },
|
||||||
\ 'biome': {
|
|
||||||
\ 'function': 'ale#fixers#biome#Fix',
|
|
||||||
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
|
||||||
\ 'description': 'Apply biome (ex. rome) check to a file.',
|
|
||||||
\ },
|
|
||||||
\}
|
\}
|
||||||
|
|
||||||
" Reset the function registry to the default entries.
|
" Reset the function registry to the default entries.
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
" Author: Akiomi Kamakura <akiomik@gmail.com>
|
|
||||||
" Description: Fixing files with biome (ex.rome).
|
|
||||||
|
|
||||||
function! ale#fixers#biome#Fix(buffer) abort
|
function! ale#fixers#biome#Fix(buffer) abort
|
||||||
let l:executable = ale#handlers#biome#GetExecutable(a:buffer)
|
let l:executable = ale#handlers#biome#GetExecutable(a:buffer)
|
||||||
let l:options = ale#Var(a:buffer, 'javascript_biome_options')
|
let l:options = ale#Var(a:buffer, 'biome_options')
|
||||||
let l:node = ale#Var(a:buffer, 'javascript_biome_node_executable')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
\ 'command': (has('win32') ? (ale#Escape(l:node) . ' ') : '')
|
\ 'command': '%e format'
|
||||||
\ . ale#Escape(l:executable)
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
\ . ' check --apply'
|
\ . ' --stdin-file-path=%s',
|
||||||
\ . ale#Pad(l:options)
|
|
||||||
\ . ' %t',
|
|
||||||
\ 'read_temporary_file': 1,
|
|
||||||
\}
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -1,14 +1,31 @@
|
|||||||
" Author: Akiomi Kamakura <akiomik@gmail.com>
|
" Author: Filip Gospodinov <f@gospodinov.ch>
|
||||||
" Description: Functions for working with biome, for fixing files.
|
" Description: Functions for working with biome, for checking or fixing files.
|
||||||
|
|
||||||
call ale#Set('javascript_biome_node_executable', 'node.exe')
|
call ale#Set('biome_executable', 'biome')
|
||||||
call ale#Set('javascript_biome_executable', 'biome')
|
call ale#Set('biome_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||||
call ale#Set('javascript_biome_use_global', get(g:, 'ale_use_global_executables', 0))
|
call ale#Set('biome_options', '')
|
||||||
call ale#Set('javascript_biome_options', '')
|
|
||||||
|
|
||||||
function! ale#handlers#biome#GetExecutable(buffer) abort
|
function! ale#handlers#biome#GetExecutable(buffer) abort
|
||||||
return ale#path#FindExecutable(a:buffer, 'javascript_biome', [
|
return ale#path#FindExecutable(a:buffer, 'biome', [
|
||||||
|
\ 'node_modules/@biomejs/cli-linux-x64/biome',
|
||||||
|
\ 'node_modules/@biomejs/cli-linux-arm64/biome',
|
||||||
|
\ 'node_modules/@biomejs/cli-win32-x64/biome.exe',
|
||||||
|
\ 'node_modules/@biomejs/cli-win32-arm64/biome.exe',
|
||||||
|
\ 'node_modules/@biomejs/cli-darwin-x64/biome',
|
||||||
|
\ 'node_modules/@biomejs/cli-darwin-arm64/biome',
|
||||||
\ 'node_modules/.bin/biome',
|
\ 'node_modules/.bin/biome',
|
||||||
\ 'node_modules/@biomejs/biome/bin/biome',
|
|
||||||
\])
|
\])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! ale#handlers#biome#GetCommand(buffer) abort
|
||||||
|
let l:options = ale#Var(a:buffer, 'biome_options')
|
||||||
|
|
||||||
|
return '%e lsp-proxy'
|
||||||
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale#handlers#biome#GetProjectRoot(buffer) abort
|
||||||
|
let l:biome_file = ale#path#FindNearestFile(a:buffer, 'biome.json')
|
||||||
|
|
||||||
|
return !empty(l:biome_file) ? fnamemodify(l:biome_file, ':h') : ''
|
||||||
|
endfunction
|
||||||
|
|||||||
@@ -28,28 +28,7 @@ To this: >
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
biome *ale-javascript-biome*
|
biome *ale-javascript-biome*
|
||||||
|
|
||||||
g:ale_javascript_biome_executable *g:ale_javascript_biome_executable*
|
Check the docs over at |ale-typescript-biome|.
|
||||||
*b:ale_javascript_biome_executable*
|
|
||||||
Type: |String|
|
|
||||||
Default: `'biome'`
|
|
||||||
|
|
||||||
See |ale-integrations-local-executables|
|
|
||||||
|
|
||||||
|
|
||||||
g:ale_javascript_biome_use_global *g:ale_javascript_biome_use_global*
|
|
||||||
*b:ale_javascript_biome_use_global*
|
|
||||||
Type: |Number|
|
|
||||||
Default: `get(g:, 'ale_use_global_executables', 0)`
|
|
||||||
|
|
||||||
See |ale-integrations-local-executables|
|
|
||||||
|
|
||||||
|
|
||||||
g:ale_javascript_biome_options *g:ale_javascript_biome_options*
|
|
||||||
*b:ale_javascript_biome_options*
|
|
||||||
Type: |String|
|
|
||||||
Default: `''`
|
|
||||||
|
|
||||||
This variable can be set to pass additional options to biome.
|
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|||||||
@@ -5,7 +5,26 @@ ALE TypeScript Integration *ale-typescript-options*
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
biome *ale-typescript-biome*
|
biome *ale-typescript-biome*
|
||||||
|
|
||||||
See |ale-javascript-biome|
|
g:ale_biome_executable *g:ale_biome_executable*
|
||||||
|
*b:ale_biome_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'biome'`
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_biome_options *g:ale_biome_options*
|
||||||
|
*b:ale_biome_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to biome.
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_biome_use_global *g:ale_biome_use_global*
|
||||||
|
*b:ale_biome_use_global*
|
||||||
|
Type: |Number|
|
||||||
|
Default: `get(g:, 'ale_use_global_executables', 0)`
|
||||||
|
|
||||||
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|||||||
@@ -302,7 +302,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
|
||||||
* [biome](http://biomejs.dev)
|
* [biome](https://biomejs.dev/)
|
||||||
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
|
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
|
||||||
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
|
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
|
||||||
* [deno](https://deno.land/)
|
* [deno](https://deno.land/)
|
||||||
@@ -666,7 +666,7 @@ formatting.
|
|||||||
* TOML
|
* TOML
|
||||||
* [dprint](https://dprint.dev)
|
* [dprint](https://dprint.dev)
|
||||||
* TypeScript
|
* TypeScript
|
||||||
* [biome](http://biomejs.dev)
|
* [biome](https://biomejs.dev/)
|
||||||
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
|
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
|
||||||
* [deno](https://deno.land/)
|
* [deno](https://deno.land/)
|
||||||
* [dprint](https://dprint.dev/)
|
* [dprint](https://dprint.dev/)
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
Before:
|
|
||||||
call ale#assert#SetUpFixerTest('javascript', 'biome')
|
|
||||||
runtime autoload/ale/handlers/biome.vim
|
|
||||||
set filetype=javascript
|
|
||||||
|
|
||||||
After:
|
|
||||||
call ale#assert#TearDownFixerTest()
|
|
||||||
|
|
||||||
Execute(The biome callback should return the correct default values):
|
|
||||||
call ale#test#SetFilename('../test-files/biome/src/test.js')
|
|
||||||
|
|
||||||
AssertFixer
|
|
||||||
\ {
|
|
||||||
\ 'read_temporary_file': 1,
|
|
||||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
|
||||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/biome/node_modules/.bin/biome'))
|
|
||||||
\ . ' check --apply %t',
|
|
||||||
\ }
|
|
||||||
|
|
||||||
Execute(The biome callback should include custom biome options):
|
|
||||||
let b:ale_javascript_biome_options = '--organize-imports-enabled=true'
|
|
||||||
call ale#test#SetFilename('../test-files/biome/src/test.js')
|
|
||||||
|
|
||||||
AssertFixer
|
|
||||||
\ {
|
|
||||||
\ 'read_temporary_file': 1,
|
|
||||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
|
||||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/biome/node_modules/.bin/biome'))
|
|
||||||
\ . ' check --apply --organize-imports-enabled=true %t',
|
|
||||||
\ }
|
|
||||||
14
test/linter/test_typescript_biome.vader
Normal file
14
test/linter/test_typescript_biome.vader
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
Before:
|
||||||
|
call ale#assert#SetUpLinterTest('typescript', 'biome')
|
||||||
|
call ale#test#SetFilename('test.ts')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
Execute(The default biome command should be correct):
|
||||||
|
AssertLinter 'biome', ale#Escape('biome') . ' lsp-proxy'
|
||||||
|
|
||||||
|
Execute(The biome command should accept options):
|
||||||
|
let b:ale_biome_options = '--foobar'
|
||||||
|
|
||||||
|
AssertLinter 'biome', ale#Escape('biome') . ' lsp-proxy --foobar'
|
||||||
0
test/test-files/biome/node_modules/.bin/biome
generated
vendored
0
test/test-files/biome/node_modules/.bin/biome
generated
vendored
Reference in New Issue
Block a user