Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update eslint-scope to ignore "use strict" directives in ES3 #15595

Merged
merged 2 commits into from Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.2.0",
"espree": "^9.3.0",
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