Support Biome as formatter #23347
Replies: 16 comments 3 replies
-
How to use biome in nx monorepo? |
Beta Was this translation helpful? Give feedback.
-
@vaibhavdugar, I have a repo for this https://github.com/guillempuche/nx-expo-next-tamagui/blob/main/biome.json I still need to run lint for all the files (as @JamesHenry pointed guillempuche/nx-expo-next-tamagui#1), but when coding a file on VSCode, it works. |
Beta Was this translation helpful? Give feedback.
-
@guillempuche in your repo as well biome is not configured with nx, I see that you are also using ESLint with nx, do you have any idea how can we use biome instead of ESLint in nx.json? |
Beta Was this translation helpful? Give feedback.
-
There aren't Eslint nor Prettier dependencies in the root package.json. It's all Biome. I don't use Nx target lint (I should delete this). Instead, you can format the code via the script in package.json. There's also a pre-commit Husky script. |
Beta Was this translation helpful? Give feedback.
-
Thanks, can you tell me how to run the biome command for linting to catch all the errors? |
Beta Was this translation helpful? Give feedback.
-
Two ways: a) |
Beta Was this translation helpful? Give feedback.
-
We just updated our lint target as follows:
|
Beta Was this translation helpful? Give feedback.
-
We use https://nx.dev/features/enforce-module-boundaries. I guess we'll wait until nx officially supports biome. |
Beta Was this translation helpful? Give feedback.
-
Biome has also a issue about monorepos: biomejs/biome#2228 aiming to support a root configuration that is extendable per project. |
Beta Was this translation helpful? Give feedback.
-
Hello friends, I am working on this project https://github.com/GitOpsLovers/nx-biome to create a plugin to implement Biome as linter, executor and generator in NX. Who wants to participate is welcome! |
Beta Was this translation helpful? Give feedback.
-
@mcfdez , how does it support child |
Beta Was this translation helpful? Give feedback.
-
The idea is that the plugin configuration generator will create a biome.json in the project that you tell it and also creates a biome.json in the workspace root. In the biome.js of the project, an extend will be made. |
Beta Was this translation helpful? Give feedback.
-
I've converted this to a discussion so it's easier to discuss. |
Beta Was this translation helpful? Give feedback.
-
For performance reasons we are also thinking of migrating away from eslint + prettier and use biome instead. The only thing that concerns us is that there is no biome ruleset equivalent for the For the time being, a possible solution is to have eslint enabled specifically for this plugin, so that we can still stop users from accidental cross module imports + run everything else with biome. Does anybody have any luck with this so far? And if this practice is recommended? |
Beta Was this translation helpful? Give feedback.
-
I haven't had the need for project specific configuration files with Biome yet, but running it during CI and pre-commit hooks works great: CI Where Pre-commit hook script #!/bin/sh
set -eu
if git status --short | grep --quiet '^MM'; then
printf '%s\n' "ERROR: Some staged files have unstaged changes" >&2
exit 1;
fi
git diff -z --staged --name-only --diff-filter=ACMR | \
xargs -0 pnpm biome check --apply --no-errors-on-unmatched
git update-index --again One outstanding issue/pain-point I've had when using NX + Biome is that many generators will install ESLint all over again (without an option to disable it). Slightly annoying having to remove files and ESLint related packages from |
Beta Was this translation helpful? Give feedback.
-
Is there any official plan to support? |
Beta Was this translation helpful? Give feedback.
-
Description
Biome (previously Rome) made some news by reaching 97% compatibility with Prettier.
A lot of rules from major plugins are already supported.
Motivation
It would be beneficial performance-wise.
And by making the formatter plugable it would make nx even more future-proof.
Suggested Implementation
official biome support with:
Alternate Implementations
Beta Was this translation helpful? Give feedback.
All reactions