@@ -17,7 +17,6 @@ import {
1717 ESLintForOfStatement ,
1818 ESLintFunctionExpression ,
1919 ESLintPattern ,
20- ESLintProgram ,
2120 ESLintVariableDeclaration ,
2221 ESLintUnaryExpression ,
2322 HasLocation ,
@@ -39,6 +38,7 @@ import {
3938 analyzeExternalReferences ,
4039 analyzeVariablesAndExternalReferences ,
4140} from "./scope-analyzer"
41+ import { ESLintCustomParser , getEspree } from "./espree"
4242
4343// [1] = spacing before the aliases.
4444// [2] = aliases.
@@ -51,14 +51,6 @@ const DUMMY_PARENT: any = {}
5151const IS_FUNCTION_EXPRESSION = / ^ \s * ( [ \w $ _ ] + | \( [ ^ ) ] * ?\) ) \s * = > | ^ f u n c t i o n \s * \( / u
5252const IS_SIMPLE_PATH = / ^ [ A - Z a - z _ $ ] [ \w $ ] * (?: \. [ A - Z a - z _ $ ] [ \w $ ] * | \[ ' [ ^ ' ] * ?' \] | \[ " [ ^ " ] * ?" \] | \[ \d + \] | \[ [ A - Z a - z _ $ ] [ \w $ ] * \] ) * $ / u
5353
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-
6254/**
6355 * Do post-process of parsing an expression.
6456 *
@@ -548,11 +540,6 @@ export interface ExpressionParseResult<T extends Node> {
548540 variables : Variable [ ]
549541}
550542
551- /**
552- * The interface of a result of ESLint custom parser.
553- */
554- export type ESLintCustomParserResult = ESLintProgram | ESLintExtendedProgram
555-
556543/**
557544 * Parse the given source code.
558545 *
@@ -568,8 +555,7 @@ export function parseScript(
568555 typeof parserOptions . parser === "string"
569556 ? // eslint-disable-next-line @mysticatea/ts/no-require-imports
570557 require ( parserOptions . parser )
571- : // eslint-disable-next-line @mysticatea/ts/no-require-imports
572- require ( "espree" )
558+ : getEspree ( )
573559 const result : any =
574560 // eslint-disable-next-line @mysticatea/ts/unbound-method
575561 typeof parser . parseForESLint === "function"
0 commit comments