diff --git a/CHANGELOG.md b/CHANGELOG.md index df28f81c03..394a0db3f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index 6d2c9dd138..1f13eb6055 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -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}`); + } }); }, diff --git a/tests/lib/rules/no-deprecated.js b/tests/lib/rules/no-deprecated.js index 0fefff3f20..b5380ad04b 100644 --- a/tests/lib/rules/no-deprecated.js +++ b/tests/lib/rules/no-deprecated.js @@ -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; + ` } ],