Skip to content

Conversation

adamhl8
Copy link
Contributor

@adamhl8 adamhl8 commented Oct 6, 2022

Continuation of #11248

status: 0,
write: [],
});
});
Copy link
Member

@fisker fisker Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these tests are correctly testing the added part. The plugin search logic always starts from Prettier cli, if we want test, we'll have to put Prettier into those dirs. I don't know how to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be misunderstanding the code, but I think in run-prettier.js the cwd gets set properly in run(). Either way, if I log autoLoadDir, it is set to the expected directory, so it does seem prettier is starting from the right directory.

@@ -113,6 +142,20 @@ async function findPluginsInNodeModules(nodeModulesDir) {
return pluginPackageJsonPaths.map(path.dirname);
}

async function findPluginDirsInPnpmVirtualStore(searchDirectory) {
const pluginPackageJsonPaths = await fastGlob(
["prettier-plugin-*", "@*/node_modules"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't plugins also stored like prettier-plugin-foo@1.0.0? I don't know how the @*/plugin-* stored, but are you sure these patterns correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the pnpm virtual store, the three possible types of plugins (@prettier/plugin-*, and @<name>/prettier-plugin-*, prettier-plugin-*) are stored like this:

.pnpm/
├── @prettier+plugin-foo@<version>/
│   └── node_modules/
│       └── @prettier/
│           └── plugin-foo/
├── @<name>+prettier-plugin-bar@<version>/
│   └── node_modules/
│       └── @<name>/
│           └── prettier-plugin-bar/
└── prettier-plugin-baz@<version>/
    └── node_modules/
        └── prettier-plugin-baz/

I don't think the +package-name part of the directory used to be there, but now that it is, I can just have the patterns be ["prettier-plugin-*", "@prettier+plugin-*", "@*+prettier-plugin-*"].

@adamhl8
Copy link
Contributor Author

adamhl8 commented Nov 17, 2022

@fisker Any chance this will be included in next?

@fisker
Copy link
Member

fisker commented Nov 17, 2022

We haven't decided yet. But we are planning to remove plugin auto-load. @thorn0

@fisker fisker changed the base branch from next to main April 23, 2023 01:17
@fisker fisker mentioned this pull request Apr 25, 2023
4 tasks
@fisker fisker closed this in #14759 May 5, 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.

2 participants