@@ -59,30 +59,30 @@ function isInsideInitializer(node, references) {
59
59
}
60
60
61
61
/**
62
- * Find if the prop is renamed in the pattern
63
- * @param {Pattern } pattern - The destructuring pattern
64
- * @param {string } propName - The original prop name
65
- * @returns {boolean } - True if the prop is renamed
62
+ * Collects all renamed props from a pattern
63
+ * @param {Pattern | null } pattern - The destructuring pattern
64
+ * @returns {Set<string> } - Set of prop names that have been renamed
66
65
*/
67
- function findRenamedProp ( pattern , propName ) {
66
+ function collectRenamedProps ( pattern ) {
67
+ const renamedProps = new Set ( )
68
+
68
69
if ( ! pattern || pattern . type !== 'ObjectPattern' ) {
69
- return false
70
+ return renamedProps
70
71
}
71
72
72
73
for ( const prop of pattern . properties ) {
73
74
if ( prop . type !== 'Property' ) continue
74
75
75
76
if (
76
77
prop . key . type === 'Identifier' &&
77
- prop . key . name === propName &&
78
78
prop . value . type === 'Identifier' &&
79
- prop . value . name !== propName
79
+ prop . key . name !== prop . value . name
80
80
) {
81
- return true
81
+ renamedProps . add ( prop . key . name )
82
82
}
83
83
}
84
84
85
- return false
85
+ return renamedProps
86
86
}
87
87
88
88
module . exports = {
@@ -142,10 +142,12 @@ module.exports = {
142
142
node
143
143
]
144
144
145
+ const renamedProps = collectRenamedProps ( propsNode )
146
+
145
147
for ( const prop of props ) {
146
148
if ( ! prop . propName ) continue
147
149
148
- if ( propsNode && findRenamedProp ( propsNode , prop . propName ) ) {
150
+ if ( renamedProps . has ( prop . propName ) ) {
149
151
continue
150
152
}
151
153
0 commit comments