Skip to content
36 changes: 25 additions & 11 deletions src/content/docs/linter/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,36 @@ the following configuration:
```

The plugin will now be enabled on all supported files the linter runs on. You
can see its results when running `biome lint` or `biome check`. For example:
can see its results when running `biome lint` or `biome check`.

```shell
$ biome lint
/packages/tailwindcss-config-analyzer/src/introspect.ts:12:17 plugin ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
## Restricting Plugins to Specific Files

✖ Prefer object spread instead of `Object.assign()`
By default, a plugin runs on every file the linter processes. If a plugin only
applies to certain files, you can restrict it using `includes` glob patterns.
Use negated globs (prefixed with `!`) for exclusions.

10 │ function createContextFromConfig(config: Partial<Config>) {
11 │ return createContext(
> 12 │ resolveConfig(Object.assign({}, DEFAULT_CONFIG, config)),
│ ^^^^^^^^^^^^^
13 │ );
14 │ }
In the following example, the first plugin only runs on files inside
`src/components/`. The second plugin runs on all files that have the extension `.ts` under `src/` folder, except for files that end with `.test.ts` in the `src/` folder:

```json name="biome.json"
{
"plugins": [
{
"path": "./react-plugin.grit",
"includes": ["src/components/**"]
},
{
"path": "./ts-only-plugin.grit",
"includes": ["src/**/*.ts", "!src/**/*.test.ts"]
}
]
}
```

When `includes` is set, the plugin only runs on files that match at least one
positive pattern and are not excluded by a negated pattern. Patterns follow the
[glob syntax reference](/reference/configuration/#glob-syntax-reference).

## Target Languages

A GritQL snippet always attempts to match against a given _target language_.
Expand Down
42 changes: 42 additions & 0 deletions src/content/docs/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,48 @@ This is required so Biome can orchestrate multiple files in CLI and editors at t

> Default: `true`

## `plugins`

A list of [GritQL plugins](/linter/plugins/) to enable. Each entry can be
either a simple path string or an object with a path and optional file-filtering
options.

Simple path:

```json title="biome.json"
{
"plugins": ["./my-plugin.grit"]
}
```

Restricting to specific files:

```json title="biome.json"
{
"plugins": [
{
"path": "./react-plugin.grit",
"includes": ["src/components/**", "!src/components/generated/**"]
}
]
}
```

You can mix both forms in the same list.

### `plugins.<ITEM>.path`

**Required.**

Path to the plugin file (`.grit`) or plugin directory containing a
`biome-manifest.jsonc`.

### `plugins.<ITEM>.includes`

A list of [glob patterns](#glob-syntax-reference) for files the plugin should
run on. Use negated globs (prefixed with `!`) for exclusions.

When omitted, the plugin runs on every file the linter processes. If `includes` is empty `[]`, the plugin doesn't run on any file.

## `files`

Expand Down