Перейти до вмісту

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.

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:

biome.json
{
"$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.

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:

  1. biome.json
  2. biome.jsonc
  3. .biome.json
  4. .biome.jsonc

Biome looks for the configuration file in the following places, in this order:

  1. 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.
  2. Parent folders, recursively.
  3. The home directory, which depends on your operating system:
    • $XDG_CONFIG_HOME or $HOME/.config/biome on Linux
    • /Users/$USER/Library/Application Support/biome on macOS
    • C:\Users\$USER\AppData\Roaming\biome\config on 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 file app/backend/biome.json.
  • Biome commands that run in app/frontend/legacy/ and app/frontend/new/ use the configuration file app/frontend/biome.json.

You can choose which files and folders Biome processes on the command line, in the configuration file, and through your VCS.

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/

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:

biome.json
{
"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/

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/

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.
biome.json
{
"files": {
"includes": [
"**",
"!**/*.generated.js",
"!!**/dist"
]
}
}

To learn how the scanner works, see Scanner.

You can make Biome ignore the files that your VCS ignores.

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:

biome.json
{
"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.