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

Try searching for manually specified plugins in pluginSearchDir's #12763

Closed
wants to merge 2 commits into from

Conversation

zachkirsch
Copy link

@zachkirsch zachkirsch commented May 1, 2022

Description

If you specify a --plugin that lives outside the current tree (i.e. not resolvable by require.resolve), the CLI throws with a MODULE_NOT_FOUND error. Locations provided via --plugin-search-dir are not searched.

After this PR: Locations provided via --plugin-search-dir are searched when resolving manually specified plugins.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@zachkirsch zachkirsch changed the title Add failing test for searching --plugin using --plugin-search-dir Try searching for manually specified plugins in pluginSearchDir's May 1, 2022
@fisker
Copy link
Sponsor Member

fisker commented May 4, 2022

pluginSearchDirs and plugins are independent and one does not require the other.

https://prettier.io/docs/en/plugins.html#using-plugins

@zachkirsch
Copy link
Author

zachkirsch commented May 4, 2022

Thanks for taking a look @fisker and @kachkaev! While pluginSearchDirs and plugins don't require each other, this PR is addressing the case where you choose to use both.

In the link you sent, the first example is

prettier --write main.foo --plugin-search-dir=./dir-with-plugins --plugin=prettier-plugin-foo

i.e. using a plugin prettier-plugin-foo that exists in ./dir-with-plugins.

However, if you instead specified a path that doesn't fall inside the current workspace, then prettier fails:

prettier --write main.foo --plugin-search-dir=../../../../dir-with-plugins --plugin=prettier-plugin-foo

If you checkout the first commit on this branch 9f8329d (it includes the test but not the fix) you can see an example

@fisker
Copy link
Sponsor Member

fisker commented May 5, 2022

You can do prettier --plugin=../../../../dir-with-plugins/prettier-plugin-foo/index.js

@zachkirsch
Copy link
Author

Yep that’s true! Just kind of cumbersome if I have a lot of plugins that live in that directory.

Would you rather this PR not merge? I thought I was fixing a bug but it sounds like the existing behavior is preferable?

@fisker
Copy link
Sponsor Member

fisker commented Nov 15, 2023

Close sinc the plugin search feature has been removed.

@fisker fisker closed this Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants