Skip to content

Commit 12086d5

Browse files
committed
use local prettier config
1 parent c11ae86 commit 12086d5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"semi": false
5+
}

mdxts/src/components/Code.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import { join } from 'node:path'
33
import { readFile, writeFile } from 'node:fs/promises'
44
import type { SourceFile } from 'ts-morph'
5-
import { format } from 'prettier'
5+
import { format, resolveConfig } from 'prettier'
66
import { isJsxOnly } from '../utils/is-jsx-only'
77
import { getHighlighter, type Theme } from './highlighter'
88
import { project } from './project'
@@ -109,10 +109,10 @@ export async function Code({
109109

110110
// Format JavaScript code blocks.
111111
if (isJavaScriptLanguage) {
112-
finalValue = await format(finalValue, {
113-
filepath: filename,
114-
printWidth: 60,
115-
})
112+
const config = await resolveConfig(filename)
113+
config.filepath = filename
114+
config.printWidth = 60
115+
finalValue = await format(finalValue, config)
116116
}
117117

118118
// Scope code block source files since they can conflict with other files on disk.

0 commit comments

Comments
 (0)