prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.03k stars 447 forks source link

nested prettier.config not taken into account #3336

Closed fredericrous closed 1 month ago

fredericrous commented 1 month ago

Summary

I have a global prettier file ~/.prettierrc.js In one of my monorepo, I have a prettier.config.cjs per packages and apps. When I format code with prettier-vscode, I do not get the formatting declared for my nested folders (packages and apps). I get the global one

Folder Structure of the Repository to Reproduce Issue

add a ~/.prettierrc.js with semi: true

add the following files to a repo with semi: false in prettier.config.cjs:

apps/my-app-1/prettier.config.cjs apps/my-app-1/src/test.js apps/my-app-2/src/test.js

Steps To Reproduce:

  1. open apps/my-app-1/src/test.js
  2. write some js code, example: console.log('test')

Expected result

notice prettier adds a semi-colon ; on save

Actual result

semi-colon should not be added by prettier in console.log('test')

VS Code Version: 1.85.2

Version: 1.85.2 Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681 Date: 2024-01-18T06:40:32.531Z Electron: 25.9.7 ElectronBuildId: 26354273 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin x64 21.6.0

Prettier Extension Version: v10.1.0

OS and version: MacOS Montery

note that I have no custom user config in my vscode for prettier, I let everything by default

ntotten commented 1 month ago

This is an issue or feature request for the Prettier library itself rather than the VS Code extension for prettier. Please open an issue at https://github.com/prettier/prettier.

fredericrous commented 1 month ago

it works with prettier command line tho... I don't understand your comment. I have been using this config for years with other IDEs. Did you test the reproduction workflow of this issue or was this a free PR Close?