Skip to content

Config overrides do not work for files in the parent directory #13556

Description

@Shayan-To

I'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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:intendedBug reports that actually turned out to be intended behavior

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions