Share Biome config across a monorepo
Use Biome 2 nested configs to inherit the root settings and override individual lint or formatter rules for each package.
You run biome check at the root of a monorepo, and the logger package needs to allow console, and you want to skip formatting generated code. Copying the root biome.json into each package works until someone changes the line width in one copy and forgets the others.
Extend the root from each package
Start with a root biome.json and add a nested config in each package that needs different settings. Copy each object below into the file named in its comment. A nested file inherits the root's settings with "extends": "//", where // means the project root at any depth, and then overrides only what differs. The big projects guide describes the setup.
// biome.json (repo root)
{
"linter": {
"rules": { "suspicious": { "noConsole": "error" } }
},
"formatter": { "indentStyle": "space", "lineWidth": 100 },
"javascript": { "formatter": { "semicolons": "asNeeded" } }
}
// packages/logger/biome.json
{
"root": false,
"extends": "//",
"linter": {
"rules": { "suspicious": { "noConsole": "off" } }
}
}
// packages/generated/biome.json
{
"extends": "//",
"formatter": { "enabled": false }
}The logger keeps the root's formatting and turns one rule off. The generated folder keeps the root's lint rules and skips the formatter.
Biome applies the nested file last, so a value it sets wins over the root's. The generated config omits "root": false because Biome infers it from "extends": "//".
One run from the root
With @biomejs/biome installed, format the three config files. Put console.log("root") in main.ts and console.log("logger") in packages/logger/src/index.ts. Put export const table={id:1} in packages/generated/table.ts, then run the check from the root.
pnpm exec biome check .Biome reports lint/suspicious/noConsole in main.ts. The logger's console.log passes, table.ts keeps its spacing, and the logger file has no semicolons and still passes because it inherited "asNeeded".
Running pnpm exec biome check . inside packages/logger gives the same result for that package. Biome walks up from the nested file to the root, so a package script and a root script agree.
When the nested file is wrong
A nested biome.json with neither "root": false nor "extends": "//" stops the whole run:
packages/logger/biome.json configuration ━━━━━━━━━━
× Found a nested root configuration, but there's already a root configuration.
× Biome exited because the configuration resulted in errors. Please fix them.Add "extends": "//", or "root": false if the package should not inherit.
The quieter mistake is "root": false without extends. Biome accepts it and uses its defaults for that package. The logger file then needs semicolons under Biome’s default formatter settings. Leave extends out only for a package that owns its whole style, and set its formatter options in its own file.