@@ -254,7 +254,7 @@ function shouldPrintAttributes(node, options) {
254254 return false ;
255255 }
256256
257- if ( isNonEmptyArray ( node . attributes ) || isNonEmptyArray ( node . assertions ) ) {
257+ if ( isNonEmptyArray ( node . attributes ) ) {
258258 return true ;
259259 }
260260
@@ -296,24 +296,16 @@ function getTextWithoutComments(options, start, end) {
296296 return text ;
297297}
298298
299- function getImportAttributesOrAssertionsKeyword ( node , options ) {
300- if (
301- // Babel parser add this property to indicate the keyword is `assert`
302- node . extra ?. deprecatedAssertSyntax ||
303- ( isNonEmptyArray ( node . assertions ) && ! isNonEmptyArray ( node . attributes ) )
304- ) {
299+ function getImportAttributesKeyword ( node , options ) {
300+ // Babel parser add this property to indicate the keyword is `assert`
301+ if ( node . extra ?. deprecatedAssertSyntax ) {
305302 return "assert" ;
306303 }
307304
308- if ( ! isNonEmptyArray ( node . assertions ) && isNonEmptyArray ( node . attributes ) ) {
309- return "with" ;
310- }
311-
312- const firstAttribute = node . attributes ?. [ 0 ] ?? node . assertions ?. [ 0 ] ;
313305 const textBetweenSourceAndAttributes = getTextWithoutComments (
314306 options ,
315307 locEnd ( node . source ) ,
316- firstAttribute ? locStart ( firstAttribute ) : locEnd ( node ) ,
308+ node . attributes ?. [ 0 ] ? locStart ( node . attributes [ 0 ] ) : locEnd ( node ) ,
317309 ) ;
318310
319311 if ( textBetweenSourceAndAttributes . trimStart ( ) . startsWith ( "assert" ) ) {
@@ -323,32 +315,23 @@ function getImportAttributesOrAssertionsKeyword(node, options) {
323315 return "with" ;
324316}
325317
326- /**
327- * Print Import Attributes syntax.
328- * If old ImportAssertions syntax is used, print them here.
329- */
330318function printImportAttributes ( path , options , print ) {
331319 const { node } = path ;
332320
333321 if ( ! shouldPrintAttributes ( node , options ) ) {
334322 return "" ;
335323 }
336324
337- const keyword = getImportAttributesOrAssertionsKeyword ( node , options ) ;
325+ const keyword = getImportAttributesKeyword ( node , options ) ;
338326 /** @type {Doc[] } */
339327 const parts = [ ` ${ keyword } {` ] ;
340328
341- const property = isNonEmptyArray ( node . attributes )
342- ? "attributes"
343- : isNonEmptyArray ( node . assertions )
344- ? "assertions"
345- : undefined ;
346- if ( property ) {
329+ if ( isNonEmptyArray ( node . attributes ) ) {
347330 if ( options . bracketSpacing ) {
348331 parts . push ( " " ) ;
349332 }
350333
351- parts . push ( join ( ", " , path . map ( print , property ) ) ) ;
334+ parts . push ( join ( ", " , path . map ( print , "attributes" ) ) ) ;
352335
353336 if ( options . bracketSpacing ) {
354337 parts . push ( " " ) ;
0 commit comments