Skip to content

Commit

Permalink
import-style: Fix crash on babel-eslint parser (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Dec 7, 2020
1 parent cc85e2d commit 9f5f721
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rules/import-style.js
Expand Up @@ -81,7 +81,7 @@ const getActualAssignmentTargetImportStyles = assignmentTarget => {
const styles = new Set();

for (const property of assignmentTarget.properties) {
if (property.type === 'RestElement') {
if (property.type === 'RestElement' || property.type === 'ExperimentalRestProperty') {
styles.add('named');
continue;
}
Expand Down
20 changes: 20 additions & 0 deletions test/import-style.js
Expand Up @@ -598,6 +598,26 @@ test({
].map(test => addDefaultOptions(test))
});

test.babel({
valid: [
'const {...rest2} = require("named")'
],
invalid: [
{
code: 'const {...rest2} = require("unassigned")',
errors: [unassignedError]
},
{
code: 'const {...rest2} = require("default")',
errors: [defaultError]
},
{
code: 'const {...rest2} = require("namespace")',
errors: [namespaceError]
}
].map(test => addDefaultOptions(test))
});

test.visualize([
'import util from \'util\'',
'import * as util from \'util\'',
Expand Down

0 comments on commit 9f5f721

Please sign in to comment.