prettier / prettier/prettier-cli
Config resolution differs between explicit paths and glob patterns
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 43
- Forks
- 10
- Avg merge
- 18m
- Merged PRs (30d)
- 1
Description
The experimental cli applies different configuration files to the same file depending on whether you specify an explicit file path or use a glob pattern
Observed behavior:
- Explicit path (
subdir/example.js): Uses root.prettierrcconfig ❌ - Glob pattern (
"subdir/*.js"): Uses subdirectory.prettierrcconfig ✅
According to Prettier's documentation, config resolution should search upward from the file being formatted and use the closest config found. Both commands should use subdir/.prettierrc for files in subdir/.
Reproduction Steps
1. Set up a test dir
mkdir prettier-experimental-bug
cd prettier-experimental-bug
npm init -y
npm install --save-dev prettier@latest
2. Create root Prettier config
Create .prettierrc in the project root:
{
"tabWidth": 2
}
3. Create subdirectory with its own config
mkdir subdir
Create subdir/.prettierrc:
{
"tabWidth": 4
}
4. Create a test file
Create subdir/example.js:
function example() {
return;
}
5. Format the file to establish baseline
npx prettier --no-cache --experimental-cli --write "subdir/*.js"
This should format the code block with 4-space indentation (using subdir/.prettierrc).
6. Reproduce the bug
Test with explicit path:
npx prettier --no-cache --experimental-cli --check subdir/example.js
Checking fails ✗ (file has 4 spaces, but root config expects 2 spaces)
Test with glob pattern:
npx prettier --no-cache --experimental-cli --check "subdir/*.js"
Checking passes ✓ (file has 4 spaces, subdir config expects 4 spaces)
Contributor guide
No contributing guide indexed for this repository
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 by running the explicit-path and glob-pattern commands in the reproduction, then trace the experimental CLI's file handling and configuration resolution paths to compare them. Done means both commands apply the nearest subdir/.prettierrc configuration and produce consistent check results for files in subdir/.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100