Skip to content

Commit

Permalink
Fix: no-invalid-regexp disallows \ at end of pattern (fixes #10861) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Oct 9, 2018
1 parent f85547a commit 5fe0e1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -66,7 +66,7 @@
"path-is-inside": "^1.0.2",
"pluralize": "^7.0.0",
"progress": "^2.0.0",
"regexpp": "^2.0.0",
"regexpp": "^2.0.1",
"require-uncached": "^1.0.3",
"semver": "^5.5.1",
"strip-ansi": "^4.0.0",
Expand Down
8 changes: 7 additions & 1 deletion tests/lib/rules/no-invalid-regexp.js
Expand Up @@ -46,6 +46,12 @@ ruleTester.run("no-invalid-regexp", rule, {
invalid: [
{ code: "RegExp('[');", errors: [{ message: "Invalid regular expression: /[/: Unterminated character class.", type: "CallExpression" }] },
{ code: "RegExp('.', 'z');", errors: [{ message: "Invalid flags supplied to RegExp constructor 'z'.", type: "CallExpression" }] },
{ code: "new RegExp(')');", errors: [{ message: "Invalid regular expression: /)/: Unmatched ')'.", type: "NewExpression" }] }
{ code: "new RegExp(')');", errors: [{ message: "Invalid regular expression: /)/: Unmatched ')'.", type: "NewExpression" }] },

// https://github.com/eslint/eslint/issues/10861
{
code: String.raw`new RegExp('\\');`,
errors: [{ message: "Invalid regular expression: /\\/: \\ at end of pattern.", type: "NewExpression" }]
}
]
});

0 comments on commit 5fe0e1a

Please sign in to comment.