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

Ability to use/configure Format On Save to work with prettier configs within folders #3465

Open
cwhitemaddox opened this issue Jul 10, 2024 · 1 comment

Comments

@cwhitemaddox
Copy link

cwhitemaddox commented Jul 10, 2024

Right now, with the prettier-vscode extension installed, the extension will recognize prettier configs (e.g. .prettierrc) that are on the root of the vscode workspace/project, but it will not recognize configs that are within folders in that vscode workspace.

It would be helpful to have the prettier-vscode extension recognize and honor the prettier configs that are within folders in a vscode workspace. This is especially helpful in a monorepo context, where different folders of the monorepo can have different package.jsons and different prettier configs.

If, for examble, you have a folder structure in a workspace like so:

codebase-1/
  package.json
  .prettierrc
  src/
    first-script.ts
codebase-2/
  package.json
  .prettierrc
  src/
    second-script.ts

It is currently possible to cd into codebase-1/ and codebase-2/ and run, e.g. npx prettier --write src/, for each, but that does not happen automatically on save like the prettier-vscode extension so helpfully enables.

However, with the vscode workspace opened on code structure above, opening codebase-1/src/first-script.ts and saving the file (with Format On Save enabled), prettier-vscode will not use the config from codebase-1/.prettierrc.

@MrHaila
Copy link

MrHaila commented Sep 7, 2024

To add to the issue, this also affects .prettierignore files. The current workaround is to duplicate the ignore file contents from subfolders into the repo root.

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