Skip to content

RegExp parse errors in regexpp are not tolerated and crash eslint #12169

@Jessidhia

Description

@Jessidhia

Tell us about your environment

  • ESLint Version: 6.2.1
  • Node Version: 12.6.0
  • npm Version: yarn 1.17.3

What parser (default, Babel-ESLint, etc.) are you using?
@typescript-eslint/parser, but the crash is in the regexpp instance used by the no-misleading-character-class rule.

Please show your full configuration:

Configuration
// too big to share, but this in any file should be enough
/* eslint no-misleading-character-class: 1 */

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

/{/u

It happens on the command line as well but this is particularly bothersome with editor plugins (e.g. vscode integration), as you get plugin crash messages while typing up regexps.

What did you expect to happen?
No crash, at worst just an "invalid regexp" lint.

What actually happened? Please include the actual, raw output from ESLint.

[Error - 1:37:37 PM] SyntaxError: Invalid regular expression: /{/u: Lone quantifier brackets
Occurred while linting .../test.js:9
    at RegExpValidator.raise (.../node_modules/regexpp/index.js:5643:15)
    at RegExpValidator.disjunction (.../node_modules/regexpp/index.js:5747:18)
    at RegExpValidator.pattern (.../node_modules/regexpp/index.js:5681:14)
    at RegExpValidator.validatePattern (.../node_modules/regexpp/index.js:5461:14)
    at RegExpParser.parsePattern (.../node_modules/regexpp/index.js:6889:25)
    at verify (.../node_modules/eslint/lib/rules/no-misleading-character-class.js:134:40)
    at Literal[regex] (.../node_modules/eslint/lib/rules/no-misleading-character-class.js:168:17)
    at listeners.(anonymous function).forEach.listener (.../node_modules/eslint/lib/linter/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (.../node_modules/eslint/lib/linter/safe-emitter.js:45:38)

To be clear, this is indeed a syntax error, it's not a false positive on my input code; rather, it's an unhandled error happening inside the rule when a regexp is invalid.

Are you willing to submit a pull request to fix this bug?
Maybe, I don't know how this should be handled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyruleRelates to ESLint's core rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions