micromatch / micromatch/picomatch
Negation extglob produces different results depending on order of alternatives
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.3k
- Forks
- 135
- Avg merge
- 23h 38m
- Merged PRs (30d)
- 7
Description
The order of alternatives inside a negation extglob !(...) affects matching results. Reordering the alternatives produces different (incorrect) results even though the order should not matter.
const picomatch = require('picomatch');
const opts = { dot: true };
// "amplify" first — incorrectly matches
const isMatch1 = picomatch('!(amplify/**|data/**|deploy/**)**', opts);
console.log(isMatch1('amplify/backend/function/jest.config.ts')); // true (WRONG)
// "amplify" last — correctly does not match
const isMatch2 = picomatch('!(deploy/**|data/**|amplify/**)**', opts);
console.log(isMatch2('amplify/backend/function/jest.config.ts')); // false (correct)
Expected behavior
Both patterns should produce identical results regardless of the order of alternatives inside !(...). The file amplify/backend/function/jest.config.ts should not match either pattern since it falls under amplify/**.
Actual behavior
When amplify/** is the first alternative, amplify/backend/function/jest.config.ts incorrectly matches. When amplify/** is moved to the last position, it correctly does not match.
Environment
- picomatch: 2.3.1
- node: v25.2.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the picomatch entry point and reproduce the two patterns from the issue on picomatch 2.3.1 with Node. Trace negation extglob alternative handling, then add coverage showing that reordering alternatives produces identical results and that the amplify path does not match either pattern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100