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

[Bug?] Symlink'd plugins in node_modules are not auto detected. #8056

Closed
benallfree opened this issue Apr 14, 2020 · 8 comments · Fixed by #14759
Closed

[Bug?] Symlink'd plugins in node_modules are not auto detected. #8056

benallfree opened this issue Apr 14, 2020 · 8 comments · Fixed by #14759
Labels
area:api Issues with Prettier's Application Programming Interface area:plugin api locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@benallfree
Copy link

Environments:

  • Prettier Version: 2.0.4
  • Running Prettier via: VSCode, CLI
  • Runtime: Node 12.16.2
  • Operating System: OS X

Steps to reproduce:

  1. Use npm to install prettier-plugin-organize-imports
  2. Run prettier foo.txs
  3. Observe that imports are correctly organized

This time, use pnpm which uses symlinks instead of copying packages to node_modules:

  1. Use pnpm to install prettier-plugin-organize-imports
  2. Run prettier foo.tsx from the command line
  3. Observe that imports are NOT organized

Now, add the plugin explicitly to package.json:

  "prettier": {
    "plugins": [
      "./node_modules/prettier-plugin-organize-imports"
    ]
  }

Repeat step 2 above and observe that plugins are now organized.

Expected behavior:

Symlink'd plugins in node_modules are auto detected.

Actual behavior:

Symlink'd plugins in node_modules are not auto detected.

@fisker
Copy link
Member

fisker commented Apr 14, 2020

I don't think we support plugins option.

Can you try node -p "require.resolve('prettier-plugin-organize-imports')" and node -p "require('prettier-plugin-organize-imports')"?

@fisker fisker added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Apr 15, 2020
@no-response
Copy link

no-response bot commented Apr 29, 2020

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Apr 29, 2020
@thorn0
Copy link
Member

thorn0 commented May 4, 2020

Prettier does support the plugins option. See https://prettier.io/docs/en/plugins.html

@thorn0 thorn0 reopened this May 4, 2020
@thorn0 thorn0 added area:api Issues with Prettier's Application Programming Interface status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug and removed status:awaiting response Issues that require answers to questions from maintainers before action can be taken labels May 4, 2020
@aparajita
Copy link

@thorn0 It's true you don't support the plugins option, but the issue is still valid. Plugins installed via pnpm are not auto-detected because their entries in node_modules are symlinks, not directories.

@fisker fisker added type:bug Issues identifying ugly output, or a defect in the program and removed status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug labels Sep 8, 2020
@fisker
Copy link
Member

fisker commented Sep 8, 2020

I can reproduce on local, run pnpm add prettier, Prettier will be installed in node_modules/.pnpm/prettier@2.1.1/node_modules/prettier, then we use findParentDir to find node_modules, it will be node_modules/.pnpm/prettier@2.1.1/node_modules and nothing is in there.

@ZeroAurora
Copy link

Experiencing the same bug. But things are worse, because plugins in my .prettierrc won't be detected too.

@Shinigami92
Copy link
Member

I was affected by exactly the same: simonhaenisch/prettier-plugin-organize-imports#34

IMO it should work out of the box.
I prefer .prettierrc.json instead of .prettierrc.js, because then you have support from jsonschema.

@arimgibson
Copy link

@Shinigami92 posted an example of this workaround on another thread, thought I'd link here for those wanting a temporary solution. It's a little bit of manual configuration, but pretty minor IMO.

https://github.com/prettier/plugin-pug/blob/3c6dd7222b65fea5c2ba69ddbb00dbed56d70b86/.prettierrc.cjs#L8

saibotk added a commit to clickbar/eslint-config that referenced this issue Dec 29, 2022
In pnpm settings, the plugin is not autodiscovered, so whe explicitly
enable it in our config.

See prettier/prettier#8056
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Aug 4, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:api Issues with Prettier's Application Programming Interface area:plugin api locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
7 participants