fix: do not filter report from functions within class elements (#13106)
This commit is contained in:
parent
61e866f6b8
commit
7bc72bb451
@ -17,7 +17,13 @@ export default ruleComposer.filterReports(noInvalidThisRule, problem => {
|
||||
node.key.type === "PrivateIdentifier")
|
||||
) {
|
||||
inClassMember = true;
|
||||
return;
|
||||
break;
|
||||
} else if (
|
||||
node.type === "FunctionDeclaration" ||
|
||||
node.type === "FunctionExpression"
|
||||
) {
|
||||
inClassMember = false;
|
||||
break;
|
||||
}
|
||||
|
||||
node = node.parent;
|
||||
|
||||
@ -93,6 +93,30 @@ const patterns = [
|
||||
invalid: [],
|
||||
},
|
||||
|
||||
{
|
||||
code: "class A {a = () => { function b() { return this.b;} };};",
|
||||
parserOptions: { ecmaVersion: 6 },
|
||||
valid: [],
|
||||
invalid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
|
||||
errors: [
|
||||
{
|
||||
message: "Unexpected 'this'.",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
code: "class A {a = () => { (function b() { return this.b;}); };};",
|
||||
parserOptions: { ecmaVersion: 6 },
|
||||
valid: [],
|
||||
invalid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
|
||||
errors: [
|
||||
{
|
||||
message: "Unexpected 'this'.",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// Class Private methods
|
||||
{
|
||||
code: "class A {#a = this.b;};",
|
||||
@ -108,6 +132,30 @@ const patterns = [
|
||||
invalid: [],
|
||||
},
|
||||
|
||||
{
|
||||
code: "class A {#a = () => { function b() { return this.b;} };};",
|
||||
parserOptions: { ecmaVersion: 6 },
|
||||
valid: [],
|
||||
invalid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
|
||||
errors: [
|
||||
{
|
||||
message: "Unexpected 'this'.",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
code: "class A {#a = () => { (function b() { return this.b;}); };};",
|
||||
parserOptions: { ecmaVersion: 6 },
|
||||
valid: [],
|
||||
invalid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
|
||||
errors: [
|
||||
{
|
||||
message: "Unexpected 'this'.",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
code: "class A {#a() {return this.b;};};",
|
||||
parserOptions: { ecmaVersion: 6 },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user