From 40452394cd81da0503f7ed8bdeba76e364675888 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Wed, 25 Jul 2018 15:57:40 +0900 Subject: [PATCH] Chore: fix a `require` expression to work with webpack --- src/script/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/script/index.ts b/src/script/index.ts index 4c4329ec..64d8747c 100644 --- a/src/script/index.ts +++ b/src/script/index.ts @@ -272,7 +272,10 @@ export function parseScript( code: string, parserOptions: any, ): ESLintExtendedProgram { - const parser: ESLintCustomParser = require(parserOptions.parser || "espree") //eslint-disable-line @mysticatea/ts/no-var-requires + const parser: ESLintCustomParser = + typeof parserOptions.parser === "string" + ? require(parserOptions.parser) + : require("espree") const result: any = typeof parser.parseForESLint === "function" ? parser.parseForESLint(code, parserOptions)