@@ -17,7 +17,6 @@ import {
17
17
ESLintForOfStatement ,
18
18
ESLintFunctionExpression ,
19
19
ESLintPattern ,
20
- ESLintProgram ,
21
20
ESLintVariableDeclaration ,
22
21
ESLintUnaryExpression ,
23
22
HasLocation ,
@@ -39,6 +38,7 @@ import {
39
38
analyzeExternalReferences ,
40
39
analyzeVariablesAndExternalReferences ,
41
40
} from "./scope-analyzer"
41
+ import { ESLintCustomParser , getEspree } from "./espree"
42
42
43
43
// [1] = spacing before the aliases.
44
44
// [2] = aliases.
@@ -51,14 +51,6 @@ const DUMMY_PARENT: any = {}
51
51
const IS_FUNCTION_EXPRESSION = / ^ \s * ( [ \w $ _ ] + | \( [ ^ ) ] * ?\) ) \s * = > | ^ f u n c t i o n \s * \( / u
52
52
const IS_SIMPLE_PATH = / ^ [ A - Z a - z _ $ ] [ \w $ ] * (?: \. [ A - Z a - z _ $ ] [ \w $ ] * | \[ ' [ ^ ' ] * ?' \] | \[ " [ ^ " ] * ?" \] | \[ \d + \] | \[ [ A - Z a - z _ $ ] [ \w $ ] * \] ) * $ / u
53
53
54
- /**
55
- * The interface of ESLint custom parsers.
56
- */
57
- interface ESLintCustomParser {
58
- parse ( code : string , options : any ) : ESLintCustomParserResult
59
- parseForESLint ?( code : string , options : any ) : ESLintCustomParserResult
60
- }
61
-
62
54
/**
63
55
* Do post-process of parsing an expression.
64
56
*
@@ -548,11 +540,6 @@ export interface ExpressionParseResult<T extends Node> {
548
540
variables : Variable [ ]
549
541
}
550
542
551
- /**
552
- * The interface of a result of ESLint custom parser.
553
- */
554
- export type ESLintCustomParserResult = ESLintProgram | ESLintExtendedProgram
555
-
556
543
/**
557
544
* Parse the given source code.
558
545
*
@@ -568,8 +555,7 @@ export function parseScript(
568
555
typeof parserOptions . parser === "string"
569
556
? // eslint-disable-next-line @mysticatea/ts/no-require-imports
570
557
require ( parserOptions . parser )
571
- : // eslint-disable-next-line @mysticatea/ts/no-require-imports
572
- require ( "espree" )
558
+ : getEspree ( )
573
559
const result : any =
574
560
// eslint-disable-next-line @mysticatea/ts/unbound-method
575
561
typeof parser . parseForESLint === "function"
0 commit comments