From 3d901f59608c1175325362dffd9231021cdb6e47 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Mon, 23 Nov 2015 20:33:39 -0500 Subject: [PATCH] Merge pull request babel/babel-eslint#212 from evocateur/fix-with-latest-eslint Avoid errors with eslint 1.10.x when excluding destructured properties --- eslint/babel-eslint-parser/index.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/eslint/babel-eslint-parser/index.js b/eslint/babel-eslint-parser/index.js index f87d13240a..5a4958fc77 100644 --- a/eslint/babel-eslint-parser/index.js +++ b/eslint/babel-eslint-parser/index.js @@ -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]); } } }