diff --git a/eslint/babel-eslint-parser/index.js b/eslint/babel-eslint-parser/index.js index 67ec4e5337..0cabbb85c7 100644 --- a/eslint/babel-eslint-parser/index.js +++ b/eslint/babel-eslint-parser/index.js @@ -298,18 +298,6 @@ function monkeypatch() { if (typeAnnotation) { checkIdentifierOrVisit.call(this, typeAnnotation); } - if (id.type === "ObjectPattern") { - // check if object destructuring has a spread - var hasSpread = id.properties.filter(function(p) { - return p._babelType === "SpreadProperty" || p._babelType === "RestProperty"; - }); - // visit properties if so - if (hasSpread.length > 0) { - for (var j = 0; j < id.properties.length; j++) { - this.visit(id.properties[j]); - } - } - } } } variableDeclaration.call(this, node); diff --git a/eslint/babel-eslint-parser/test/non-regression.js b/eslint/babel-eslint-parser/test/non-regression.js index 11be9483d1..e34e9f506b 100644 --- a/eslint/babel-eslint-parser/test/non-regression.js +++ b/eslint/babel-eslint-parser/test/non-regression.js @@ -1137,18 +1137,45 @@ describe("verify", function () { ); }); - it("visits excluded properties left of spread #95", function () { + // This two tests are disabled, as the feature to visit properties when + // there is a spread/rest operator has been removed as it caused problems + // with other rules #249 + it.skip("visits excluded properties left of spread #95", function () { verifyAndAssertMessages( "var originalObject = {}; var {field1, field2, ...clone} = originalObject;", - { "no-undef": 1, "no-unused-vars": 1, "no-redeclare": 1 }, + { "no-unused-vars": 1 }, [] ); }); - it("visits excluded properties left of spread #210", function () { + it.skip("visits excluded properties left of spread #210", function () { verifyAndAssertMessages( "const props = { yo: 'yo' }; const { ...otherProps } = props;", - { "no-undef": 1, "no-unused-vars": 1, "no-redeclare": 1 }, + { "no-unused-vars": 1 }, + [] + ); + }); + + it("does not mark spread variables false-positive", function () { + verifyAndAssertMessages( + "var originalObject = {}; var {field1, field2, ...clone} = originalObject;", + { "no-undef": 1, "no-redeclare": 1 }, + [] + ); + }); + + it("does not mark spread variables false-positive", function () { + verifyAndAssertMessages( + "const props = { yo: 'yo' }; const { ...otherProps } = props;", + { "no-undef": 1, "no-redeclare": 1 }, + [] + ); + }); + + it("does not mark spread variables as use-before-define #249", function () { + verifyAndAssertMessages( + "var originalObject = {}; var {field1, field2, ...clone} = originalObject;", + { "no-use-before-define": 1 }, [] ); });