Skip to content

Commit

Permalink
Merge pull request #549 from Galooshi/omitted-array-destructure
Browse files Browse the repository at this point in the history
Handle omitted array destructure
  • Loading branch information
trotzig authored Dec 10, 2019
2 parents 84e72bb + 29e1b88 commit 2a9c1a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/__tests__/findUndefinedIdentifiers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,9 @@ it('knows about object rest', () => {
const { a, ...theRest } = someObject;
`))).toEqual(new Set([]));
});

it('can handle omitted array destructure', () => {
expect(findUndefinedIdentifiers(parse(`
const [,bar] = foo();
`))).toEqual(new Set(['foo']));
});
3 changes: 3 additions & 0 deletions lib/visitIdentifierNodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export default function visitIdentifierNodes(

while (queue.length) {
current = queue.shift();
if (!current.node) {
continue; // eslint-disable-line
}
if (Array.isArray(current.node)) {
if (current.context.key === 'body') {
// A new scope has started. Copy whatever we have from the parent scope
Expand Down

0 comments on commit 2a9c1a9

Please sign in to comment.