Merge pull request babel/babel-eslint#146 from hzoo/i-142-2

use node.babelType for SpreadProperty
This commit is contained in:
Henry Zhu 2015-07-06 10:40:11 -04:00
parent f57dde1ac3
commit 05f5cc3ea8
2 changed files with 5 additions and 3 deletions

View File

@ -170,10 +170,12 @@ function convertTemplateType(tokens) {
var astTransformVisitor = {
noScope: true,
enter: function (node) {
// private var to track original node type
node._babelType = node.type;
},
exit: function (node) { /* parent */
if (this.isSpreadProperty()) {
// private var to track if it's a spread property
node._spread = true;
node.type = "Property";
node.kind = "init";
node.computed = true;

View File

@ -266,7 +266,7 @@ function monkeypatch() {
if (id.type === "ObjectPattern") {
// check if object destructuring has a spread
var hasSpread = id.properties.filter(function(p) {
return p._spread === true;
return p._babelType === "SpreadProperty";
});
// visit properties if so
if (hasSpread.length > 0) {