From 535fe47fee6544b4957378f9408117c8318d4762 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Fri, 1 Jan 2021 19:11:00 +0100 Subject: [PATCH] Update: use regexpp's default ecmaVersion in no-control-regex (#13969) --- 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" }] } ] });