-
-
Notifications
You must be signed in to change notification settings - Fork 207
fix: improve globs resolution docs #3727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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/generate.ts`, and the nested configuration extends the root, as follow: | ||
ematipico marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <FileTree> | ||
| - app | ||
| - biome.json | ||
| - generated.ts | ||
| - package.json | ||
| - biome.json | ||
| - package.json | ||
| </FileTree> | ||
|
|
||
| ```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/generatd.ts`, which doesn't match any existing folder inside the project. | ||
ematipico marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| To properly exclude `app/generated.ts`, you have two options: | ||
| - Prepend the glob with `**`, so that any folder is matched: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look right-- prepending You would need to remove the package path from the root config so that it sees the package relative path correctly.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand. The objective is to exclude What am I missing? Please provide an example so I can understand There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you have the paths: and Prefixing a Let me know if I am making any sense 🤞 |
||
| ```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` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this done? Is there a way to manipulate the global It may be worth clarifying what exactly you can do if you want to move the path into the package config. I think something like: in an exclude, but I am not 100% on that. |
||
|
|
||
| ## Other ways to share a configuration file | ||
|
|
||
| As we saw above, the `extends` field allows you to split your configuration | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ematipico this seems opposite of the above-- they are not resolved from the config file they are defined, but rather from the "leaf" or "package" config file, right?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair. What about "configuration where they are loaded from"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that sounds better 👍 |
||
|
|
||
| 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": [{ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think part of the confusion may arise from this kind of description. From my perspective, these two points contradict the actual behavior, because the root glob is evaled from the config file it was defined in only if no other config file inherits from it. If a package config file inherits from the root, then globs are not evaled from the file they are defined in but rather the file that inherits them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's confusing if the docs and the behaviour are contradicting one another. But I do think the behaviour as described here sounds the most sensible, so I would consider the actual behaviour to be a bug then.