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

Switch from prettier to Biome #304

Merged
merged 17 commits into from
Feb 25, 2025
Merged
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: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
repos:
# Hooks that are run everywhere
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8 # Only update together with the pre-commit yaml in the tempalate!
- repo: https://github.com/biomejs/pre-commit
rev: v1.9.4
hooks:
- id: prettier
- id: biome-format
# Hooks that are run for scripts
- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.5.0
Expand Down
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"formatter": { "useEditorconfig": true },
"overrides": [
{
"include": ["**/*.vscode*/*.json", "**/*.jsonc"],
"json": {
"formatter": { "trailingCommas": "all" },
"parser": {
"allowComments": true,
"allowTrailingCommas": true,
},
},
},
],
}
6 changes: 3 additions & 3 deletions {{cookiecutter.project_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ default_stages:
- pre-push
minimum_pre_commit_version: 2.16.0
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
- repo: https://github.com/biomejs/pre-commit
rev: v1.9.4
hooks:
- id: prettier
- id: biome-format
- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.5.0
hooks:
Expand Down
16 changes: 16 additions & 0 deletions {{cookiecutter.project_name}}/biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"formatter": { "useEditorconfig": true },
"overrides": [
{
"include": ["./.vscode/*.json", "**/*.jsonc"],
"json": {
"formatter": { "trailingCommas": "all" },
"parser": {
"allowComments": true,
"allowTrailingCommas": true,
},
},
},
],
}
5 changes: 2 additions & 3 deletions {{cookiecutter.project_name}}/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,12 @@ to integrate the changes into yours.
While the [pre-commit.ci][] is useful, we strongly encourage installing and running pre-commit locally first to understand its usage.

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

[pre-commit]: https://pre-commit.com/
[pre-commit.ci]: https://pre-commit.ci/
[ruff-editors]: https://docs.astral.sh/ruff/integrations/

[prettier-editors]: https://prettier.io/docs/en/editors.html
[biome-editors]: https://biomejs.dev/guides/integrate-in-editor/

(writing-tests)=

Expand Down
10 changes: 5 additions & 5 deletions {{cookiecutter.project_name}}/docs/template_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You'll notice that the command `git commit` installed a bunch of packages and tr
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.

:::{note}
There is a chance that `git commit -m "first commit"` fails due to the `prettier` pre-commit formatting the file `.cruft.json`.
There is a chance that `git commit -m "first commit"` fails due to the `biome` pre-commit formatting of the file `.cruft.json`.
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:

```bash
Expand Down Expand Up @@ -260,8 +260,8 @@ Once authorized, pre-commit.ci should automatically be activated.

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

- [prettier](https://prettier.io/docs/en/index.html):
standard code formatter for non-Python files (e.g. YAML).
- [biome](https://biomejs.dev/):
code formatter for non-Python files (e.g. JSON).
- [ruff][] formatting (`ruff-format`)
- [ruff][] based checks:
- [isort](https://beta.ruff.rs/docs/rules/#isort-i) (rule category: `I`):
Expand Down Expand Up @@ -308,8 +308,8 @@ This section shows you where these checks are defined, and how to enable/ disabl
##### pre-commit

You can add or remove pre-commit checks by simply deleting relevant lines in the `.pre-commit-config.yaml` file under the repository root.
Some pre-commit checks have additional options that can be specified either in the `pyproject.toml` (for `ruff`) or tool-specific config files,
such as `.prettierrc.yml` for **prettier**.
Some pre-commit checks have additional options that can be specified either in the `pyproject.toml` (for [ruff][]) or tool-specific config files,
such as `biome.jsonc` for [biome][].

##### Ruff

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
// Linting and formatting
"editorconfig.editorconfig",
"charliermarsh.ruff",
"esbenp.prettier-vscode",
"biomejs.biome",
],
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"[python][jsonc][yaml]": {
"[python][json][jsonc]": {
"editor.formatOnSave": true,
},
"[python]": {
Expand All @@ -9,8 +9,8 @@
"source.organizeImports": "always",
},
},
"[jsonc][yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[json][jsonc]": {
"editor.defaultFormatter": "biomejs.biome",
},
"python.analysis.typeCheckingMode": "basic",
"python.testing.pytestEnabled": true,
Expand Down
Loading