prettier-vscode icon indicating copy to clipboard operation
prettier-vscode copied to clipboard

The vscode extension is inconsistent with the default value of the prettier configuration file

Open a81n9 opened this issue 1 year ago • 6 comments
trafficstars

I found that the default configuration of the prettier vscode extension is inconsistent with the prettier configuration file.

For example, the default configuration of prettier vscode extended trailingComma is es5, while the default configuration of prettier configuration file is all.

Prettier vscode Extension

Prettier options

a81n9 avatar Jul 02 '24 03:07 a81n9

I had exactly this problem - it's becuase the version of prettier itself bundled inside the vs code extension is an old version (2.8) which has a different default value for the trailing comma parameter

as suggested somewhere in the documentation, if you npm install prettier on your machine (either globally or in the project, the vs code extension will use this version and so you will get the latest defaults

timrobinson33 avatar Aug 23 '24 15:08 timrobinson33

@timrobinson33 I was running into this issue even when prettier 3 was locally installed and I had pointed the extension at that executable.

I'm pretty sure VSCode settings defaults are static anyway, and it would be impossible to change them based upon the locally installed prettier.

It baffles me that anyone benefits from being able to configure prettier format in their VSCode settings.

jedwards1211 avatar Sep 03 '24 14:09 jedwards1211

@timrobinson33 I was running into this issue even when prettier 3 was locally installed and I had pointed the extension at that executable.

Hmm I'm not sure what you were seeing. the documentation says:

"Should prettier not be installed locally with your project's dependencies or globally on the machine, the version of prettier that is bundled with the extension will be used."

and also:

"Prettier's preview version 3 is supported as of version 9.12.0. It is not included in the extension by default, but can be used by installing locally in your project"

and this is definitely what happened for me.

TBH though there are so many different ways to configure these tools and what with prettier, eslint, tsconfig, package.json etc, not to mention all the vs code settings files, I struggle to figure out what's going on most of the time :-)

timrobinson33 avatar Sep 04 '24 09:09 timrobinson33

Yeah the extension can use prettier 3 but that doesn't mean it will change the default format settings in the extension. Try it in a project that doesn't declare its own format settings, you will see

jedwards1211 avatar Sep 04 '24 14:09 jedwards1211

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

github-actions[bot] avatar Feb 11 '25 02:02 github-actions[bot]

/unstale Still an issue AFAIK

shreyasminocha avatar Feb 11 '25 03:02 shreyasminocha

To avoid this issue, you can create an empty .prettierrc file in the root of your project. That way, when VSCode prettier extension runs it detects that you have an empty configuration an respects it.

I saw this because the logs for the prettier extension said:

["INFO" - 5:59:46 PM] Extension Name: esbenp.prettier-vscode.
["INFO" - 5:59:46 PM] Extension Version: 11.0.0.
["INFO" - 6:06:27 PM] Using config file at /Users/jackbravo/Documents/meetearnest/aegis-authentication-service/.prettierrc
["INFO" - 6:29:48 PM] No local configuration (i.e. .prettierrc or .editorconfig) detected, falling back to VS Code configuration
["INFO" - 6:29:48 PM] Prettier Options:
{
  "arrowParens": "always",
  "bracketSpacing": true,
  "endOfLine": "lf",
...

jackbravo avatar Oct 17 '25 02:10 jackbravo

This also seems like a duplicate of #3487, which mentions the same workaround I mentioned :-p. And also another one of setting the prettier.requireConfig config option.

jackbravo avatar Oct 17 '25 02:10 jackbravo

That's not a good workaround: This happened to me contributing to a project that's not mine... didn't realize until CI failed. It should just work off the bat in any project we're contributing to. I'm not sure that project is even willing to have an empty .prettierrc in their repo

jedwards1211 avatar Oct 17 '25 13:10 jedwards1211