Skip to content

Commit

Permalink
Merge pull request #1039 from preco21/namespace-crash-fix
Browse files Browse the repository at this point in the history
#656: Fix crashes that caused when using object-rest properties in `namespace` rule
  • Loading branch information
ljharb authored Mar 7, 2018
2 parents 196c238 + 1a084cc commit 158f4e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/rules/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ module.exports = {
if (pattern.type !== 'ObjectPattern') return

for (let property of pattern.properties) {
if (property.type === 'ExperimentalRestProperty') {
continue
}

if (property.key.type !== 'Identifier') {
context.report({
Expand Down
14 changes: 14 additions & 0 deletions tests/src/rules/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ const valid = [
options: [{ allowComputed: true }],
}),

// #656: should handle object-rest properties
test({
code: `import * as names from './named-exports'; const {a, b, ...rest} = names;`,
parserOptions: {
ecmaFeatures: {
experimentalObjectRestSpread: true,
},
},
}),
test({
code: `import * as names from './named-exports'; const {a, b, ...rest} = names;`,
parser: 'babel-eslint',
}),

...SYNTAX_CASES,
]

Expand Down

0 comments on commit 158f4e8

Please sign in to comment.