Skip to content

Commit

Permalink
[Refactor] destructuring-assignment: use getParentStatelessComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot authored and ljharb committed Sep 29, 2024
1 parent ae6fb8d commit 96d46d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## Unreleased

### Changed
* [Refactor] [`destructuring-assignment`]: use `getParentStatelessComponent` ([#3835][] @golopot)

[#3835]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3835

## [7.37.1] - 2024.10.01

### Fixed
Expand Down
7 changes: 1 addition & 6 deletions lib/rules/destructuring-assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,7 @@ module.exports = {
'FunctionExpression:exit': handleStatelessComponentExit,

MemberExpression(node) {
let scope = getScope(context, node);
let SFCComponent = components.get(scope.block);
while (!SFCComponent && scope.upper && scope.upper !== scope) {
SFCComponent = components.get(scope.upper.block);
scope = scope.upper;
}
const SFCComponent = utils.getParentStatelessComponent(node);
if (SFCComponent) {
handleSFCUsage(node);
}
Expand Down

0 comments on commit 96d46d5

Please sign in to comment.