Skip to content

Commit d0b5196

Browse files
committed
[Fix] no-deprecated: fix crash on rest elements
Fixes #3016
1 parent f74be29 commit d0b5196

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1111
### Fixed
1212
* component detection: use `estraverse` to improve component detection ([#2992][] @Wesitos)
1313
* [`destructuring-assignment`], [`no-multi-comp`], [`no-unstable-nested-components`], component detection: improve component detection ([#3001][] @vedadeepta)
14+
* [`no-deprecated`]: fix crash on rest elements ([#3016][] @ljharb)
1415

1516
### Changed
1617
* [Docs] [`jsx-no-bind`]: updates discussion of refs ([#2998][] @dimitropoulos)
1718

19+
[#3016]: https://github.com/yannickcr/eslint-plugin-react/issues/3016
1820
[#3006]: https://github.com/yannickcr/eslint-plugin-react/pull/3006
1921
[#3001]: https://github.com/yannickcr/eslint-plugin-react/pull/3001
2022
[#2998]: https://github.com/yannickcr/eslint-plugin-react/pull/2998

lib/rules/no-deprecated.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ module.exports = {
211211
return;
212212
}
213213
node.id.properties.forEach((property) => {
214-
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`);
214+
if (property.type !== 'RestElement' && property.key) {
215+
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`);
216+
}
215217
});
216218
},
217219

tests/lib/rules/no-deprecated.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ ruleTester.run('no-deprecated', rule, {
103103
}
104104
`,
105105
settings: {react: {version: '16.8.0'}}
106+
},
107+
{
108+
code: `
109+
import React from "react";
110+
111+
let { default: defaultReactExport, ...allReactExports } = React;
112+
`
106113
}
107114
],
108115

0 commit comments

Comments
 (0)