Config overrides do not work for files in the parent directory
See original GitHub issueI’m using prettier to format some json files with custom extensions (like VSCode’s .code-workspace
files). The files are in the parent directory of the project, so I’m running prettier --write ../**/*.{json-1,json-2}
.
The problem I have is that I cannot tell prettier that parser for .json-1
files is "json"
. This is my config:
{
"overrides": [
{
"files": "*.json-1",
"options": {
"parser": "json"
}
}
]
}
And when I run prettier, it gives me this output:
[error] No parser could be inferred for file: ../test.json-1
I have also tried changing "files": "*.json-1"
to "files": "**/*.json-1"
and "files": "../**/*.json-1"
, but the behavior is the same.
Environments:
- Prettier Version: 2.7.1
- Running Prettier via: CLI
- Runtime: Node.js v16.14.2
- Operating System: Ubuntu 20.04.4
- Prettier plugins (if any): –
Steps to reproduce:
Here’s the repro (in the prettier-parent-overrides
branch): https://github.com/Shayan-To/repros/tree/prettier-parent-overrides
Go into the project directory cd prettier-proj
, and after npm install
, run npm run repro
.
There are files both in the parent directory, and in the project directory. Prettier can infer the parser for none of the files in the parent directory.
Expected behavior:
The overrides
configurations for the files in the parent directory can be set.
Actual behavior:
There seems to be no way to set overrides
configurations for the files in the parent directory.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Forgot about this: https://prettier.io/docs/en/cli.html#--find-config-path-and---config You can specify the config file in the command line to get what you need.
Right
Only for files inside the project directory because your glob includes them.
Yes
As for editorconfig, AFAIK, it’s all intended too, but I can’t comment more on it now. Feel free to search the issue tracker yourself to find the discussions that lead to the current state of things.