summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/biome.vim17
-rw-r--r--autoload/ale/handlers/biome.vim14
-rw-r--r--doc/ale-javascript.txt27
-rw-r--r--doc/ale-supported-languages-and-tools.txt2
-rw-r--r--doc/ale-typescript.txt6
-rw-r--r--doc/ale.txt2
-rw-r--r--supported-tools.md2
-rw-r--r--test/fixers/test_biome_fixer_callback.vader30
-rw-r--r--test/test-files/biome/node_modules/.bin/biome0
-rw-r--r--test/test-files/biome/src/test.js0
11 files changed, 105 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 0cad0a99..044a14d5 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -646,6 +646,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['ruby'],
\ '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.
diff --git a/autoload/ale/fixers/biome.vim b/autoload/ale/fixers/biome.vim
new file mode 100644
index 00000000..3a45fa3e
--- /dev/null
+++ b/autoload/ale/fixers/biome.vim
@@ -0,0 +1,17 @@
+" Author: Akiomi Kamakura <akiomik@gmail.com>
+" Description: Fixing files with biome (ex.rome).
+
+function! ale#fixers#biome#Fix(buffer) abort
+ let l:executable = ale#handlers#biome#GetExecutable(a:buffer)
+ let l:options = ale#Var(a:buffer, 'javascript_biome_options')
+ let l:node = ale#Var(a:buffer, 'javascript_biome_node_executable')
+
+ return {
+ \ 'command': (has('win32') ? (ale#Escape(l:node) . ' ') : '')
+ \ . ale#Escape(l:executable)
+ \ . ' check --apply'
+ \ . ale#Pad(l:options)
+ \ . ' %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/autoload/ale/handlers/biome.vim b/autoload/ale/handlers/biome.vim
new file mode 100644
index 00000000..8d75e3bc
--- /dev/null
+++ b/autoload/ale/handlers/biome.vim
@@ -0,0 +1,14 @@
+" Author: Akiomi Kamakura <akiomik@gmail.com>
+" Description: Functions for working with biome, for fixing files.
+
+call ale#Set('javascript_biome_node_executable', 'node.exe')
+call ale#Set('javascript_biome_executable', 'biome')
+call ale#Set('javascript_biome_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('javascript_biome_options', '')
+
+function! ale#handlers#biome#GetExecutable(buffer) abort
+ return ale#path#FindExecutable(a:buffer, 'javascript_biome', [
+ \ 'node_modules/.bin/biome',
+ \ 'node_modules/@biomejs/biome/bin/biome',
+ \])
+endfunction
diff --git a/doc/ale-javascript.txt b/doc/ale-javascript.txt
index a55cd643..98c582da 100644
--- a/doc/ale-javascript.txt
+++ b/doc/ale-javascript.txt
@@ -26,6 +26,33 @@ To this: >
===============================================================================
+biome *ale-javascript-biome*
+
+g:ale_javascript_biome_executable *g:ale_javascript_biome_executable*
+ *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.
+
+
+===============================================================================
clang-format *ale-javascript-clangformat*
See |ale-c-clangformat| for information about the available options.
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index d9099879..403aa842 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -292,6 +292,7 @@ Notes:
* `javalsp`
* `uncrustify`
* JavaScript
+ * `biome`
* `clang-format`
* `cspell`
* `deno`
@@ -653,6 +654,7 @@ Notes:
* TOML
* `dprint`
* TypeScript
+ * `biome`
* `cspell`
* `deno`
* `dprint`
diff --git a/doc/ale-typescript.txt b/doc/ale-typescript.txt
index ab3f17bd..1641e60e 100644
--- a/doc/ale-typescript.txt
+++ b/doc/ale-typescript.txt
@@ -3,6 +3,12 @@ ALE TypeScript Integration *ale-typescript-options*
===============================================================================
+biome *ale-typescript-biome*
+
+See |ale-javascript-biome|
+
+
+===============================================================================
cspell *ale-typescript-cspell*
See |ale-cspell-options|
diff --git a/doc/ale.txt b/doc/ale.txt
index c76abfbe..756735f7 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -3116,6 +3116,7 @@ documented in additional help files.
eclipselsp............................|ale-java-eclipselsp|
uncrustify............................|ale-java-uncrustify|
javascript..............................|ale-javascript-options|
+ biome.................................|ale-javascript-biome|
clang-format..........................|ale-javascript-clangformat|
cspell................................|ale-javascript-cspell|
deno..................................|ale-javascript-deno|
@@ -3439,6 +3440,7 @@ documented in additional help files.
toml....................................|ale-toml-options|
dprint................................|ale-toml-dprint|
typescript..............................|ale-typescript-options|
+ biome.................................|ale-typescript-biome|
cspell................................|ale-typescript-cspell|
deno..................................|ale-typescript-deno|
dprint................................|ale-typescript-dprint|
diff --git a/supported-tools.md b/supported-tools.md
index 414fefe4..785b1b27 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -301,6 +301,7 @@ formatting.
* [javalsp](https://github.com/georgewfraser/vscode-javac)
* [uncrustify](https://github.com/uncrustify/uncrustify)
* JavaScript
+ * [biome](http://biomejs.dev)
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
* [deno](https://deno.land/)
@@ -662,6 +663,7 @@ formatting.
* TOML
* [dprint](https://dprint.dev)
* TypeScript
+ * [biome](http://biomejs.dev)
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
* [deno](https://deno.land/)
* [dprint](https://dprint.dev/)
diff --git a/test/fixers/test_biome_fixer_callback.vader b/test/fixers/test_biome_fixer_callback.vader
new file mode 100644
index 00000000..0cb4888e
--- /dev/null
+++ b/test/fixers/test_biome_fixer_callback.vader
@@ -0,0 +1,30 @@
+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',
+ \ }
diff --git a/test/test-files/biome/node_modules/.bin/biome b/test/test-files/biome/node_modules/.bin/biome
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/test-files/biome/node_modules/.bin/biome
diff --git a/test/test-files/biome/src/test.js b/test/test-files/biome/src/test.js
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/test-files/biome/src/test.js