Configure your project
Цей контент ще не доступний вашою мовою.
Biome works without configuration, but most projects add a biome.json file to adjust the defaults and share them with the team. This page explains how the file is structured, how Biome finds it, and how to choose which files it processes. For every option, see the configuration reference.
Configuration file structure
Section titled “Configuration file structure”Because Biome is a toolchain, its configuration is organized around the tools it provides: the formatter, the linter, and the assist. All of them are enabled by default. To disable one or more of them, set the <tool>.enabled field to false:
{ "$schema": "https://biomejs.dev/schemas/2.6.10/schema.json", "formatter": { "enabled": false }, "linter": { "enabled": false }, "assist": { "enabled": false }}Options that apply to every language go under the tool, such as formatter.lineWidth. Options for a single language go under that language, such as javascript.formatter.quoteStyle.
A language can also override the general options of a tool, or turn the tool off for its files, such as with json.formatter.enabled. See Configure the formatter for an example.
How Biome finds the configuration file
Section titled “How Biome finds the configuration file”The configuration file usually sits in your project’s root folder, next to your project’s package.json.
Biome supports the following configuration files, in this order:
biome.jsonbiome.jsonc.biome.json.biome.jsonc
Biome looks for the configuration file in the following places, in this order:
- The current working directory:
- From the CLI, the working directory is where you run the command.
- From the editor, the working directory is the root of the project.
- Parent folders, recursively.
- The home directory, which depends on your operating system:
$XDG_CONFIG_HOMEor$HOME/.config/biomeon Linux/Users/$USER/Library/Application Support/biomeon macOSC:\Users\$USER\AppData\Roaming\biome\configon Windows
If Biome finds no configuration file, it uses its default configuration.
For example, take the following project:
Каталогapp/
Каталогbackend/
- biome.json
- package.json
Каталогfrontend/
Каталогlegacy/
- package.json
Каталогnew/
- package.json
- biome.json
- Biome commands that run in
app/backend/use the configuration fileapp/backend/biome.json. - Biome commands that run in
app/frontend/legacy/andapp/frontend/new/use the configuration fileapp/frontend/biome.json.
Choose which files Biome processes
Section titled “Choose which files Biome processes”You can choose which files and folders Biome processes on the command line, in the configuration file, and through your VCS.
Pass files on the command line
Section titled “Pass files on the command line”List the files and folders you want Biome to process in the command. Biome traverses folders recursively, so the following command formats file1.js and all the files in the src folder:
npx biome format file1.js src/pnpm biome format file1.js src/bunx biome format file1.js src/deno run -A npm:@biomejs/biome format file1.js src/yarn biome format file1.js src/biome format file1.js src/Include files via configuration
Section titled “Include files via configuration”To choose which files Biome processes, list them in the files.includes field. files.includes accepts glob patterns such as src/**/*.js. Negated patterns, which start with !, exclude files.
Paths and globs inside Biome’s configuration file are resolved from the directory containing that file. When another configuration file extends it, they are resolved from the directory containing the extending configuration instead.
Plugins can opt out of this rule. See Load a plugin from a shared configuration.
files.includes applies to all of Biome’s tools: the linter, the formatter, and the assist process the files it matches, unless you configure them otherwise. To refine the matching files for a single tool, use <tool>.includes.
The following configuration includes only the JavaScript files (.js) inside the src/ and test/ folders, ignores the files that have .min.js in their name, and excludes the test/ folder from the linter:
{ "files": { "includes": ["src/**/*.js", "test/**/*.js", "!**/*.min.js"] }, "linter": { "includes": ["**", "!test/**"] }}The following command formats the files in the test/ folder that end with .js and do not end with .min.js:
npx biome format test/pnpm biome format test/bunx biome format test/deno run -A npm:@biomejs/biome format test/yarn biome format test/biome format test/The files in src/ are not formatted, because the command does not list that folder.
The following command lints no files, because the configuration excludes the test/ folder from the linter:
npx biome lint test/pnpm biome lint test/bunx biome lint test/deno run -A npm:@biomejs/biome lint test/yarn biome lint test/biome lint test/Exclude files via configuration
Section titled “Exclude files via configuration”To exclude files and folders, add negated patterns to files.includes:
- A pattern with a leading
!excludes files from linting and formatting. - A pattern with a leading
!!excludes files from any project-related operation.
Project-related operations are:
- Building the internal module graph, so that some project rules can resolve information from imports and exports.
- Inferring types, so that type-aware lint rules can infer types correctly.
A file that Biome considers for project-related operations is indexed.
The negated globs must come after the ** pattern.
The following configuration includes all files, except:
- The
dist/folder, which Biome ignores for any project-related operation, so its files are not indexed. - Files that end with
.generated.js, which Biome does not format or lint, but still indexes.
{ "files": { "includes": [ "**", "!**/*.generated.js", "!!**/dist" ] }}To learn how the scanner works, see Scanner.
Ignore the files your VCS ignores
Section titled “Ignore the files your VCS ignores”You can make Biome ignore the files that your VCS ignores.
Use different settings for some files
Section titled “Use different settings for some files”To change options for only some files, add an entry to overrides. Select the files with includes, then set only the options that change for them.
The following configuration uses a line width of 120 and single quotes for the files in the scripts/ folder:
{ "overrides": [ { "includes": ["scripts/**"], "formatter": { "lineWidth": 120 }, "javascript": { "formatter": { "quoteStyle": "single" } } } ]}When several entries match a file and set the same option, the last one takes precedence.
© 2023-present Biome developers and contributors.