Skip to content

Commit 158f4e8

Browse files
authored
Merge pull request #1039 from preco21/namespace-crash-fix
#656: Fix crashes that caused when using object-rest properties in `namespace` rule
2 parents 196c238 + 1a084cc commit 158f4e8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/rules/namespace.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ module.exports = {
161161
if (pattern.type !== 'ObjectPattern') return
162162

163163
for (let property of pattern.properties) {
164+
if (property.type === 'ExperimentalRestProperty') {
165+
continue
166+
}
164167

165168
if (property.key.type !== 'Identifier') {
166169
context.report({

tests/src/rules/namespace.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ const valid = [
9292
options: [{ allowComputed: true }],
9393
}),
9494

95+
// #656: should handle object-rest properties
96+
test({
97+
code: `import * as names from './named-exports'; const {a, b, ...rest} = names;`,
98+
parserOptions: {
99+
ecmaFeatures: {
100+
experimentalObjectRestSpread: true,
101+
},
102+
},
103+
}),
104+
test({
105+
code: `import * as names from './named-exports'; const {a, b, ...rest} = names;`,
106+
parser: 'babel-eslint',
107+
}),
108+
95109
...SYNTAX_CASES,
96110
]
97111

0 commit comments

Comments
 (0)