Add test for .prettierrc with string reference to ESM config package#3868
Merged
Add test for .prettierrc with string reference to ESM config package#3868
Conversation
Co-authored-by: ntotten <[email protected]>
Co-authored-by: ntotten <[email protected]>
Copilot
AI
changed the title
[WIP] Fix JSON config resolution for ESM Prettier
Add test for .prettierrc with string reference to ESM config package
Dec 1, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds test coverage for a specific Prettier configuration pattern where a .prettierrc file contains a string reference to an ESM config package. This addresses an issue where the extension fails with "Invalid prettier configuration file detected" when resolving such configurations.
Key changes:
- New test suite
string-esm-config.test.tsto validate string ESM config resolution - Test fixture
test-fixtures/string-esm-config/with local ESM package dependency - Workspace configuration updated to include the new test fixture
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/test/suite/string-esm-config.test.ts |
New test suite validating .prettierrc with string reference to ESM config package |
test-fixtures/test.code-workspace |
Added string-esm-config fixture to test workspace |
test-fixtures/string-esm-config/.prettierrc |
Test config file containing string reference to ESM package |
test-fixtures/string-esm-config/package.json |
Test fixture package with Prettier 3.4.2 and local ESM config package dependency |
test-fixtures/string-esm-config/test.js |
Unformatted test input file |
test-fixtures/string-esm-config/test.result.js |
Expected formatted output |
test-fixtures/string-esm-config/test-prettier-config-esm/package.json |
ESM config package definition with proper module exports |
test-fixtures/string-esm-config/test-prettier-config-esm/index.js |
ESM config package exporting Prettier configuration |
| @@ -0,0 +1 @@ | |||
| const foo={bar:1,baz:2}; | |||
There was a problem hiding this comment.
Unused variable foo.
Suggested change
| const foo={bar:1,baz:2}; |
| @@ -0,0 +1 @@ | |||
| const foo = { bar: 1, baz: 2 }; | |||
There was a problem hiding this comment.
Unused variable foo.
Suggested change
| const foo = { bar: 1, baz: 2 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds test coverage for
.prettierrcfiles containing a string reference to an ESM config package. This pattern is valid in Prettier but was reported to fail in the extension with "Invalid prettier configuration file detected."Test fixture structure:
.prettierrccontaining"test-prettier-config-esm"(JSON string reference)test-prettier-config-esm/exporting Prettier config with"type": "module"Example of the pattern being tested:
Where the referenced package exports ESM:
Verified: Prettier CLI resolves this config correctly. Test will validate extension behavior.
Related Issue
Addresses issue where extension fails to resolve string JSON configs that reference pure ESM prettier config packages.
Type of Change
Checklist
npm run lintpasses)npm run prettierto format my codenpm test)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com//advisories/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(http block)update.code.visualstudio.com/usr/local/bin/node node /home/REDACTED/work/prettier-vscode/prettier-vscode/node_modules/.bin/vscode-test(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.