Added linting support for private class methods (#11993)
* Added linting support for private class methods * Renamed variable * Renamed variable
This commit is contained in:
parent
76d571e285
commit
304eea4133
@ -4,17 +4,21 @@ import eslint from "eslint";
|
||||
const noInvalidThisRule = new eslint.Linter().getRules().get("no-invalid-this");
|
||||
|
||||
export default ruleComposer.filterReports(noInvalidThisRule, problem => {
|
||||
let inClassProperty = false;
|
||||
let inClassMember = false;
|
||||
let node = problem.node;
|
||||
|
||||
while (node) {
|
||||
if (node.type === "ClassProperty" || node.type === "ClassPrivateProperty") {
|
||||
inClassProperty = true;
|
||||
if (
|
||||
node.type === "ClassPrivateMethod" ||
|
||||
node.type === "ClassPrivateProperty" ||
|
||||
node.type === "ClassProperty"
|
||||
) {
|
||||
inClassMember = true;
|
||||
return;
|
||||
}
|
||||
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
return !inClassProperty;
|
||||
return !inClassMember;
|
||||
});
|
||||
|
||||
@ -107,6 +107,13 @@ const patterns = [
|
||||
valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
|
||||
invalid: [],
|
||||
},
|
||||
|
||||
{
|
||||
code: "class A {#a() {return this.b;};};",
|
||||
parserOptions: { ecmaVersion: 6 },
|
||||
valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
|
||||
invalid: [],
|
||||
},
|
||||
];
|
||||
|
||||
const ruleTester = new RuleTester();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user