From 5ac55342a8c5e749440fa44e483164a9a4a095d3 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Wed, 30 Dec 2020 04:23:37 +0100 Subject: [PATCH] Update: use regexpp's default ecmaVersion in no-control-regex --- lib/rules/no-control-regex.js | 1 - tests/lib/rules/no-control-regex.js | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-control-regex.js b/lib/rules/no-control-regex.js index 146c4f22d01..6feeb6419d5 100644 --- a/lib/rules/no-control-regex.js +++ b/lib/rules/no-control-regex.js @@ -8,7 +8,6 @@ const RegExpValidator = require("regexpp").RegExpValidator; const collector = new (class { constructor() { - this.ecmaVersion = 2018; this._source = ""; this._controlChars = []; this._validator = new RegExpValidator(this); diff --git a/tests/lib/rules/no-control-regex.js b/tests/lib/rules/no-control-regex.js index 19b66e802c5..059e50dc4e7 100644 --- a/tests/lib/rules/no-control-regex.js +++ b/tests/lib/rules/no-control-regex.js @@ -41,6 +41,11 @@ ruleTester.run("no-control-regex", rule, { code: "var regex = /(?\\x1f)/", parserOptions: { ecmaVersion: 2018 }, errors: [{ messageId: "unexpected", data: { controlChars: "\\x1f" }, type: "Literal" }] + }, + { + code: String.raw`var regex = /(?<\u{1d49c}>.)\x1f/`, + parserOptions: { ecmaVersion: 2020 }, + errors: [{ messageId: "unexpected", data: { controlChars: "\\x1f" }, type: "Literal" }] } ] });