-
-
Notifications
You must be signed in to change notification settings - Fork 10
Open
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@latest2. Create root Prettier config
Create .prettierrc in the project root:
{
"tabWidth": 2
}3. Create subdirectory with its own config
mkdir subdirCreate 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.jsChecking 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)
fabiospampinato and edi9999
Metadata
Metadata
Assignees
Labels
No labels