eslint: no-invalid-regexp rule doesn't error with example from its documentation

Tell us about your environment

  • ESLint Version: 5.6.0
  • Node Version: 8.12.0
  • npm Version: 6.3.0

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
{
  "env": {
    "es6": true,
    "node": true
  },
  "parserOptions": {
    "ecmaVersion": 2017
  },
  "rules": {
    "no-invalid-regexp": "error"
  }
}

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

// like in the no-invalid-regexp documentation:
// https://github.com/eslint/eslint/blob/master/docs/rules/no-invalid-regexp.md#rule-details
new RegExp('\\');
eslint file.js

What did you expect to happen?

eslint failing with an error from the no-invalid-regexp rule.

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

eslint passed with no output.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@sstern6 It looks like the fix has already been published as a new version of regexpp. https://github.com/eslint/eslint/pull/10920 has the effect of upgrading regexpp and adding a test, as you suggested.

I’m sorry, I misread it as // šŸ˜…

When I run that code, I get an error:

SyntaxError: Invalid regular expression: /\/: \ at end of pattern