8000 Do not use custom parser for expressions · f-list/vue-eslint-parser@2cd08da · GitHub
[go: up one dir, main page]

Skip to content

Commit 2cd08da

Browse files
author
Maya
committed
Do not use custom parser for expressions
1 parent aa55d1c commit 2cd08da

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "vue-eslint-parser",
2+
"name": "@f-list/vue-eslint-parser",
33
"version": "7.6.0",
44
"description": "The ESLint custom parser for `.vue` files.",
55
"engines": {

src/script/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,10 @@ function parseScriptFragment(
189189
code: string,
190190
locationCalculator: LocationCalculator,
191191
parserOptions: ParserOptions,
192+
useSpecifiedParser = false
192193
): ESLintExtendedProgram {
193194
try {
194-
const result = parseScript(code, parserOptions)
195+
const result = parseScript(code, parserOptions, useSpecifiedParser)
195196
fixLocations(result, locationCalculator)
196197
return result
197198
} catch (err) {
@@ -520,9 +521,10 @@ export interface ExpressionParseResult<T extends Node> {
520521
export function parseScript(
521522
code: string,
522523
parserOptions: ParserOptions,
524+
useSpecifiedParser = false
523525
): ESLintExtendedProgram {
524526
const parser: ESLintCustomParser =
525-
typeof parserOptions.parser === "string"
527+
typeof parserOptions.parser === "string" && useSpecifiedParser
526528
? // eslint-disable-next-line @mysticatea/ts/no-require-imports
527529
require(parserOptions.parser)
528530
: getEspree()
@@ -558,7 +560,7 @@ export function parseScriptElement(
558560
const locationCalculator = globalLocationCalculator.getSubCalculatorAfter(
559561
offset,
560562
)
561-
const result = parseScriptFragment(code, locationCalculator, parserOptions)
563+
const result = parseScriptFragment(code, locationCalculator, parserOptions, true)
562564

563565
// Needs the tokens of start/end tags for `lines-around-*` rules to work
564566
// correctly.

0 commit comments

Comments
 (0)
0