@@ -11,6 +11,7 @@ import {
1111 getLeadingComment ,
1212 isIgnoreDirective ,
1313 isInsideQuotedAttribute ,
14+ isJSON ,
1415 isLess ,
1516 isNodeSupportedLanguage ,
1617 isPugTemplate ,
@@ -177,7 +178,7 @@ export function embed(path: FastPath, _options: Options) {
177178
178179 const embedType = (
179180 tag : 'script' | 'style' | 'template' ,
180- parser : 'typescript' | 'babel-ts' | 'css' | 'scss' | 'less' | 'pug' ,
181+ parser : 'typescript' | 'babel-ts' | 'css' | 'scss' | 'less' | 'pug' | 'json' ,
181182 isTopLevel : boolean ,
182183 ) => {
183184 return async (
@@ -203,7 +204,7 @@ export function embed(path: FastPath, _options: Options) {
203204 // the user could have set the default language. babel-ts will format things a little
204205 // bit different though, especially preserving parentheses around dot notation which
205206 // fixes https://github.com/sveltejs/prettier-plugin-svelte/issues/218
206- isTypeScript ( node ) ? 'typescript' : 'babel-ts' ,
207+ isTypeScript ( node ) ? 'typescript' : isJSON ( node ) ? 'json' : 'babel-ts' ,
207208 isTopLevel ,
208209 ) ;
209210 const embedStyle = ( isTopLevel : boolean ) =>
@@ -260,7 +261,7 @@ function getSnippedContent(node: Node) {
260261
261262async function formatBodyContent (
262263 content : string ,
263- parser : 'typescript' | 'babel-ts' | 'css' | 'scss' | 'less' | 'pug' ,
264+ parser : 'typescript' | 'babel-ts' | 'css' | 'scss' | 'less' | 'pug' | 'json' ,
264265 textToDoc : ( text : string , options : object ) => Promise < Doc > ,
265266 options : ParserOptions & { pugTabWidth ?: number } ,
266267) {
0 commit comments