Skip to content

fix: respect overrides of manual configs - #125

Open
43081j wants to merge 3 commits into
mainfrom
jg/manual-overrides
Open

43081j wants to merge 3 commits into
mainfrom
jg/manual-overrides

Conversation

@43081j

@43081j 43081j commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Passes the manual config through normal config resolution such that
overrides are evaluated and respected.

Fixes #124

Passes the manual config through normal config resolution such that
`overrides` are evaluated and respected.

Fixes #124
@pkg-pr-new

pkg-pr-new Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

yarn add https://pkg.pr.new/@prettier/cli@125.tgz

commit: 7d85b6b

@43081j
43081j requested a review from fisker October 16, 2026 10:00
@fisker

fisker commented Oct 19, 2026

Copy link
Copy Markdown
Member

Have you tested how the classic CLI works? I think it makes sense to solve files from the config path.

@43081j

43081j commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

do you have an example? i'm not sure i follow.

you're saying prettier --config ~/config.json foo.js should resolve ~/foo.js? that doesn't seem right.

this is just fixing a bug: we weren't resolving overrides for manual configs at all, i.e. they were completely skipped. so this branch now resolves them


describe("--config-path in another dir resolves override globs from the cwd", () => {
runCli("config-path-other-dir", [
"--config-path",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classic CLI uses --config, not --config-path, a known bug?

https://prettier.io/docs/next/cli#--find-config-path-and---config

@43081j 43081j Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has always used --config from when Fabio first made it, i just assumed it was on purpose to make it clearer what it is. i don't think it can be considered a bug, its just a choice to be made

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fisker

fisker commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

do you have an example? i'm not sure i follow.

>cat config/prettier.json
{
  "semi": true,
  "overrides": [
    {
      "files": "src/*.js",   # <-- this should only apply to `config/src/*.js`, no matter where Prettier runs
      "options": {
        "semi": false
      }
    }
  ]
}

>node bin/prettier --config=config/prettier.json src/foo.js
const x = "foo"; # <-- still prints semiconlon

>node bin/prettier --config=config/prettier.json config/src/foo.js
const x = "foo" # <-- no semicolon

@43081j

43081j commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

ok @fisker i've updated it:

  • overrides are now relative to their config file
  • fixed a bug during that where we weren't clearing overrides before adding the normalised ones
  • added some test cases to cover this

}
}
]
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just a//b/ or foo bar instead of src//lib/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no particular reason. its just what i was testing it against so the fixture ended up the same name.

happy to change it if needed

@fisker

fisker commented Oct 20, 2026

Copy link
Copy Markdown
Member

I didn't look into the implementation details, but the result looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

overrides[].files never match when the config is passed with --config-path from another directory

2 participants