diff --git a/src/content/docs/guides/big-projects.mdx b/src/content/docs/guides/big-projects.mdx index 046e2b9e0..3551d8758 100644 --- a/src/content/docs/guides/big-projects.mdx +++ b/src/content/docs/guides/big-projects.mdx @@ -147,6 +147,61 @@ case, we suggest ignoring the nested project entirely using [the `files.includes` field](/reference/configuration/#filesincludes). ::: +### Globs resolution + +The resolution of globs defined in the `*.includes` fields doesn't change when a nested configuration file extends the root. + +For example, the following project is placed in the folder `/Users/todo`, and contains a root configuration in `/Users/todo/biome.json`, and one +inside `/Users/todo/app/biome.json`. + +- Globs defined in `/Users/todo/biome.json` are resolved from `/Users/todo/`. +- Globs defined in `/Users/todo/app/biome.json` are resolved from `/Users/todo/app`. + +The root configuration excludes `app/generated.ts`, and the nested configuration extends the root, as follows: + + + - app + - biome.json + - generated.ts + - package.json + - biome.json + - package.json + + +```json title="/Users/todo/biome.json" +{ + "files": { + "includes": [ + "**", + "!app/generated.ts" + ] + } +} +``` + +```json title="/Users/todo/app/biome.json" +{ + "extends": "//" +} +``` + +**This setting won't exclude `app/generated.ts` if/when you decide to run a command from `/Users/todo/app`**. That's because when Biome resolves globs from `app/biome.json`, +the extended glob `!app/generated.ts` is resolved like this: `/Users/todo/app ~ !app/generated.ts`, which doesn't match any existing folder inside the project. + +To properly exclude `app/generated.ts`, you have two options: +- Prepend the glob with `**`, so that any folder is matched: + ```json title="/Users/todo/biome.json" ins="!**" ins={5} + { + "files": { + "includes": [ + "**", + "!**/app/generated.ts" + ] + } + } + ``` +- Move the `!app/generated.ts` glob inside `/Users/todo/app/biome.json` + ## Other ways to share a configuration file As we saw above, the `extends` field allows you to split your configuration diff --git a/src/content/docs/reference/configuration.mdx b/src/content/docs/reference/configuration.mdx index 1d478fdcd..11351b4b3 100644 --- a/src/content/docs/reference/configuration.mdx +++ b/src/content/docs/reference/configuration.mdx @@ -57,6 +57,8 @@ This is required so Biome can orchestrate multiple files in CLI and editors at t A list of [glob patterns](#glob-syntax-reference) of files to process. +All globs are resolved from the configuration file where they are defined. + If a folder matches a glob pattern, all files inside that folder will be processed. @@ -245,6 +247,8 @@ Enables Biome's linter. A list of [glob patterns](#glob-syntax-reference) of files to lint. +All globs are resolved from the configuration file where they are defined. + The following example lints all files with a `.js` extension inside the `src` folder: @@ -392,6 +396,8 @@ Enables Biome's assist. A list of [glob patterns](#glob-syntax-reference) of files to lint. +All globs are resolved from the configuration file where they are defined. + The following example analyzes all files with a `.js` extension inside the `src` folder: @@ -504,6 +510,8 @@ Enables Biome's formatter. A list of [glob patterns](#glob-syntax-reference) of files to format. +All globs are resolved from the configuration file where they are defined. + The following example formats all files with a `.js` extension inside the `src` folder: @@ -1483,6 +1491,8 @@ The order of the patterns matter. If a file *can* match three patterns, only the A list of [glob patterns](https://en.wikipedia.org/wiki/Glob_(programming)) of files for which to apply customised settings. +All globs are resolved from the configuration file where they are defined. + ```jsonc title="biome.jsonc" { "overrides": [{