File tree Expand file tree Collapse file tree 8 files changed +61
-0
lines changed
Expand file tree Collapse file tree 8 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ import * as assert from "assert" ;
2+ import { format , getText } from "./formatTestUtils.js" ;
3+ import { ensureExtensionActivated } from "./testUtils.js" ;
4+
5+ describe ( "String ESM Config Support" , ( ) => {
6+ before ( async ( ) => {
7+ await ensureExtensionActivated ( ) ;
8+ } ) ;
9+
10+ // This test validates that .prettierrc with a string reference to an ESM config package works
11+ // Reproduces issue where extension fails with "Invalid prettier configuration file detected"
12+ // when .prettierrc contains a string pointing to an ESM prettier config package
13+ it ( "it formats with .prettierrc containing string reference to ESM config package" , async ( ) => {
14+ const { actual } = await format ( "string-esm-config" , "test.js" ) ;
15+ const expected = await getText ( "string-esm-config" , "test.result.js" ) ;
16+ assert . equal ( actual , expected ) ;
17+ } ) ;
18+ } ) ;
Original file line number Diff line number Diff line change 1+ "test-prettier-config-esm"
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " string-esm-config" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " Test folder for .prettierrc with string reference to ESM config package" ,
5+ "private" : true ,
6+ "type" : " module" ,
7+ "scripts" : {
8+ "test" : " echo \" Error: no test specified\" && exit 1"
9+ },
10+ "author" : " Prettier" ,
11+ "license" : " MIT" ,
12+ "devDependencies" : {
13+ "prettier" : " ^3.4.2" ,
14+ "test-prettier-config-esm" : " file:./test-prettier-config-esm"
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ // ESM Prettier config package
2+ const config = {
3+ semi : true ,
4+ singleQuote : false ,
5+ tabWidth : 2 ,
6+ trailingComma : "es5" ,
7+ } ;
8+
9+ export default config ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " test-prettier-config-esm" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " ESM Prettier config package for testing" ,
5+ "type" : " module" ,
6+ "main" : " index.js" ,
7+ "exports" : {
8+ "." : " ./index.js"
9+ },
10+ "author" : " Prettier" ,
11+ "license" : " MIT"
12+ }
Original file line number Diff line number Diff line change 1+ const foo = { bar :1 , baz :2 } ;
Original file line number Diff line number Diff line change 1+ const foo = { bar : 1 , baz : 2 } ;
Original file line number Diff line number Diff line change 5757 {
5858 "path" : " esm-plugin-import"
5959 },
60+ {
61+ "path" : " string-esm-config"
62+ },
6063 {
6164 "path" : " monorepo-subfolder/subfolder"
6265 },
You can’t perform that action at this time.
0 commit comments