Support private properties in no-invalid-this (babel/eslint-plugin-babel#183)
* add failing test * support ClassPrivateProperty
This commit is contained in:
parent
693fa1aa0d
commit
f3e2752df3
@ -5,17 +5,18 @@ const eslint = require('eslint');
|
||||
const noInvalidThisRule = new eslint.Linter().getRules().get('no-invalid-this');
|
||||
|
||||
module.exports = ruleComposer.filterReports(
|
||||
noInvalidThisRule,
|
||||
noInvalidThisRule,
|
||||
(problem, metadata) => {
|
||||
let inClassProperty = false;
|
||||
let node = problem.node;
|
||||
|
||||
while (node) {
|
||||
if (node.type === "ClassProperty") {
|
||||
if (node.type === "ClassProperty" ||
|
||||
node.type === "ClassPrivateProperty") {
|
||||
inClassProperty = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
|
||||
@ -602,6 +602,21 @@ const patterns = [
|
||||
valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
|
||||
invalid: []
|
||||
},
|
||||
|
||||
// Class Private Instance Properties.
|
||||
{
|
||||
code: "class A {#a = this.b;};",
|
||||
parserOptions: { ecmaVersion: 6 },
|
||||
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