From f30c01a2cc9a22488ca715f993a4a32d43d6c838 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Wed, 9 Feb 2022 18:41:09 +0100 Subject: [PATCH 1/2] feat: update eslint-scope to ignore `"use strict"` directives in ES3 --- 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 ff67418ec46..df6abbdf4aa 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": "github:eslint/eslint-scope#prepare-7.1.1", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.2.0", "espree": "^9.3.0", 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: [] } ]; From 09dee8c9aa4c5a54063a504f1c56dbccf84a0c36 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Sat, 12 Feb 2022 01:09:52 +0100 Subject: [PATCH 2/2] update package.json with eslint-scope@7.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df6abbdf4aa..9d2da54311f 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": "github:eslint/eslint-scope#prepare-7.1.1", + "eslint-scope": "^7.1.1", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.2.0", "espree": "^9.3.0",