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

Option to let prettier determine format options instead of falling back to VSCode settings when project doesn't contain explicit prettier config #3508

Open
jedwards1211 opened this issue Aug 14, 2024 · 4 comments

Comments

@jedwards1211
Copy link

jedwards1211 commented Aug 14, 2024

Is your feature request related to a problem? Please describe.

There are many OSS projects that keep their code formatted with prettier with its default settings. They don't declare any explicit prettier config.

Anyone developing on a project like that needs prettier-vscode to apply the same format as running the prettier CLI would.

But prettier-vscode falls back to format options from prettier-vscode settings instead. If I could I would workaround by making the prettier-vscode settings match prettier's own defaults. But prettier has changed some defaults, for example trailing comma:

Default value changed from es5 to all in v3.0.0

(prettier-vscode still considers es5 the default)

So it's impossible to make prettier-vscode always format the way prettier would right now, without bending over backwards.

Describe the solution you'd like

An extension option: Always format the same way prettier CLI would

When enabled, if a project doesn't have explicit prettier config, prettier-vscode would ignore all format options in its own VSCode settings, and instead use the same default format options as prettier CLI. In other words, it wouldn't pass any format option values to prettier.format(...), letting prettier determine options from loading config or applying defaults.

Describe alternatives you've considered

If it were up to me I would have made this the default behavior and required users to opt into using format config from VSCode settings.

But unfortunately #3487 was rejected.

Additional context

I think it's ridiculous that the official prettier extension doesn't currently support letting the project's installed prettier control the options in all cases. Was this never a design goal? Did this use case get forgotten when people who want to format without installing prettier in projects asked for support?

It's just such an inane situation to have the official prettier extension actively cause incorrect format in a PR on a project that uses prettier, I feel so frustrated at the decisions that led to this.

@jedwards1211 jedwards1211 changed the title Option to use prettier's default format config instead of falling back to VSCode settings when project doesn't contain explicit config Option to let prettier determine format options instead of falling back to VSCode settings when project doesn't contain explicit prettier config Aug 14, 2024
@KholdStare
Copy link

Agreed completely - the vscode plugin should just let the prettier CLI tool determine its own options. We migrated to prettier 3 and are having the same issue with trailing commas. 🤦

@aryzing
Copy link

aryzing commented Sep 23, 2024

I have a feeling that perhaps the plugin values were set as a way of providing reasonable defaults at the time. Prettier, albeit slowly, does change it's defaults from time to time. Probably best to go with the package defaults rather than trying to set them through the plugin if not explicitly set by users.

@jedwards1211
Copy link
Author

jedwards1211 commented Sep 25, 2024

Really, the options in VSCode settings should be fallback values that only apply when formatting in a project that doesn't have prettier installed (though there should also be an option to only format if prettier is installed in the project)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants