Skip to content

Infinite loop when linting Vue file containing TypeScript keyword #136

@MatthiasKunnen

Description

@MatthiasKunnen

The @typescript-eslint/parser is stuck in an infinite loop when it encounters the words static class in the attributes of an element in a template of another file. Yes, this bug is weird.

Reproduction
https://github.com/MatthiasKunnen/eslint-vue-ts-keyword

Examples of failing code:

<template>
    <div style="display: none"
         static
         class=""
    >
    </div>
</template>
<template>
  <div data-test="
        static
        class">
  </div>
</template>

Result
Eslint crashes with FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory.
Error log

Please check the reproduction repo for a more in-depth explanation and examples.

If I had to guess, the problem is that typescript-estree:createWatchProgram parses all files that are mentioned in the tsconfig's include property which makes it attempt to parse the tags which causes the infinite loop. This despite the parser being set to <template>: espree in the ESLint config. Now the question is if this can be avoided.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions