Glob Patterns
Glob patterns are used all throughout the package’s configuration to determine whether a path/file should have some specific behavior applied to it. For the most part, the package makes use of the fast-glob syntax, with one notable exception. If you want to test out some glob patterns, there is a playground available.
Basic Syntax
*
matches any character, except for/
and hidden files (starting with.
).**
matches zero or more directories?
matches a single character, except for/
[seq]
matches any character inseq
Only matches a file in the root directory (because /
are not matched).
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md
Only matches files with the .md
extension in the root directory.
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md
Matches all files in all directories.
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md
Matches all files with the .md
extension in all directories.
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md
Matches all files with a two-character extension in all directories.
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md
Matches all files with a two-character extension in all directories.
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md
Advanced Syntax
?(a|b)
matchesa
orb
(zero or one times)*(a|b)
matchesa
orb
(zero or more times)+(a|b)
matchesa
orb
(one or more times)@(a|b)
matchesa
orb
(exactly one time)!(a|b)
matches anything excepta
orb
Pattern processing
- Patterns are processed in the order they are defined.
- The first pattern that matches the file path will be used to determine the behavior.
- If a
!
is present at the start of the pattern, the behavior will be negated.
Some examples:
Matches all files.
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md
Matches no files, even if the second pattern matches all files, because the first pattern is matched first.
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md
Matches all files in the dir
directory.
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md
Matches all files in the some
directory, except for those dir
directory.
- page.md
- script.js
Directorysome
Directorydir
- important.ts
- file.md
- .hidden.md
Directoryother-dir
- note.mdx
- regular.md