Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not seem to work with overrides #200

Closed
petertriho opened this issue Jun 24, 2021 · 4 comments · Fixed by #559
Closed

Does not seem to work with overrides #200

petertriho opened this issue Jun 24, 2021 · 4 comments · Fixed by #559
Labels
bug Something isn't working

Comments

@petertriho
Copy link

petertriho commented Jun 24, 2021

I can't seem to get overrides to work with this config (.prettierrc.json). Changing the root tabWidth works but my overrides do not work for the specific files.

{
    "tabWidth": 4,
    "overrides": [
        {
            "files": [
                "*.yaml",
                "*.yml",
                "*.md"
            ],
            "options": {
                "tabWidth": 2
            }
        }
    ]
}

@fsouza fsouza added the bug Something isn't working label Jul 15, 2021
@barrett-ruth
Copy link

Sorry for the prod @fsouza , any updates on this?

@barrett-ruth
Copy link

barrett-ruth commented Oct 18, 2022

@petertriho Seems like a problem with prettier itself (see here)

For now, though, you can just create an editorconfig with the following options:

[*.{yaml,yml,md}]
indent_style = spaces
indent_size = 2

@fsouza
Copy link
Owner

fsouza commented Oct 22, 2022

Yeah looking at that issue, it looks like when resolveConfig is invoked overrides should work, and we do invoke resolveConfig. Maybe we're not setting the right parameters for the file type or something like that?

@barrett-ruth
Copy link

barrett-ruth commented Jul 7, 2023

@fsouza the problem has to do with how you cache values in configuration files. If I run prettierd with overrides in a config file, it works. If I change that config file, it doesn't.

These lines of code cache configurations according to files... but if the configuration file changes, prettierd completely ignores the new changes and just uses the cache.

I think you can either completely remove the config cache (would it really hurt performance that bad), figure out a way to invalidate files in the cache (which sounds annoying), or see how prettier did it.

Willing to write a PR for any of those solutions, let me know.

fsouza added a commit that referenced this issue Jul 8, 2023
Caching was introduced as a premature optimization: we probably don't
need it, and it complicates many things (see #511, #200, #533, #303 and
 #302).

I'll publish a release with this change and see what things look like
over the coming days.

Closes #200.
Closes #303.
Closes #511.
Closes #533.
@fsouza fsouza mentioned this issue Jul 8, 2023
@fsouza fsouza closed this as completed in f28c485 Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants