1
- import assert from "node:assert" ;
2
-
3
1
import {
4
2
group ,
5
3
hardline ,
@@ -13,6 +11,7 @@ import { printDanglingComments } from "../../main/comments/print.js";
13
11
import isNonEmptyArray from "../../utils/is-non-empty-array.js" ;
14
12
import UnexpectedNodeError from "../../utils/unexpected-node-error.js" ;
15
13
import { hasSameLoc , locEnd , locStart } from "../loc.js" ;
14
+ import getTextWithoutComments from "../utils/get-text-without-comments.js" ;
16
15
import {
17
16
CommentCheckFlags ,
18
17
createTypeCheckFunction ,
@@ -249,35 +248,6 @@ function shouldPrintSpecifiers(node, options) {
249
248
return text . trimEnd ( ) . endsWith ( "from" ) ;
250
249
}
251
250
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
-
281
251
function getImportAttributesKeyword ( node , options ) {
282
252
// Babel parser add this property to indicate the keyword is `assert`
283
253
if ( node . extra ?. deprecatedAssertSyntax ) {
0 commit comments