From 68f64a9218341e5e9d83270c72587e1b413846de Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Sat, 12 Feb 2022 01:26:05 +0100 Subject: [PATCH] feat: update eslint-scope to ignore `"use strict"` directives in ES3 (#15595) * feat: update eslint-scope to ignore `"use strict"` directives in ES3 * update package.json with eslint-scope@7.1.1 --- package.json | 2 +- tests/lib/rules/no-eval.js | 7 +++++++ tests/lib/rules/no-invalid-this.js | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ddea098285..800cbc88dba 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.0", + "eslint-scope": "^7.1.1", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.3.0", "espree": "^9.3.1", diff --git a/tests/lib/rules/no-eval.js b/tests/lib/rules/no-eval.js index 79ba4a1eb11..b084892cf2e 100644 --- a/tests/lib/rules/no-eval.js +++ b/tests/lib/rules/no-eval.js @@ -139,6 +139,13 @@ ruleTester.run("no-eval", rule, { code: "class A { static {} [this.eval()]; }", parserOptions: { ecmaVersion: 2022 }, errors: [{ messageId: "unexpected" }] + }, + + // in es3, "use strict" directives do not apply + { + code: "function foo() { 'use strict'; this.eval(); }", + parserOptions: { ecmaVersion: 3 }, + errors: [{ messageId: "unexpected" }] } ] }); diff --git a/tests/lib/rules/no-invalid-this.js b/tests/lib/rules/no-invalid-this.js index 90cbdef98ac..6b54d9a965e 100644 --- a/tests/lib/rules/no-invalid-this.js +++ b/tests/lib/rules/no-invalid-this.js @@ -865,6 +865,14 @@ const patterns = [ valid: [NORMAL], invalid: [USE_STRICT, IMPLIED_STRICT, MODULES], errors: [{ messageId: "unexpectedThis", type: "ThisExpression" }] + }, + + // in es3, "use strict" directives do not apply + { + code: "function foo() { 'use strict'; this.eval(); }", + parserOptions: { ecmaVersion: 3 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT], + invalid: [] } ];