This repository has been archived by the owner on May 19, 2018. It is now read-only.
Fix crash when exporting with destructuring and sparse array #170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there!
The tests for eslint-plugin-import are currently failing, with the
Cannot read property 'type' of null
error.I tracked down the error to Babylon and the new checks to whether a duplicate export exists, and have fixed it in this PR.
I have created a minimal viable example, which is available in my first commit, to show that the tests fail unexpectedly with the error message above. It looks like this
(Actually,
export const [,, a] = {}
would have sufficed, but I just noticed it, and have already updated theexpected.json
file in the tests, which took me a while 😅... let me know if you prefer I use this form instead, or add both cases in the tests)The problem is that the code here loops through the elements inside the destructuring expression, but forgets to filter out the
null
ones, that you get when you have a sparse array like[,,a]
, before directly accessing thetype
property.I added a null check around the recursive call, and that fixes the problem.
Let me know if you need more info, more work or anything else :)