File tree 8 files changed +238
-213
lines changed
src/transformations/__tests__
8 files changed +238
-213
lines changed Original file line number Diff line number Diff line change 44
44
}
45
45
},
46
46
"resolutions" : {
47
- "ast-types" : " npm:ast-types-x@1.17.1 " ,
48
- "recast" :
" npm:[email protected] .3 "
47
+ "ast-types" : " npm:ast-types-x@1.18.0 " ,
48
+ "recast" :
" npm:[email protected] .5 "
49
49
}
50
50
}
Original file line number Diff line number Diff line change 44
44
},
45
45
"dependencies" : {
46
46
"@babel/helper-validator-identifier" : " ^7.24.7" ,
47
- "ast-types" : " npm:ast-types-x@1.17.1 " ,
47
+ "ast-types" : " npm:ast-types-x@1.18.0 " ,
48
48
"jscodeshift" :
" npm:[email protected] "
49
49
},
50
50
"devDependencies" : {
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ export function findReferences(
171
171
) : Collection < Identifier > {
172
172
const targetScope = 'bindings' in nodeOrScope ? nodeOrScope : j ( nodeOrScope ) . get ( ) . scope as Scope
173
173
const range = 'bindings' in nodeOrScope ? nodeOrScope . path : nodeOrScope
174
+ const rangeNode = 'node' in range ? range . node : range
174
175
175
176
return j ( range )
176
177
. find ( j . Identifier , { name : identifierName } )
@@ -179,6 +180,11 @@ export function findReferences(
179
180
// ignore properties (e.g. in MemberExpression
180
181
if ( path . name === 'property' && j . MemberExpression . check ( path . parent . node ) && ! path . parent . node . computed ) return false
181
182
183
+ // ignore function name that is at the top level
184
+ if ( path . parent . node === rangeNode && j . FunctionDeclaration . check ( path . parent . node ) && path . parent . node . id === path . node ) {
185
+ return false
186
+ }
187
+
182
188
if ( ! path . scope ) return false
183
189
184
190
let scope : Scope | null = path . scope
Original file line number Diff line number Diff line change 30
30
"lint:fix" : " eslint src --fix --max-warnings=0"
31
31
},
32
32
"dependencies" : {
33
- "@babel/parser" : " ^7.25.0 " ,
34
- "ast-types" : " npm:ast-types-x@1.17.1 " ,
33
+ "@babel/parser" : " ^7.25.6 " ,
34
+ "ast-types" : " npm:ast-types-x@1.18.0 " ,
35
35
"jscodeshift" :
" npm:[email protected] " ,
36
36
"pathe" : " ^1.1.2" ,
37
37
"zod" : " ^3.23.8"
Original file line number Diff line number Diff line change 25
25
},
26
26
"dependencies" : {
27
27
"@babel/helper-validator-identifier" : " ^7.24.7" ,
28
- "@babel/parser" : " ^7.25.0 " ,
29
- "ast-types" : " npm:ast-types-x@1.17.1 " ,
28
+ "@babel/parser" : " ^7.25.6 " ,
29
+ "ast-types" : " npm:ast-types-x@1.18.0 " ,
30
30
"jscodeshift" :
" npm:[email protected] " ,
31
31
"lebab" : " ^3.2.4" ,
32
32
"pathe" : " ^1.1.2" ,
33
33
"prettier" : " ^2.8.8" ,
34
34
"zod" : " ^3.23.8"
35
35
},
36
36
"devDependencies" : {
37
- "@babel/core" : " ^7.24.9 " ,
37
+ "@babel/core" : " ^7.25.2 " ,
38
38
"@rollup/plugin-commonjs" : " ^26.0.1" ,
39
39
"@rollup/plugin-node-resolve" : " ^15.2.3" ,
40
- "@swc/core" : " ^1.7.2 " ,
40
+ "@swc/core" : " ^1.7.22 " ,
41
41
"@types/jscodeshift" : " ^0.11.11" ,
42
42
"@types/prettier" : " ^2.7.3" ,
43
43
"@types/yargs" : " ^17.0.32" ,
46
46
"@wakaru/shared" : " workspace:*" ,
47
47
"@wakaru/test-utils" : " workspace:*" ,
48
48
"picocolors" : " ^1.0.1" ,
49
- "rollup" : " ^4.19.1 " ,
49
+ "rollup" : " ^4.21.2 " ,
50
50
"rollup-plugin-dts" : " ^6.1.1" ,
51
51
"rollup-plugin-swc3" : " ^0.11.2" ,
52
52
"typescript" : " ^5.5.4"
Original file line number Diff line number Diff line change @@ -323,6 +323,25 @@ function foo() {
323
323
` ,
324
324
)
325
325
326
+ inlineTest ( 'property destructuring - resolve naming conflicts #4' ,
327
+ `
328
+ function J(U) {
329
+ const B = U.children;
330
+ const G = U.className;
331
+ const J = U.description;
332
+ }
333
+ ` ,
334
+ `
335
+ function J(U) {
336
+ const {
337
+ children,
338
+ className,
339
+ description
340
+ } = U;
341
+ }
342
+ ` ,
343
+ )
344
+
326
345
inlineTest ( 'array destructuring' ,
327
346
`
328
347
const t = e[0];
Original file line number Diff line number Diff line change 25
25
},
26
26
"dependencies" : {
27
27
"@babel/helper-validator-identifier" : " ^7.24.7" ,
28
- "@babel/parser" : " ^7.25.0 " ,
29
- "ast-types" : " npm:ast-types-x@1.17.1 " ,
28
+ "@babel/parser" : " ^7.25.6 " ,
29
+ "ast-types" : " npm:ast-types-x@1.18.0 " ,
30
30
"jscodeshift" :
" npm:[email protected] " ,
31
31
"pathe" : " ^1.1.2" ,
32
32
"zod" : " ^3.23.8"
33
33
},
34
34
"devDependencies" : {
35
35
"@rollup/plugin-commonjs" : " ^26.0.1" ,
36
36
"@rollup/plugin-node-resolve" : " ^15.2.3" ,
37
- "@swc/core" : " ^1.7.2 " ,
37
+ "@swc/core" : " ^1.7.22 " ,
38
38
"@types/jscodeshift" : " ^0.11.11" ,
39
39
"@wakaru/ast-utils" : " workspace:*" ,
40
40
"@wakaru/shared" : " workspace:*" ,
41
41
"@wakaru/test-utils" : " workspace:*" ,
42
- "rollup" : " ^4.18.1 " ,
42
+ "rollup" : " ^4.21.2 " ,
43
43
"rollup-plugin-dts" : " ^6.1.1" ,
44
44
"rollup-plugin-swc3" : " ^0.11.2" ,
45
45
"typescript" : " ^5.5.4"
You can’t perform that action at this time.
0 commit comments