babel/eslint/babel-eslint-plugin/rules/no-invalid-this.js
Nicolò Ribaudo b4c42601d1
Fix linting in ESLint packages (#10712)
* Lint eslint/*

* Run "make fix-js"

* Fix remaining problems

* Remove linting from subpackages

* Remove husky

* Add back eslint dep
2019-11-14 22:05:26 +01:00

22 lines
529 B
JavaScript

"use strict";
const ruleComposer = require("eslint-rule-composer");
const eslint = require("eslint");
const noInvalidThisRule = new eslint.Linter().getRules().get("no-invalid-this");
module.exports = ruleComposer.filterReports(noInvalidThisRule, problem => {
let inClassProperty = false;
let node = problem.node;
while (node) {
if (node.type === "ClassProperty" || node.type === "ClassPrivateProperty") {
inClassProperty = true;
return;
}
node = node.parent;
}
return !inClassProperty;
});