Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
Remove left over eslint 2 estraverse code (#452)
Browse files Browse the repository at this point in the history
This was missed in #361
  • Loading branch information
zertosh authored and hzoo committed Mar 23, 2017
1 parent b5fb53b commit 5626de1
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions index.js
Expand Up @@ -36,17 +36,12 @@ function monkeypatch() {

// get modules relative to what eslint will load
var eslintMod = createModule(eslintLoc);
// contains all the instances of estraverse so we can modify them if necessary
var estraverses = [];
// ESLint v1.9.0 uses estraverse directly to work around https://github.com/npm/npm/issues/9663
var estraverseOfEslint = eslintMod.require("estraverse");
estraverses.push(estraverseOfEslint);
Object.assign(estraverseOfEslint.VisitorKeys, t.VISITOR_KEYS);
var estraverse = eslintMod.require("estraverse");

estraverses.forEach((estraverse) => {
estraverse.VisitorKeys.MethodDefinition.push("decorators");
estraverse.VisitorKeys.Property.push("decorators");
});
Object.assign(estraverse.VisitorKeys, t.VISITOR_KEYS);
estraverse.VisitorKeys.MethodDefinition.push("decorators");
estraverse.VisitorKeys.Property.push("decorators");

// monkeypatch escope
var escopeLoc = Module._resolveFilename("escope", eslintMod);
Expand Down Expand Up @@ -275,16 +270,12 @@ function monkeypatch() {
}
// set ArrayPattern/ObjectPattern visitor keys back to their original. otherwise
// escope will traverse into them and include the identifiers within as declarations
estraverses.forEach((estraverse) => {
estraverse.VisitorKeys.ObjectPattern = ["properties"];
estraverse.VisitorKeys.ArrayPattern = ["elements"];
});
estraverse.VisitorKeys.ObjectPattern = ["properties"];
estraverse.VisitorKeys.ArrayPattern = ["elements"];
visitFunction.call(this, node);
// set them back to normal...
estraverses.forEach((estraverse) => {
estraverse.VisitorKeys.ObjectPattern = t.VISITOR_KEYS.ObjectPattern;
estraverse.VisitorKeys.ArrayPattern = t.VISITOR_KEYS.ArrayPattern;
});
estraverse.VisitorKeys.ObjectPattern = t.VISITOR_KEYS.ObjectPattern;
estraverse.VisitorKeys.ArrayPattern = t.VISITOR_KEYS.ArrayPattern;
if (typeParamScope) {
this.close(node);
}
Expand Down

0 comments on commit 5626de1

Please sign in to comment.