summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBraden Kelley <redbmk@gmail.com>2024-06-20 17:21:19 -0700
committerGitHub <noreply@github.com>2024-06-21 09:21:19 +0900
commitf2aef2f510f1c4c0efea019e7c2dc36799133689 (patch)
tree772231772863f00ccbbbb6ffeec190f4d28a8eb6
parent0cd64c87bf72f9237eedb9bdc9739411be9120cb (diff)
downloadale-f2aef2f510f1c4c0efea019e7c2dc36799133689.zip
fix(biome): run all enabled biome fixers (#4763)
- based on biome config, will format, lint, and/or sort imports - adds variable to apply unsafe fixes, disabled by default fixes: #4754
-rw-r--r--autoload/ale/fixers/biome.vim3
-rw-r--r--autoload/ale/handlers/biome.vim1
-rw-r--r--doc/ale-typescript.txt8
-rw-r--r--test/fixers/test_biome_fixer_callback.vader18
-rw-r--r--test/linter/test_typescript_biome.vader6
5 files changed, 33 insertions, 3 deletions
diff --git a/autoload/ale/fixers/biome.vim b/autoload/ale/fixers/biome.vim
index c16cb3b8..63c0fdbc 100644
--- a/autoload/ale/fixers/biome.vim
+++ b/autoload/ale/fixers/biome.vim
@@ -1,10 +1,11 @@
function! ale#fixers#biome#Fix(buffer) abort
let l:executable = ale#handlers#biome#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'biome_options')
+ let l:apply = ale#Var(a:buffer, 'biome_fixer_apply_unsafe') ? '--apply-unsafe' : '--apply'
return {
\ 'read_temporary_file': 1,
- \ 'command': ale#Escape(l:executable) . ' format'
+ \ 'command': ale#Escape(l:executable) . ' check ' . l:apply
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' %t'
\}
diff --git a/autoload/ale/handlers/biome.vim b/autoload/ale/handlers/biome.vim
index cec98458..e8da6a2f 100644
--- a/autoload/ale/handlers/biome.vim
+++ b/autoload/ale/handlers/biome.vim
@@ -4,6 +4,7 @@
call ale#Set('biome_executable', 'biome')
call ale#Set('biome_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('biome_options', '')
+call ale#Set('biome_fixer_apply_unsafe', 0)
function! ale#handlers#biome#GetExecutable(buffer) abort
return ale#path#FindExecutable(a:buffer, 'biome', [
diff --git a/doc/ale-typescript.txt b/doc/ale-typescript.txt
index 96899a29..967287a2 100644
--- a/doc/ale-typescript.txt
+++ b/doc/ale-typescript.txt
@@ -27,6 +27,14 @@ g:ale_biome_use_global *g:ale_biome_use_global*
See |ale-integrations-local-executables|
+g:ale_biome_fixer_apply_unsafe *g:ale_biome_fixer_apply_unsafe*
+ *b:ale_biome_fixer_apply_unsafe*
+ Type: |Number|
+ Default: `0`
+
+ If set to `1`, biome will apply unsafe fixes along with safe fixes.
+
+
===============================================================================
cspell *ale-typescript-cspell*
diff --git a/test/fixers/test_biome_fixer_callback.vader b/test/fixers/test_biome_fixer_callback.vader
index 4c417394..2922b3e6 100644
--- a/test/fixers/test_biome_fixer_callback.vader
+++ b/test/fixers/test_biome_fixer_callback.vader
@@ -1,4 +1,10 @@
Before:
+ Save g:ale_biome_options
+ Save g:ale_biome_fixer_apply_unsafe
+
+ let g:ale_biome_options = ''
+ let g:ale_biome_fixer_apply_unsafe = 0
+
call ale#assert#SetUpFixerTest('typescript', 'biome')
After:
@@ -11,6 +17,16 @@ Execute(The default biome command should be correct):
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('biome')
- \ . ' format %t'
+ \ . ' check --apply %t'
\ }
+Execute(Unsafe fixes can be applied via an option):
+ call ale#test#SetFilename('../test-files/typescript/test.ts')
+ let g:ale_biome_fixer_apply_unsafe = 1
+
+ AssertFixer
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('biome')
+ \ . ' check --apply-unsafe %t'
+ \ }
diff --git a/test/linter/test_typescript_biome.vader b/test/linter/test_typescript_biome.vader
index 95b8fe82..79bcbebc 100644
--- a/test/linter/test_typescript_biome.vader
+++ b/test/linter/test_typescript_biome.vader
@@ -1,4 +1,8 @@
Before:
+ Save g:ale_biome_options
+
+ let g:ale_biome_options = ''
+
call ale#assert#SetUpLinterTest('typescript', 'biome')
call ale#test#SetFilename('test.ts')
@@ -9,6 +13,6 @@ 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'
+ let g:ale_biome_options = '--foobar'
AssertLinter 'biome', ale#Escape('biome') . ' lsp-proxy --foobar'