Skip to content

Commit

Permalink
feat: add biome formatter (#339)
Browse files Browse the repository at this point in the history
See https://biomejs.dev/

Alternative formatter to `prettier`

closes #323
  • Loading branch information
danielpza authored Jan 18, 2025
1 parent 30b19fa commit fa50cb3
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions test/formatters/installers/biome.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm install -g @biomejs/biome
13 changes: 13 additions & 0 deletions test/formatters/samplecode/biome/in.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
body

{
padding-left : 11em;
font-family
: Georgia,

"Times New Roman",
Times, serif;
color: purple;
background-color:
#d8da3d
}
1 change: 1 addition & 0 deletions test/formatters/samplecode/biome/in.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{human(id: "1000") {name height(unit: FOOT)}}
4 changes: 4 additions & 0 deletions test/formatters/samplecode/biome/in.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function HelloWorld({greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) {

if(!greeting){return null};
}
1 change: 1 addition & 0 deletions test/formatters/samplecode/biome/in.json
Original file line number Diff line number Diff line change
@@ -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}
1 change: 1 addition & 0 deletions test/formatters/samplecode/biome/in.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
interface GreetingSettings{greeting: string; duration?: number; color?: string;}declare function greet(setting: GreetingSettings): void;
6 changes: 6 additions & 0 deletions test/formatters/samplecode/biome/out.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
body {
padding-left: 11em;
font-family: Georgia, "Times New Roman", Times, serif;
color: purple;
background-color: #d8da3d;
}
6 changes: 6 additions & 0 deletions test/formatters/samplecode/biome/out.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
human(id: "1000") {
name
height(unit: FOOT)
}
}
10 changes: 10 additions & 0 deletions test/formatters/samplecode/biome/out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function HelloWorld({
greeting = "hello",
greeted = '"World"',
silent = false,
onMouseOver,
}) {
if (!greeting) {
return null;
}
}
19 changes: 19 additions & 0 deletions test/formatters/samplecode/biome/out.json
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 6 additions & 0 deletions test/formatters/samplecode/biome/out.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface GreetingSettings {
greeting: string;
duration?: number;
color?: string;
}
declare function greet(setting: GreetingSettings): void;

0 comments on commit fa50cb3

Please sign in to comment.