Skip to content

Commit 4045239

Browse files
committed
Chore: fix a require expression to work with webpack
1 parent a6156b8 commit 4045239

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/script/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ export function parseScript(
272272
code: string,
273273
parserOptions: any,
274274
): ESLintExtendedProgram {
275-
const parser: ESLintCustomParser = require(parserOptions.parser || "espree") //eslint-disable-line @mysticatea/ts/no-var-requires
275+
const parser: ESLintCustomParser =
276+
typeof parserOptions.parser === "string"
277+
? require(parserOptions.parser)
278+
: require("espree")
276279
const result: any =
277280
typeof parser.parseForESLint === "function"
278281
? parser.parseForESLint(code, parserOptions)

0 commit comments

Comments
 (0)