Skip to content

Commit

Permalink
Fix flow type spread handling (babel/babel-eslint#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
zertosh committed Apr 21, 2017
1 parent b5c058b commit 6feaee8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
7 changes: 5 additions & 2 deletions eslint/babel-eslint-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function monkeypatch(modules) {
// loops
callProperties: { type: "loop", values: ["value"] },
indexers: { type: "loop", values: ["key", "value"] },
properties: { type: "loop", values: ["value"] },
properties: { type: "loop", values: ["argument", "value"] },
types: { type: "loop" },
params: { type: "loop" },
// single property
Expand Down Expand Up @@ -142,7 +142,10 @@ function monkeypatch(modules) {
for (var j = 0; j < nodeProperty.length; j++) {
if (Array.isArray(propertyType.values)) {
for (var k = 0; k < propertyType.values.length; k++) {
checkIdentifierOrVisit.call(this, nodeProperty[j][propertyType.values[k]]);
var loopPropertyNode = nodeProperty[j][propertyType.values[k]];
if (loopPropertyNode) {
checkIdentifierOrVisit.call(this, loopPropertyNode);
}
}
} else {
checkIdentifierOrVisit.call(this, nodeProperty[j]);
Expand Down
2 changes: 1 addition & 1 deletion eslint/babel-eslint-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"babel-code-frame": "^6.22.0",
"babel-traverse": "^6.23.1",
"babel-types": "^6.23.0",
"babylon": "^6.16.1"
"babylon": "^6.17.0"
},
"scripts": {
"test": "npm run lint && npm run test-only",
Expand Down
12 changes: 12 additions & 0 deletions eslint/babel-eslint-parser/test/non-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,18 @@ describe("verify", () => {
);
});

it("supports type spreading", () => {
verifyAndAssertMessages(
unpad(`
type U = {};
type T = {a: number, ...U, ...V};
`),
{ "no-undef": 1, "no-unused-vars": 1 },
[ "2:6 'T' is defined but never used. no-unused-vars",
"2:31 'V' is not defined. no-undef" ]
);
});

it("1", () => {
verifyAndAssertMessages(
unpad(`
Expand Down
6 changes: 3 additions & 3 deletions eslint/babel-eslint-parser/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ babel-types@^6.15.0, babel-types@^6.23.0:
lodash "^4.2.0"
to-fast-properties "^1.0.1"

babylon@^6.13.0, babylon@^6.15.0, babylon@^6.16.1:
version "6.16.1"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3"
babylon@^6.13.0, babylon@^6.15.0, babylon@^6.17.0:
version "6.17.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932"

balanced-match@^0.4.1:
version "0.4.2"
Expand Down

0 comments on commit 6feaee8

Please sign in to comment.