microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.75k stars 588 forks source link

[rush] How to use sharing prettier config with vscode prettier plugin? #3149

Open ChikaFujiwara opened 2 years ago

ChikaFujiwara commented 2 years ago

Summary

I want to use prettier plugin with sharing config from a npm package, but don't know how.

Details

I want to use sharing prettier config from a npm package https://prettier.io/docs/en/configuration.html#sharing-configurations.

I have read the rush doc of how to enable prettier, But how can I use it with the vscode prettier plugin?

I tried to add "@azz/prettier-config" to the .prettierrc.json, and the plugin said Cannot find module '@azz/prettier-config'

I don't know how to add the dependency so that the plugin can read it

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.58.0
rushVersion from rush.json? 5.58.0
useWorkspaces from rush.json? false
Operating system? Mac
Would you consider contributing a PR? No
Node.js version (node -v)? 16.13.1
halfnibble commented 2 years ago

Our process may not be compatible with the VS Code plugin. While not ideal, does the VS Code plugin work if you globally install your prettier config package?

ChikaFujiwara commented 2 years ago

Our process may not be compatible with the VS Code plugin. While not ideal, does the VS Code plugin work if you globally install your prettier config package?

Sadly no. Now I use vscode workspace and install the prettier config in every package to work around.

D4N14L commented 2 years ago

Looking at the documentation (https://prettier.io/docs/en/configuration.html#sharing-configurations). you could work around this by using a .prettierrc.js file and require-ing the installed prettier config directly from the common/temp/node_modules/... path to the prettier config you want to use, or to the node_modules of some stub project set up to provide the prettier config package. This would mean that rush install would need to be run before prettier could be used, but I think this would be expected anyway.