`--ignore-pattern` comma-split conflicts with gitignore brace expansion syntax
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and discussions and couldn’t find anything (or linked relevant results below)
Thanks for this great tool! I ran into an issue with
--ignore-patternand wanted to share both the problem and two possible approaches to fix it.
Problem
--ignore-pattern values are parsed through commaParse (comma-separated-tokens), which splits on commas. This makes it impossible to use gitignore brace expansion like {a,b} in patterns.
Reproduction
remark . --ignore-pattern "**/{src,dist}/examples/**"Expected: ignores src/examples/ and dist/examples/ under all directories.
Actual: nothing is ignored, because commaParse splits the value into two invalid patterns:
"**/{src" ← broken
"dist}/examples/**" ← brokenCurrent solutions
Root cause
lib/parse-argv.js line 187-189:
const ignorePattern =
parseIfString(joinIfArray(undefinedIfBoolean(config['ignore-pattern']))) ||
[]The parseIfString → commaParse roundtrip exists to support --ignore-pattern "a,b" syntax. But --ignore-pattern already supports repeated flags:
--ignore-pattern a --ignore-pattern b # already worksThe comma-split is redundant and actively breaks valid gitignore syntax.
Two possible fixes
Fix A: unified-args (upstream)
Change one line in lib/parse-argv.js:
const ignorePattern = toArray(undefinedIfBoolean(config['ignore-pattern'])) || []toArray is already in the file. Single values → [value], repeated flags → [value1, value2], no comma split. This fixes it at the root for all downstream CLI tools (remark-cli, retext-cli, rehype-cli). But it's technically breaking for anyone currently relying on --ignore-pattern "a,b" semantics.
Fix B: remark-cli (downstream workaround)
Pre-expand brace patterns in cli.js before handing off to unified-args:
// See remarkjs/remark for the full implementation
// --ignore-pattern "**/{a,b}/**"
// → expands to:
// --ignore-pattern "**/a/**" --ignore-pattern "**/b/**"No breaking change, no dependency on upstream. But only fixes remark-cli, not other tools that use unified-args.
Proposed solutions
I prefer Fix A:
Fixes the root cause, not the symptom — the parser shouldn't treat commas as delimiters in values where commas are valid gitignore syntax.
The impact is minimal —
--ignore-pattern a --ignore-pattern bis already the established idiom (ESLint, Prettier, etc.), and anyone who happens to use the comma form would get a clean break rather than silently broken brace expansion.Only
unified-argsneeds to change; otherwise every downstream CLI has to carry its own workaround.
Source: remarkjs/remark