Guide to using glob patterns in Ellipsis configuration.
.gitignore
patterns.
Quick Reference
Token | Meaning |
---|---|
* | any run of characters except / |
** | zero or more path segments |
{a,b} | brace expansion – either a or b |
!pattern | negation – exclude matches |
? | exactly one character except / |
[...] | one character from the set / range |
Use‑case | Pattern |
---|---|
All files at any depth | ** |
All markdown files at any depth | **/*.md |
All files in src/ | src/** |
All TypeScript & TSX in src/ | src/**/*.{ts,tsx} |
Only test files (Jest style) | **/*.{test,spec}.{ts,tsx} |
Everything except node_modules | ** !**/node_modules/** |
*
*
matches any string within a path segment, but not across directory boundaries.
*
when you meant to use the globstar **
- see below.**
**
matches any string (including empty) across directory boundaries. Using **
is the most common way to match all files in a directory.
{a,b}
src/**/*.{ts,tsx}
expands into two patterns: src/**/*.ts
and src/**/*.tsx
!pattern
!
to exclude it.
Negation is usually used in conjunction with multiple patterns.Patterns are evaluated in the order they are listed. So, you typically want your first pattern to be the most inclusive, followed by a series of negations.
["!src/utils/**", "**"]
will not exclude anything, and will instead match all files.Combining Brace Expansion and Negation
Character class `[...]`
Single‑char wildcard `?`
?
matches exactly one character (except /
).Extglobs: `@() !() ?() +() *()`
Syntax | Meaning | Handy mnemonic |
---|---|---|
@(p1|p2) | Exactly one of the alternatives | “At” least one – exactly one |
?(p) | Zero or one occurrence of the pattern | The ? you already know means “maybe” |
+(p) | One or more occurrences | + in regex = “one or more” |
*(p) | Zero or more occurrences | * in regex = “zero or more” |
!(p) | Anything except the alternatives | ! = “not” |
|
): @(foo|bar|baz)
.@
with extglobs:!
with extglobs:src/**/!(*.test|*.spec).js
is equivalent to ["src/**/*.js", "!src/**/*.{test,spec}.js"]
.*
with extglobs:?
with extglobs:+
with extglobs:/**
.gitignore
-style patterns, which don’t require using the globstar **
. So, we expand patterns that don’t end in /**
to include all files in the directory.
src
=> src/**
src/
=> src/**
**
pattern to run first in the list to ensure some files are included.
***
)***
is usually a typo where the user meant to write **
. So, we rewrite them to **
.
***
=> **
src/***/foo
=> src/**/foo