Skip to content

Commit c0c3f02

Browse files
Switch from prettier to Biome (#304)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c94a15f commit c0c3f02

11 files changed

+49
-34
lines changed

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
repos:
22
# Hooks that are run everywhere
3-
- repo: https://github.com/pre-commit/mirrors-prettier
4-
rev: v4.0.0-alpha.8 # Only update together with the pre-commit yaml in the tempalate!
3+
- repo: https://github.com/biomejs/pre-commit
4+
rev: v1.9.4
55
hooks:
6-
- id: prettier
6+
- id: biome-format
77
# Hooks that are run for scripts
88
- repo: https://github.com/tox-dev/pyproject-fmt
99
rev: v2.5.0

.prettierignore

-2
This file was deleted.

.prettierrc.yaml

-7
This file was deleted.

biome.jsonc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"formatter": { "useEditorconfig": true },
4+
"overrides": [
5+
{
6+
"include": ["**/*.vscode*/*.json", "**/*.jsonc"],
7+
"json": {
8+
"formatter": { "trailingCommas": "all" },
9+
"parser": {
10+
"allowComments": true,
11+
"allowTrailingCommas": true,
12+
},
13+
},
14+
},
15+
],
16+
}

{{cookiecutter.project_name}}/.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ default_stages:
66
- pre-push
77
minimum_pre_commit_version: 2.16.0
88
repos:
9-
- repo: https://github.com/pre-commit/mirrors-prettier
10-
rev: v4.0.0-alpha.8
9+
- repo: https://github.com/biomejs/pre-commit
10+
rev: v1.9.4
1111
hooks:
12-
- id: prettier
12+
- id: biome-format
1313
- repo: https://github.com/tox-dev/pyproject-fmt
1414
rev: v2.5.0
1515
hooks:
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"formatter": { "useEditorconfig": true },
4+
"overrides": [
5+
{
6+
"include": ["./.vscode/*.json", "**/*.jsonc"],
7+
"json": {
8+
"formatter": { "trailingCommas": "all" },
9+
"parser": {
10+
"allowComments": true,
11+
"allowTrailingCommas": true,
12+
},
13+
},
14+
},
15+
],
16+
}

{{cookiecutter.project_name}}/docs/contributing.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ to integrate the changes into yours.
7070
While the [pre-commit.ci][] is useful, we strongly encourage installing and running pre-commit locally first to understand its usage.
7171

7272
Finally, most editors have an _autoformat on save_ feature.
73-
Consider enabling this option for [ruff][ruff-editors] and [prettier][prettier-editors].
73+
Consider enabling this option for [ruff][ruff-editors] and [biome][biome-editors].
7474

7575
[pre-commit]: https://pre-commit.com/
7676
[pre-commit.ci]: https://pre-commit.ci/
7777
[ruff-editors]: https://docs.astral.sh/ruff/integrations/
78-
79-
[prettier-editors]: https://prettier.io/docs/en/editors.html
78+
[biome-editors]: https://biomejs.dev/guides/integrate-in-editor/
8079

8180
(writing-tests)=
8281

{{cookiecutter.project_name}}/docs/template_usage.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ You'll notice that the command `git commit` installed a bunch of packages and tr
5353
To read more about what they are and what they do, you can go to the related section [Pre-commit checks](#pre-commit-checks) in this document.
5454

5555
:::{note}
56-
There is a chance that `git commit -m "first commit"` fails due to the `prettier` pre-commit formatting the file `.cruft.json`.
56+
There is a chance that `git commit -m "first commit"` fails due to the `biome` pre-commit formatting of the file `.cruft.json`.
5757
No problem, you have just experienced what pre-commit checks do in action. Just go ahead and re-add the modified file and try to commit again:
5858

5959
```bash
@@ -260,8 +260,8 @@ Once authorized, pre-commit.ci should automatically be activated.
260260

261261
The following pre-commit hooks are for code style and format:
262262

263-
- [prettier](https://prettier.io/docs/en/index.html):
264-
standard code formatter for non-Python files (e.g. YAML).
263+
- [biome](https://biomejs.dev/):
264+
code formatter for non-Python files (e.g. JSON).
265265
- [ruff][] formatting (`ruff-format`)
266266
- [ruff][] based checks:
267267
- [isort](https://beta.ruff.rs/docs/rules/#isort-i) (rule category: `I`):
@@ -308,8 +308,8 @@ This section shows you where these checks are defined, and how to enable/ disabl
308308
##### pre-commit
309309
310310
You can add or remove pre-commit checks by simply deleting relevant lines in the `.pre-commit-config.yaml` file under the repository root.
311-
Some pre-commit checks have additional options that can be specified either in the `pyproject.toml` (for `ruff`) or tool-specific config files,
312-
such as `.prettierrc.yml` for **prettier**.
311+
Some pre-commit checks have additional options that can be specified either in the `pyproject.toml` (for [ruff][]) or tool-specific config files,
312+
such as `biome.jsonc` for [biome][].
313313
314314
##### Ruff
315315

{{cookiecutter.project_name}}/{% if cookiecutter.ide_integration %}.prettierrc.yaml{% endif %}

-7
This file was deleted.

{{cookiecutter.project_name}}/{{".vscode" if cookiecutter.ide_integration else "DELETE-ME" }}/extensions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
// Linting and formatting
1414
"editorconfig.editorconfig",
1515
"charliermarsh.ruff",
16-
"esbenp.prettier-vscode",
16+
"biomejs.biome",
1717
],
1818
}

{{cookiecutter.project_name}}/{{".vscode" if cookiecutter.ide_integration else "DELETE-ME" }}/settings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"[python][jsonc][yaml]": {
2+
"[python][json][jsonc]": {
33
"editor.formatOnSave": true,
44
},
55
"[python]": {
@@ -9,8 +9,8 @@
99
"source.organizeImports": "always",
1010
},
1111
},
12-
"[jsonc][yaml]": {
13-
"editor.defaultFormatter": "esbenp.prettier-vscode",
12+
"[json][jsonc]": {
13+
"editor.defaultFormatter": "biomejs.biome",
1414
},
1515
"python.analysis.typeCheckingMode": "basic",
1616
"python.testing.pytestEnabled": true,

0 commit comments

Comments
 (0)