Skip to content

Commit fc6384d

Browse files
YashVardhan2496YashVardhan2496mortenpi
authored
Add Biome formatter support for JavaScript files (#2913)
* Replace Prettier with Biome: update Makefile, CI, config and docs Remove Prettier reference from AGENTS.md * build: edit biome config, a few cleanups --------- Co-authored-by: YashVardhan2496 <23bch048@nith.ac.in> Co-authored-by: Morten Piibeleht <morten.piibeleht@juliahub.com>
1 parent 1af80b8 commit fc6384d

File tree

5 files changed

+43
-7
lines changed

5 files changed

+43
-7
lines changed

.github/workflows/CI.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,16 @@ jobs:
307307
env:
308308
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
309309

310-
prettier:
311-
name: Prettier (JS code formatting)
310+
biome:
311+
name: Biome (JS code formatting)
312312
runs-on: ubuntu-latest
313313
steps:
314314
- uses: actions/checkout@v6
315-
- uses: actionsx/prettier@v3
315+
- uses: julia-actions/setup-julia@v2
316316
with:
317-
args: --check .
317+
version: '1'
318+
- run: make install-biome
319+
- run: make format-js
318320

319321
runic:
320322
name: "Runic (Julia code formatting)"

AGENTS.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ generic defaults:
1414

1515
* for Julia code, use the Runic-based workflow described there
1616
(for example `make format-julia`);
17-
* for JS, HTML, and (S)CSS, follow the Prettier guidance described there;
1817
* for Markdown, follow the Markdown conventions described there and do not
1918
introduce hard-wrapping or ad hoc list formatting.
2019

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
JULIA:=julia
22
RUNIC:=@runic
3+
BIOME:=@biome
34

45
default: help
56

@@ -29,6 +30,12 @@ format-julia:
2930
install-runic:
3031
julia --project=$(RUNIC) -e 'using Pkg; Pkg.add("Runic")'
3132

33+
format-js:
34+
julia --project=$(BIOME) -e 'using biome_jll; run(`$$(biome_jll.biome()) check --write`)'
35+
36+
install-biome:
37+
julia --project=$(BIOME) -e 'using Pkg; Pkg.add(; name="biome_jll", version="2.4.8")'
38+
3239
test:
3340
${JULIA} --project -e 'using Pkg; Pkg.test()'
3441

@@ -66,9 +73,11 @@ help:
6673
@echo " - make docs-instantiate: instantiate the docs/ Julia environment"
6774
@echo " - make format-julia: formats the Julia source code with Runic"
6875
@echo " - make install-runic: installs Runic.jl into the @runic shared Julia environment (for make format)"
76+
@echo " - make format-js: formats the JS source code with Biome"
77+
@echo " - make install-biome: installs biome_jll into the @biome shared Julia environment"
6978
@echo " - make test: run the tests"
7079
@echo " - make search-benchmarks: run search functionality benchmarks"
7180
@echo " - make themes: compile Documenter's native CSS themes"
7281
@echo " - make clean: remove generated files"
7382

74-
.PHONY: default docs-instantiate themes help changelog docs test format-julia install-runic search-benchmarks
83+
.PHONY: default docs-instantiate themes help changelog docs test format-julia install-runic format-js install-biome search-benchmarks

biome.jsonc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
// The biome JLL runs into:
3+
// > The configuration schema version does not match the CLI version 0.0.1
4+
// "$schema": "https://biomejs.dev/schemas/2.4.8/schema.json",
5+
"vcs": {
6+
"enabled": true,
7+
"clientKind": "git",
8+
"useIgnoreFile": true
9+
},
10+
"files": {
11+
"ignoreUnknown": false,
12+
"includes": [
13+
"biome.jsonc",
14+
"assets/html/**",
15+
"!!assets/html/themes",
16+
"!!assets/html/scss/highlightjs"
17+
]
18+
},
19+
"formatter": {
20+
"enabled": true,
21+
"indentStyle": "space"
22+
},
23+
"linter": {
24+
"enabled": false
25+
}
26+
}

docs/src/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ If the formatter fails to run because it can not load Runic, you can install it
5151

5252
### JS, HTML and (S)CSS
5353

54-
We use [Prettier](https://github.com/prettier/prettier) v2 for formatting the HTML/web front end related code.
54+
We use [Biome](https://biomejs.dev) for formatting the JavaScript source code. You can run it with `make format-js` (install with `make install-biome`).
5555

5656
### Markdown
5757

0 commit comments

Comments
 (0)