-
-
Notifications
You must be signed in to change notification settings - Fork 688
Description
Description
Prior to #1687 and #1995, Biome traversed all directories regardless of include
and ignore
.
Glob patterns of include
and ignore
were only tested on regular files.
Users were not able to prevent Biome from traversing a directory. This resulted in a performance penalty (when a large hierarchy was traversed for nothing) and reporting errors (broken symlinks and files with higher permissions).
#1687 fixed this by skipping folders that match at least one ignore
pattern and folders that don't match all include
patterns.
Unfortunately, this introduced a regression because it is likely that a folder don't match any include
pattern.
Let's take an example:
❯ tree
.
├── biome.json
├── src
│ └── file.js
❯ cat biome.json
{
"files": {
"include": ["./**/*.js"]
}
}
❯ biome format src
internalError/io ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ No files were processed in the specified paths.
Here src/file.js
is not processed because src
doesn't match ./**/*.js
.
This is an unexpected result.
To avoid this issue, #1995 doesn't match folders (including symlinks that target a folder) against include
.
This fixed the regression. However, this partially reverts #1687 by not ignoring the folders in which all its files don't match all patterns of include
.
For instance, the following configuration should prevent Biome from traversing the test
folder.
❯ tree
.
├── biome.json
├── src
│ └── file.js
├── test
│ └── ...
❯ cat biome.json
{
"files": {
"include": ["./src/**/*.js"]
}
}
To prevent Biome from visiting test
, we should adopt a dedicated strategy for matching directories within include
:
If a folder is not a prefix of at least one pattern of include
, it should be ignored.
Here test/
is not a prefix of ./src/**/*.js
. test/
is a valid prefix of ./**/*.js
or ./test/**/*.js
.
See #1995 for more context.