1- import assert from "node:assert" ;
2-
31import {
42 group ,
53 hardline ,
@@ -13,6 +11,7 @@ import { printDanglingComments } from "../../main/comments/print.js";
1311import isNonEmptyArray from "../../utils/is-non-empty-array.js" ;
1412import UnexpectedNodeError from "../../utils/unexpected-node-error.js" ;
1513import { hasSameLoc , locEnd , locStart } from "../loc.js" ;
14+ import getTextWithoutComments from "../utils/get-text-without-comments.js" ;
1615import {
1716 CommentCheckFlags ,
1817 createTypeCheckFunction ,
@@ -249,35 +248,6 @@ function shouldPrintSpecifiers(node, options) {
249248 return text . trimEnd ( ) . endsWith ( "from" ) ;
250249}
251250
252- function getTextWithoutComments ( options , start , end ) {
253- let text = options . originalText . slice ( start , end ) ;
254-
255- for ( const comment of options [ Symbol . for ( "comments" ) ] ) {
256- const commentStart = locStart ( comment ) ;
257- // Comments are sorted, we can escape if the comment is after the range
258- if ( commentStart > end ) {
259- break ;
260- }
261-
262- const commentEnd = locEnd ( comment ) ;
263- if ( commentEnd < start ) {
264- continue ;
265- }
266-
267- const commentLength = commentEnd - commentStart ;
268- text =
269- text . slice ( 0 , commentStart - start ) +
270- " " . repeat ( commentLength ) +
271- text . slice ( commentEnd - start ) ;
272- }
273-
274- if ( process . env . NODE_ENV !== "production" ) {
275- assert ( text . length === end - start ) ;
276- }
277-
278- return text ;
279- }
280-
281251function getImportAttributesKeyword ( node , options ) {
282252 // Babel parser add this property to indicate the keyword is `assert`
283253 if ( node . extra ?. deprecatedAssertSyntax ) {
0 commit comments