Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add biome formatter #339

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Comment on lines -1180 to +1181
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted the indentation in this line to be consistent with the whole file. I can revert it if undesired.

(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;
Loading