aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Perez Alvarez <danielpza@protonmail.com>2025-01-18 11:08:20 -0800
committerGitHub <noreply@github.com>2025-01-18 11:08:20 -0800
commitfa50cb3a3c7cb8f2b4216760c05f8a885a3ce906 (patch)
treefcfa0df142f091d336a3ee3be7d44796f0efdbb2
parent30b19fa7b3841bb9b811e2ecdcd3782248052ae8 (diff)
feat: add biome formatter (#339)
See https://biomejs.dev/ Alternative formatter to `prettier` closes https://github.com/radian-software/apheleia/issues/323
-rw-r--r--CHANGELOG.md6
-rw-r--r--apheleia-formatters.el3
-rw-r--r--test/formatters/installers/biome.bash1
-rw-r--r--test/formatters/samplecode/biome/in.css13
-rw-r--r--test/formatters/samplecode/biome/in.graphql1
-rw-r--r--test/formatters/samplecode/biome/in.js4
-rw-r--r--test/formatters/samplecode/biome/in.json1
-rw-r--r--test/formatters/samplecode/biome/in.ts1
-rw-r--r--test/formatters/samplecode/biome/out.css6
-rw-r--r--test/formatters/samplecode/biome/out.graphql6
-rw-r--r--test/formatters/samplecode/biome/out.js10
-rw-r--r--test/formatters/samplecode/biome/out.json19
-rw-r--r--test/formatters/samplecode/biome/out.ts6
13 files changed, 76 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb03f72..3297592 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].
+## Unreleased
+### Formatters
+* `biome` ([#339]).
+
+[#339]: https://github.com/radian-software/apheleia/pull/339
+
## 4.3 (released 2024-11-12)
### Features
* New user option `apheleia-skip-functions`, like
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index bef7aa0..ba3aad1 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -35,6 +35,7 @@
"-"))
(brittany . ("brittany"))
(buildifier . ("buildifier"))
+ (biome . ("apheleia-npx" "biome" "format" "--stdin-file-path" filepath))
(caddyfmt . ("caddy" "fmt" "-"))
(clang-format . ("clang-format"
"-assume-filename"
@@ -1177,7 +1178,7 @@ For more implementation detail, see
(setq-local indent-line-function
(buffer-local-value 'indent-line-function buffer))
(setq-local lisp-indent-function
- (buffer-local-value 'lisp-indent-function buffer))
+ (buffer-local-value 'lisp-indent-function buffer))
(setq-local indent-tabs-mode
(buffer-local-value 'indent-tabs-mode buffer))
(goto-char (point-min))
diff --git a/test/formatters/installers/biome.bash b/test/formatters/installers/biome.bash
new file mode 100644
index 0000000..56b6e1b
--- /dev/null
+++ b/test/formatters/installers/biome.bash
@@ -0,0 +1 @@
+npm install -g @biomejs/biome
diff --git a/test/formatters/samplecode/biome/in.css b/test/formatters/samplecode/biome/in.css
new file mode 100644
index 0000000..55d5d36
--- /dev/null
+++ b/test/formatters/samplecode/biome/in.css
@@ -0,0 +1,13 @@
+ body
+
+{
+ padding-left : 11em;
+font-family
+ : Georgia,
+
+ "Times New Roman",
+ Times, serif;
+ color: purple;
+ background-color:
+ #d8da3d
+ }
diff --git a/test/formatters/samplecode/biome/in.graphql b/test/formatters/samplecode/biome/in.graphql
new file mode 100644
index 0000000..72fc73e
--- /dev/null
+++ b/test/formatters/samplecode/biome/in.graphql
@@ -0,0 +1 @@
+{human(id: "1000") {name height(unit: FOOT)}}
diff --git a/test/formatters/samplecode/biome/in.js b/test/formatters/samplecode/biome/in.js
new file mode 100644
index 0000000..fd56713
--- /dev/null
+++ b/test/formatters/samplecode/biome/in.js
@@ -0,0 +1,4 @@
+function HelloWorld({greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) {
+
+ if(!greeting){return null};
+ }
diff --git a/test/formatters/samplecode/biome/in.json b/test/formatters/samplecode/biome/in.json
new file mode 100644
index 0000000..28dc75f
--- /dev/null
+++ b/test/formatters/samplecode/biome/in.json
@@ -0,0 +1 @@
+{"arrowParens":"always","bracketSpacing":true,"embeddedLanguageFormatting":"auto","htmlWhitespaceSensitivity":"css","insertPragma":false,"jsxBracketSameLine":false,"jsxSingleQuote":false,"printWidth":80,"proseWrap":"preserve","quoteProps":"as-needed","requirePragma":false,"semi":true,"singleQuote":false,"tabWidth":2,"trailingComma":"es5","useTabs":false,"vueIndentScriptAndStyle":false}
diff --git a/test/formatters/samplecode/biome/in.ts b/test/formatters/samplecode/biome/in.ts
new file mode 100644
index 0000000..c75d40f
--- /dev/null
+++ b/test/formatters/samplecode/biome/in.ts
@@ -0,0 +1 @@
+interface GreetingSettings{greeting: string; duration?: number; color?: string;}declare function greet(setting: GreetingSettings): void;
diff --git a/test/formatters/samplecode/biome/out.css b/test/formatters/samplecode/biome/out.css
new file mode 100644
index 0000000..87717b9
--- /dev/null
+++ b/test/formatters/samplecode/biome/out.css
@@ -0,0 +1,6 @@
+body {
+ padding-left: 11em;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ color: purple;
+ background-color: #d8da3d;
+}
diff --git a/test/formatters/samplecode/biome/out.graphql b/test/formatters/samplecode/biome/out.graphql
new file mode 100644
index 0000000..89828da
--- /dev/null
+++ b/test/formatters/samplecode/biome/out.graphql
@@ -0,0 +1,6 @@
+{
+ human(id: "1000") {
+ name
+ height(unit: FOOT)
+ }
+}
diff --git a/test/formatters/samplecode/biome/out.js b/test/formatters/samplecode/biome/out.js
new file mode 100644
index 0000000..1486b51
--- /dev/null
+++ b/test/formatters/samplecode/biome/out.js
@@ -0,0 +1,10 @@
+function HelloWorld({
+ greeting = "hello",
+ greeted = '"World"',
+ silent = false,
+ onMouseOver,
+}) {
+ if (!greeting) {
+ return null;
+ }
+}
diff --git a/test/formatters/samplecode/biome/out.json b/test/formatters/samplecode/biome/out.json
new file mode 100644
index 0000000..86787f9
--- /dev/null
+++ b/test/formatters/samplecode/biome/out.json
@@ -0,0 +1,19 @@
+{
+ "arrowParens": "always",
+ "bracketSpacing": true,
+ "embeddedLanguageFormatting": "auto",
+ "htmlWhitespaceSensitivity": "css",
+ "insertPragma": false,
+ "jsxBracketSameLine": false,
+ "jsxSingleQuote": false,
+ "printWidth": 80,
+ "proseWrap": "preserve",
+ "quoteProps": "as-needed",
+ "requirePragma": false,
+ "semi": true,
+ "singleQuote": false,
+ "tabWidth": 2,
+ "trailingComma": "es5",
+ "useTabs": false,
+ "vueIndentScriptAndStyle": false
+}
diff --git a/test/formatters/samplecode/biome/out.ts b/test/formatters/samplecode/biome/out.ts
new file mode 100644
index 0000000..b97c21b
--- /dev/null
+++ b/test/formatters/samplecode/biome/out.ts
@@ -0,0 +1,6 @@
+interface GreetingSettings {
+ greeting: string;
+ duration?: number;
+ color?: string;
+}
+declare function greet(setting: GreetingSettings): void;