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

Trouble reading prettierrc if it uses extends #2728

Open
AnnieTaylorCHEN opened this issue Sep 27, 2022 · 15 comments
Open

Trouble reading prettierrc if it uses extends #2728

AnnieTaylorCHEN opened this issue Sep 27, 2022 · 15 comments
Labels
uncomfirmed Possible bugs that haven't been confirmed

Comments

@AnnieTaylorCHEN
Copy link

AnnieTaylorCHEN commented Sep 27, 2022

Summary

If you have a prettier config npm package and install it in your local repo (such as in a big team where you want to centrally manage your prettier config), then you use the extends, now when you set up the settings.json in vscode, and prettier require config to be true, it doesn't seem to work. It will only work when you copy paste the actual rules in your config file. That means the current fix is to have a post install script to manually copy that file.

Github Repository to Reproduce Issue

N/A

Steps To Reproduce:

  1. Have a prettier config released as an independent npm package.
  2. Install it in your local repo, add this to your .prettierrc locally
module.exports = {
    ...require('@yourOrg/prettier-config'),
  };
  1. Add this to your .vscode/settings.json:
{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true,
  "editor.formatOnPaste": false,
  "prettier.requireConfig": true
}
  1. start changing and see if it works as expected.

Expected result

It should format exactly as our prettier config rules specified in that npm package.

Actual result

It doesn't seem to work, unless we copy the rules into our local prettierrc.

Additional information

N/A.

VS Code Version: 1.71.2 (Universal)

Prettier Extension Version: v9.9.0

OS and version: MacOS 12.6 as well as Ubuntu 22.04

Prettier Log Output

LOG GOES HERE. DO NOT USE A SCREENSHOT, COPY AND PASTE THE TEXT
@ntotten ntotten added the uncomfirmed Possible bugs that haven't been confirmed label Oct 7, 2022
@jguerinet
Copy link

I'm having the same issue described above. We have a shared prettier configuration that is imported via an NPM module, and then referenced from the project's .prettierrc file. When the reference is there, changes to the module's .prettierrc do not change how the document is formatted. It would seem that when you refer one prettier config file from another, the extension does not follow. Very simple to reproduce:

  • Create a .prettierrc file with the following:
"./.prettierrc-test.json"
  • Create a prettierrc-test.json file with a Prettier configuration. In my test, I simply turned semicolons on and off:
{ "semi": false }

When you change semi to true/false and use the command line to format your project files, you will see that they follow whatever is in prettierrc-test.json as it is correctly resolving the reference in .prettierrc.

However, When simply using the Prettier extension to format your files, the configurations in prettierrc-test.json are not followed at all.

@a2937
Copy link

a2937 commented May 17, 2023

I can also confirm that I have the same problem. If necessary, I will set up an example project that uses a npm prettier config package.

@github-actions
Copy link

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Jul 17, 2023
@jguerinet
Copy link

Replying to keep this issue open.

@github-actions github-actions bot removed the Stale label Jul 18, 2023
@github-actions
Copy link

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Sep 17, 2023
@frederikhors
Copy link

Keep open.

@github-actions github-actions bot removed the Stale label Sep 18, 2023
Copy link

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Nov 17, 2023
@frederikhors
Copy link

Nope.

@github-actions github-actions bot removed the Stale label Nov 18, 2023
Copy link

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Jan 17, 2024
@frederikhors
Copy link

Nope

@github-actions github-actions bot removed the Stale label Jan 18, 2024
Copy link

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label Mar 19, 2024
@frederikhors
Copy link

Nope

@jguerinet
Copy link

Ideally we can get some sort of acknowledgement for this issue, or at the very least the removal of the stale and unconfirmed labels? Reproducible steps are provided above, it should at the very least be confirmed... This is the 7th oldest open issue on this repo.

@github-actions github-actions bot removed the Stale label Mar 20, 2024
Copy link

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

@github-actions github-actions bot added the Stale label May 19, 2024
@jguerinet
Copy link

Still happening, would appreciate some sort of acknowledgement.

@github-actions github-actions bot removed the Stale label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
uncomfirmed Possible bugs that haven't been confirmed
5 participants