Skip to content

Commit

Permalink
[Fix] no-deprecated: fix crash on rest elements
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 2, 2021
1 parent 961df01 commit 79a4961
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -11,10 +11,12 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
### Fixed
* component detection: use `estraverse` to improve component detection ([#2992][] @Wesitos)
* [`destructuring-assignment`], [`no-multi-comp`], [`no-unstable-nested-components`], component detection: improve component detection ([#3001][] @vedadeepta)
* [`no-deprecated`]: fix crash on rest elements ([#3016][] @ljharb)

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

[#3016]: https://github.com/yannickcr/eslint-plugin-react/issues/3016
[#3006]: https://github.com/yannickcr/eslint-plugin-react/pull/3006
[#3001]: https://github.com/yannickcr/eslint-plugin-react/pull/3001
[#2998]: https://github.com/yannickcr/eslint-plugin-react/pull/2998
Expand Down
4 changes: 3 additions & 1 deletion lib/rules/no-deprecated.js
Expand Up @@ -211,7 +211,9 @@ module.exports = {
return;
}
node.id.properties.forEach((property) => {
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`);
if (property.type !== 'RestElement' && property.key) {
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`);
}
});
},

Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/no-deprecated.js
Expand Up @@ -103,6 +103,13 @@ ruleTester.run('no-deprecated', rule, {
}
`,
settings: {react: {version: '16.8.0'}}
},
{
code: `
import React from "react";
let { default: defaultReactExport, ...allReactExports } = React;
`
}
],

Expand Down

0 comments on commit 79a4961

Please sign in to comment.