2
2
/* eslint-disable unicorn/no-await-expression-member */
3
3
import path from 'path'
4
4
5
- import type { Comment , Token } from 'acorn'
5
+ import type { Token } from 'acorn'
6
6
import { cosmiconfig } from 'cosmiconfig'
7
7
import type { CosmiconfigResult } from 'cosmiconfig/dist/types'
8
8
import type { AST } from 'eslint'
9
9
import type { EsprimaToken } from 'espree/lib/token-translator'
10
- import type { Comment as EsComment } from 'estree'
11
10
import type { Options } from 'micromark-extension-mdx-expression'
12
11
import { extractProperties , runAsWorker } from 'synckit'
13
12
import type { FrozenProcessor } from 'unified'
@@ -33,22 +32,17 @@ const explorer = cosmiconfig('remark', {
33
32
34
33
export const processorCache = new Map < string , FrozenProcessor > ( )
35
34
36
- const getRemarkMdxOptions = (
37
- tokens : Token [ ] ,
38
- comments : Comment [ ] ,
39
- ) : Options => ( {
35
+ const getRemarkMdxOptions = ( tokens : Token [ ] ) : Options => ( {
40
36
acornOptions : {
41
37
ecmaVersion : 'latest' ,
42
38
sourceType : 'module' ,
43
39
locations : true ,
44
40
ranges : true ,
45
41
onToken : tokens ,
46
- onComment : comments ,
47
42
} ,
48
43
} )
49
44
50
45
const sharedTokens : Token [ ] = [ ]
51
- const sharedComments : Comment [ ] = [ ]
52
46
53
47
export const getRemarkProcessor = async (
54
48
searchFrom : string ,
@@ -111,10 +105,7 @@ export const getRemarkProcessor = async (
111
105
. use ( remarkStringify )
112
106
113
107
if ( isMdx ) {
114
- initProcessor . use (
115
- remarkMdx ,
116
- getRemarkMdxOptions ( sharedTokens , sharedComments ) ,
117
- )
108
+ initProcessor . use ( remarkMdx , getRemarkMdxOptions ( sharedTokens ) )
118
109
}
119
110
120
111
cachedProcessor = (
@@ -136,10 +127,7 @@ export const getRemarkProcessor = async (
136
127
const initProcessor = remarkProcessor ( ) . use ( remarkStringify )
137
128
138
129
if ( isMdx ) {
139
- initProcessor . use (
140
- remarkMdx ,
141
- getRemarkMdxOptions ( sharedTokens , sharedComments ) ,
142
- )
130
+ initProcessor . use ( remarkMdx , getRemarkMdxOptions ( sharedTokens ) )
143
131
}
144
132
145
133
cachedProcessor = initProcessor . freeze ( )
@@ -161,7 +149,6 @@ runAsWorker(
161
149
ignoreRemarkConfig,
162
150
} : WorkerOptions ) : Promise < WorkerResult > => {
163
151
sharedTokens . length = 0
164
- sharedComments . length = 0
165
152
166
153
const processor = await getRemarkProcessor (
167
154
physicalFilename ,
@@ -250,7 +237,6 @@ runAsWorker(
250
237
return {
251
238
root,
252
239
tokens,
253
- comments : sharedComments as EsComment [ ] ,
254
240
}
255
241
} ,
256
242
)
0 commit comments