@@ -5,7 +5,6 @@ import type { AST, Linter } from 'eslint'
5
5
import remarkMdx from 'remark-mdx'
6
6
import remarkParse from 'remark-parse'
7
7
import unified from 'unified'
8
- import type { Node , Parent } from 'unist'
9
8
10
9
import {
11
10
arrayify ,
@@ -26,6 +25,8 @@ import { traverse } from './traverse'
26
25
import type {
27
26
Comment ,
28
27
LocationError ,
28
+ Node ,
29
+ Parent ,
29
30
ParserFn ,
30
31
ParserOptions ,
31
32
ParserServices ,
@@ -47,7 +48,8 @@ export const DEFAULT_PARSER_OPTIONS: ParserOptions = {
47
48
ecmaFeatures : {
48
49
jsx : true ,
49
50
} ,
50
- ecmaVersion : new Date ( ) . getUTCFullYear ( ) as Linter . ParserOptions [ 'ecmaVersion' ] ,
51
+ ecmaVersion :
52
+ new Date ( ) . getUTCFullYear ( ) as Linter . ParserOptions [ 'ecmaVersion' ] ,
51
53
sourceType : 'module' ,
52
54
tokens : true ,
53
55
filePath : '__placeholder__.mdx' ,
@@ -80,7 +82,7 @@ export class Parser {
80
82
}
81
83
82
84
normalizeJsxNode ( node : Node , parent ?: Parent , options = this . _options ) {
83
- const value = node . value as string
85
+ const value = node . value
84
86
85
87
if ( node . type !== 'jsx' || isComment ( value ) ) {
86
88
return node
@@ -235,9 +237,9 @@ export class Parser {
235
237
}
236
238
237
239
/* istanbul ignore next */
238
- return ( 'ast' in program && program . ast
239
- ? program
240
- : { ast : program } ) as Linter . ESLintParseResult
240
+ return (
241
+ 'ast' in program && program . ast ? program : { ast : program }
242
+ ) as Linter . ESLintParseResult
241
243
}
242
244
243
245
// fix adjacent JSX nodes
@@ -247,7 +249,7 @@ export class Parser {
247
249
node : Node ,
248
250
options : ParserOptions ,
249
251
) : Node | Node [ ] {
250
- const value = node . value as string
252
+ const value = node . value
251
253
252
254
let program : AST . Program
253
255
@@ -281,7 +283,7 @@ export class Parser {
281
283
return node
282
284
}
283
285
284
- const { expression } = ( program . body [ 0 ] as unknown ) as ExpressionStatement
286
+ const { expression } = program . body [ 0 ] as unknown as ExpressionStatement
285
287
286
288
if ( ! isJsxNode ( expression ) || expression . children . length <= 1 ) {
287
289
return node
@@ -339,7 +341,7 @@ export class Parser {
339
341
this . _services . JSXElementsWithHTMLComments . push ( node )
340
342
}
341
343
342
- const value = node . value as string
344
+ const value = node . value
343
345
344
346
const { loc, start, end } = normalizePosition ( node . position )
345
347
0 commit comments