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

Commit

Permalink
Avoid errors in eslint 1.10.x when excluding destructured properties.
Browse files Browse the repository at this point in the history
Despite the improvements from #209 with the pattern visitor, it doesn't
actually iterate over the Property node siblings of the SpreadProperty.
Thus, the "ignore properties left of spread" fix in #95 regressed.

Restoring the "old" path of looping over all properties of an ObjectPattern
that contains a SpreadProperty avoids the regression. It seems inelegant,
but I don't have enough insight into the referencer to propose an alternative.
  • Loading branch information
Daniel Stockman committed Nov 23, 2015
1 parent 0af8736 commit 0d8953d
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,18 +295,15 @@ function monkeypatch() {
if (typeAnnotation) {
checkIdentifierOrVisit.call(this, typeAnnotation);
}
if (!patternVisitor) {
// Old method. Once escope in eslint is updated, this code is not necessary.
if (id.type === "ObjectPattern") {
// check if object destructuring has a spread
var hasSpread = id.properties.filter(function(p) {
return p._babelType === "SpreadProperty";
});
// visit properties if so
if (hasSpread.length > 0) {
for (var j = 0; j < id.properties.length; j++) {
this.visit(id.properties[j]);
}
if (id.type === "ObjectPattern") {
// check if object destructuring has a spread
var hasSpread = id.properties.filter(function(p) {
return p._babelType === "SpreadProperty";
});
// visit properties if so
if (hasSpread.length > 0) {
for (var j = 0; j < id.properties.length; j++) {
this.visit(id.properties[j]);
}
}
}
Expand Down

0 comments on commit 0d8953d

Please sign in to comment.