Configure Biome
This guide will help you to understand how to configure Biome. It explains the structure of a Biome configuration file and how Biome resolves its configuration. If you are already familiar with the configuration, you may want to take a look at the configuration reference, which details all the options available.
Biome allows you to customize its behavior using CLI options or a configuration file named biome.json
or biome.jsonc
.
We recommend that you create a configuration file for each project.
This ensures that each team member has the same configuration in the CLI and in any editor that allows Biome integration.
Many of the options available in a configuration file are also available in the CLI.
Configuration file structure
Section titled Configuration file structureA Biome configuration file is named biome.json
or biome.jsonc
. It is usually
placed in your project’s root folder, next to your project’s package.json
.
Because Biome is a toolchain, its configuration is organized around the tools it
provides. At the moment, Biome provides three tools: the formatter, the linter
and the assist. All of these tools are enabled by default. You can disable one
or several of them using the <tool>.enabled
field:
{ "$schema": "https://biomejs.dev/schemas/2.0.0-beta/schema.json", "formatter": { "enabled": false }, "linter": { "enabled": false }, "assist": { "enabled": false }}
Options that apply to more than one language are placed in the corresponding tool field.
Language-specific options of a tool are placed under a <language>.<tool>
field.
This also allows overriding general options for a given language.
You can also enable or disable a tool based on the language.
In the following example, we configure the general options formatter.indentStyle
and formatter.lineWidth
for all the languages.
Also, we set the JavaScript-specific option quoteStyle
in javascript.formatter
and we override formatter.lineWidth
.
We disabled the formatter for JSON files.
{ "formatter": { "indentStyle": "space", // default is `tab` "lineWidth": 100 // default is `80` }, "javascript": { "formatter": { "quoteStyle": "single", // default is `double` "lineWidth": 120 // override `formatter.lineWidth` } }, "json": { "formatter": { "enabled": false } }}
Configuration file resolution
Section titled Configuration file resolutionBiome uses auto discovery to find the nearest configuration file. It looks in
the working directory and its parent folders until it finds a biome.json
or a
biome.jsonc
file. If no configuration is found, Biome’s default configuration
is used. If both biome.json
and biome.jsonc
are present in the same folder,
biome.json
is used.
Here’s an example:
Directoryapp/
Directorybackend/
- biome.json
- package.json
Directoryfrontend/
Directorylegacy/
- package.json
Directorynew/
- package.json
- biome.json
- Biome commands that run in
app/backend/package.json
will use the configuration fileapp/backend/biome.json
; - Biome commands that run in
app/frontend/legacy/package.json
andapp/frontend/new/package.json
will use the configuration fileapp/frontend/biome.json
;
Specifying files to process
Section titled Specifying files to processThe first way to control which files and folders are processed by Biome is to
list them in the CLI. In the following command, we only format file1.js
and
all the files in the src
folder, because folders are recursively traversed.
biome format file1.js src/
The Biome configuration file can be used to refine which files are processed.
You can explicitly list the files to be processed using
the files.includes
field. files.includes
accepts
glob patterns such as
src/**/*.js
. Negated patterns starting with !
can be used to exclude files.
Paths and globs inside Biome’s configuration file are resolved relative to the folder the configuration file is in. An exception to this is when a configuration file is extended by another.
files.includes
applies to all of Biome’s tools, meaning the files specified
here are processed by the linter, the formatter and the assist, unless specified
otherwise. For the individual tools, you can further refine the matching files
using <tool>.includes
.
Let’s take the following configuration:
{ "files": { "includes": ["src/**/*.js", "test/**/*.js", "!**/*.min.js"], }, "linter": { "includes": ["!test/**"] }}
And run the following command:
biome format test/
The command will format the files that end with the .js
extension and don’t
end with the .min.js
extension from the test/
folder.
The files in src/
are not formatted because the folder is not listed in the
CLI.
If we run the following command, no files are linted because files inside the
test/
folder are explicitly ignored for the linter.
biome lint test/
Well-known files
Section titled Well-known filesHere are some well-known files that we specifically treat based on their file names, rather than their extensions. Currently, the well-known files are JSON-like files only, but we may broaden the list to include other types when we support new parsers.
The following files are parsed as JSON
files with both the options json.parser.allowComments
and json.parser.allowTrailingCommas
set to false
.
.all-contributorsrc
.arcconfig
.auto-changelog
.bowerrc
.c8rc
.htmlhintrc
.imgbotconfig
.jslintrc
.nycrc
.tern-config
.tern-project
.vuerc
.watchmanconfig
mcmod.info
The following files are parsed as JSON
files with the options json.parser.allowComments
set to true
but json.parser.allowTrailingCommas
set to false
. This is because the tools consuming these files can only strip comments.
.ember-cli
.eslintrc.json
.jscsrc
.jshintrc
tslint.json
turbo.json
The following files are parsed as JSON
files with the options json.parser.allowComments
and json.parser.allowTrailingCommas
set to true
. This is because the tools consuming these files are designed to accommodate such settings.
.babelrc
.babelrc.json
.devcontainer.json
.hintrc
.hintrc.json
.swcrc
api-documenter.json
api-extractor.json
babel.config.json
deno.json
devcontainer.json
dprint.json
jsconfig.json
jsr.json
language-configuration.json
tsconfig.json
typedoc.json
typescript.json
Sharing a configuration file
Section titled Sharing a configuration fileThe extends
field allows you to split your configuration across multiple
files. This way, you can share common settings across different projects or
folders.
Here’s an example of how you might set up your configuration to extend a
common.json
configuration file:
{ "extends": ["./common.json"]}
The entries defined in extends
are resolved from the path where the
biome.json
file is defined. They are processed in the order they are listed,
with settings in later files overriding earlier ones.
Files that you extend
from cannot extend
other files in turn.
Note that paths in a configuration file are always resolved from the folder in
which the biome.json
/biome.jsonc
file resides. When using the extends
field, this means that paths in a shared configuration are interpreted from the
location of the configuration that is extending it, and not from the folder
of the file being extended.
For example, let’s assume a project that contains two directories backend/
and
frontend/
, each having their own biome.json
that both extend a common.json
configuration in the root folder:
Directorybackend/
Directorysrc/
- …
Directorytest/
- …
- biome.json
Directoryfrontend/
Directorysrc/
- …
Directorytest/
- …
- biome.json
- common.json
{ "files": { "includes": ["src/**/*.js", "test/**/*.js"], }, "linter": { "includes": ["!test/**"] }}
{ "extends": ["../common.json"]}
- When running Biome from the
frontend/
folder, it will be configured to format and lint all JavaScript files in thefrontend/src/
andfrontend/test/
folders, and only format the files in thefrontend/src/
folder. This works because the paths specified incommon.json
are interpreted from thefrontend/
folder, because that’s where thebiome.json
file resides. - Assuming
backend/biome.json
looks the same asfrontend/biome.json
, it will have the same behaviour, except the paths will be interpreted from thebackend/
folder.
Exporting a Biome configuration from an NPM package
Section titled Exporting a Biome configuration from an NPM packageBiome is able to resolve configuration files from the node_modules/
folder.
So you can export your configuration file from a package, and import it in
multiple projects.
In order to do so, the first thing to do is to set up your “shared” Biome
configuration in a certain way. Let’s suppose that you want to share a
configuration from a package called @org/shared-configs
, using the specifier
@org/shared-configs/biome
. You have to create an exports
entry in the
package.json
of this package:
{ "name": "@org/shared-configs", "type": "module", "exports": { "./biome": "./biome.json" }}
Make sure that @org/shared-configs
is correctly installed in your project, and
update the biome.json
file to look like the following snippet:
{ "extends": ["@org/shared-configs/biome"]}
Biome will attempt to resolve your library @org/shared-configs/
from your
working directory. The working directory is:
- when using the CLI, the folder where you execute your scripts from.
Usually it matches the location of your
package.json
file; - when using the LSP, the root folder of your project.
For more information about the resolution algorithm, refer to the Node.js documentation.