Skip to content

Commit

Permalink
feat: update eslint-scope to ignore "use strict" directives in ES3 (#…
Browse files Browse the repository at this point in the history
…15595)

* feat: update eslint-scope to ignore `"use strict"` directives in ES3

* update package.json with eslint-scope@7.1.1
  • Loading branch information
mdjermanovic committed Feb 12, 2022
1 parent db57639 commit 68f64a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/no-eval.js
Expand Up @@ -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" }]
}
]
});
8 changes: 8 additions & 0 deletions tests/lib/rules/no-invalid-this.js
Expand Up @@ -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: []
}
];

Expand Down

0 comments on commit 68f64a9

Please sign in to comment.