Skip to content

Commit f0884f5

Browse files
committed
fix!: use import assertions to get prettierrcs
We need them to be in module graph so that esbuild can correctly bundle them, see f822d2d This is a breaking change as we can only support Node.js 16.14+ by using this feature.
1 parent e29e11b commit f0884f5

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default function createConfig ({
144144
}
145145
if (needsPrettier) {
146146
// Prettier recommends an explicit configuration file to let the editor know that it's used.
147-
files['.prettierrc.json'] = prettierrcs[styleGuide]
147+
files['.prettierrc.json'] = JSON.stringify(prettierrcs[styleGuide], undefined, 2)
148148
}
149149

150150
return {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"create-eslint-config": "bin/create-eslint-config.js"
99
},
1010
"engines": {
11-
"node": "^14.18.0 || >=16.0.0"
11+
"node": "^16.14.0 || >= 18.0.0"
1212
},
1313
"scripts": {
1414
"test": "echo \"Error: no test specified\" && exit 1"

templates/prettierrcs.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { readFileSync } from 'node:fs'
2-
import { fileURLToPath } from 'node:url'
1+
import defaultConfig from './prettierrc-default.json' assert { type: 'json' }
32

4-
export default readFileSync(fileURLToPath(new URL('./prettierrc-default.json', import.meta.url)))
3+
import airbnb from './prettierrc-airbnb.json' assert { type: 'json' }
4+
import standard from './prettierrc-standard.json' assert { type: 'json' }
55

6-
export const airbnb = readFileSync(fileURLToPath(new URL('./prettierrc-airbnb.json', import.meta.url)))
7-
export const standard = readFileSync(fileURLToPath(new URL('./prettierrc-standard.json', import.meta.url)))
6+
export {
7+
defaultConfig as default,
8+
9+
airbnb,
10+
standard,
11+
}

0 commit comments

Comments
 (0)