Open jedwards1211 opened 2 months ago
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. 🤦
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.
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)
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 theprettier
CLI would.But
prettier-vscode
falls back to format options fromprettier-vscode
settings instead. If I could I would workaround by making theprettier-vscode
settings matchprettier
's own defaults. Butprettier
has changed some defaults, for example trailing comma:(
prettier-vscode
still considerses5
the default)So it's impossible to make
prettier-vscode
always format the wayprettier
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 asprettier
CLI. In other words, it wouldn't pass any format option values toprettier.format(...)
, lettingprettier
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.