Skip to content

Commit

Permalink
Fix: traverse ExperimentalSpread/RestProperty.argument (fixes eslin…
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jul 24, 2015
1 parent 83db585 commit 6c3d7e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/eslint.js
Expand Up @@ -33,6 +33,10 @@ estraverse.Syntax.ExperimentalRestProperty = "ExperimentalRestProperty";
estraverse.VisitorKeys.ExperimentalSpreadProperty = ["argument"];
estraverse.VisitorKeys.ExperimentalRestProperty = ["argument"];

// All nodes in ObjectExpression.properties and ObjectPattern.properties are visited as `Property`.
// See Also: https://github.com/estools/estraverse/blob/master/estraverse.js#L687-L688
estraverse.VisitorKeys.Property.push("argument");

/**
* Parses a list of "name:boolean_value" or/and "name" options divided by comma or
* whitespace.
Expand Down
9 changes: 8 additions & 1 deletion tests/lib/rules/no-undef.js
Expand Up @@ -71,6 +71,13 @@ eslintTester.addRuleTest("lib/rules/no-undef", {
{ code: "[a] = [0];", ecmaFeatures: {destructuring: true}, errors: [{ message: "\"a\" is not defined." }] },
{ code: "({a}) = {};", ecmaFeatures: {destructuring: true}, errors: [{ message: "\"a\" is not defined." }] },
{ code: "({b: a}) = {};", ecmaFeatures: {destructuring: true}, errors: [{ message: "\"a\" is not defined." }] },
{ code: "[obj.a, obj.b] = [0, 1];", ecmaFeatures: {destructuring: true}, errors: [{ message: "\"obj\" is not defined." }, { message: "\"obj\" is not defined." }] }
{ code: "[obj.a, obj.b] = [0, 1];", ecmaFeatures: {destructuring: true}, errors: [{ message: "\"obj\" is not defined." }, { message: "\"obj\" is not defined." }] },

// Experimental
{
code: "const c = 0; const a = {...b, c};",
ecmaFeatures: {blockBindings: true, objectLiteralShorthandProperties: true, experimentalObjectRestSpread: true},
errors: [{ message: "\"b\" is not defined." }]
}
]
});

0 comments on commit 6c3d7e4

Please sign in to comment.