How Biome works
This is a guide that explains how the tool works, assumptions, and internal information useful when setting up the project and the configuration file.
ConfigurationSection titled Configuration
The configuration file is considered optional, Biome has good defaults. Use the configuration file to change those defaults.
The Biome configuration file is named
biome.json and should be placed in the root directory of your project. The root
directory is usually the directory containing your project’s
1.6.0, Biome accepts also the file
This configuration file enables the formatter and sets the preferred indent style and width. The linter is disabled:
Default configurationSection titled Default configuration
When you run
biome init, the default configuration emitted is the following:
Configuration file resolutionSection titled Configuration file resolution
Biome uses auto discovery to find the nearest
biome.json file. It starts looking for
biome.json in the current
working directory, and then it starts looking in the parent directories until:
- it finds a
- it applies Biome’s defaults if no
Here’s an example:
- biome commands that run in
app/backend/package.jsonwill use the configuration file
- biome commands that run in
app/frontend/new/package.jsonwill use the configuration file
The Section titled The extends option
extends option allows to break down a configuration in multiple file and “share” common patterns among multiple projects/folders.
The files defined in this array:
- must exist in the file system;
- are resolved from the path where the
biome.jsonfile is defined;
- must be relative paths. Paths to libraries are not resolved;
- must be reachable by Biome, e.g. symbolic links might not be resolved by Biome;
- will be processed in order: from the first one to the last one;
- can override the same properties, but ultimately only the last one will be used by Biome;
Import Section titled Import biome.json from a library
biome.json from a library
v1.6.0, Biome is able to resolve configuration files from
node_modules/, so you can export your configuration file from a library, 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 your library is called
@org/shared-configs, and you want to import the Biome configuration using the specifier
@org/shared-configs/biome. You have to set up the
package.json is a specific way:
Make sure that
@org/shared-configs is correctly installed in your project, and update the
biome.json file to look like the following snippet:
Biome will attempt to resolve your library
@org/shared-configs/ from your working directory. The working directory is:
- when using the CLI, the directory where you execute your scripts from. Usually it matches the location of your
- when using the LSP, the root directory of your project.
For more information about the resolution algorithm, read the Node.js documentation.
Protected FilesSection titled Protected Files
The following files are currently ignored by Biome. This means that no diagnostics will be ever emitted by Biome for those files.
The following files are parsed as
JSON files with the options
json.parser.allowTrailingCommas set to
true. This is because editor tools like VSCode treat them like this.
Section titled include and ignore explained
Biome will resolve the globs specified in
ignore relatively from the working directory.
The working directory is the directory where you usually run a CLI command. This means that you have to place particular attention when the configuration file is placed in a different directory from where you execute your command.
For example, you have a project that contains two directories called
and decide to place your
biome.json at the root folder of the project.
frontend/ project, you have your
package.json with some scripts that run Biome:
When you run the script
the working directory resolved by that script will be
src/**/*.ts will have as “base” directory
Glob syntax explainedSection titled Glob syntax explained
The syntax and meaning of these two options loosely follow the globset rules but without the ability to set options.
*matches zero or more characters.
**recursively matches directories but are only legal in three situations. First, if the glob starts with
**/, then it matches all directories. For example,
foo/bar. Secondly, if the glob ends with
/**, then it matches all sub-entries. For example,
foo/a/b, but not
foo. Thirdly, if the glob contains
/**/anywhere within the pattern, then it matches zero or more directories. Using
**anywhere else is illegal (N.B. the glob
**is allowed and means “match everything”).
Metacharacters such as
?can be escaped with character class notation. e.g.,
Check the wikipedia page for more information.