Skip to content

Conversation

FEliuyg
Copy link

@FEliuyg FEliuyg commented Oct 11, 2025

Added a check to ensure that plugin paths do not start with file://, in addition to the existing checks for relative and absolute paths. This improves the robustness of the plugin resolution logic.

  • Run tests

I created a shared Prettier configuration via npm that includes plugins. However, in a pnpm project, the plugin strings fail to locate the corresponding modules unless import.meta.resolve is used to resolve the module paths (see this issue).

After applying this fix, the Prettier CLI works correctly to format documents.

However, import.meta.resolve() returns URLs that start with file://. Since path.isAbsolute(plugin) returns false for such URLs, the path is incorrectly treated as non-absolute, leading to unexpected behavior. This can be resolved by converting the URL to a file path using url.fileURLToPath(import.meta.resolve('xxx')), which allows the plugin to work correctly with Prettier.

To improve reliability, I suggest adding an explicit check to treat paths starting with file:// as absolute paths during plugin resolution.

Added a check to ensure that plugin paths do not start with "file://", in addition to existing checks for relative and absolute paths. This improves the robustness of the plugin resolution logic.
@auto-assign auto-assign bot requested a review from ntotten October 11, 2025 02:49
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