diff --git a/src/content/docs/linter/plugins.mdx b/src/content/docs/linter/plugins.mdx index 909c66c00..8878a41df 100644 --- a/src/content/docs/linter/plugins.mdx +++ b/src/content/docs/linter/plugins.mdx @@ -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) { - 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_. diff --git a/src/content/docs/reference/configuration.mdx b/src/content/docs/reference/configuration.mdx index 674cfd4b8..c1d47b5bc 100644 --- a/src/content/docs/reference/configuration.mdx +++ b/src/content/docs/reference/configuration.mdx @@ -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..path` + +**Required.** + +Path to the plugin file (`.grit`) or plugin directory containing a +`biome-manifest.jsonc`. + +### `plugins..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`