File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed
Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -29,19 +29,20 @@ function convertDeclaratorToScriptRef(declarator) {
2929 * @returns {ScriptRef[] }
3030 * */
3131function getScriptRefsFromSetupFunction ( body ) {
32- /** @type { VariableDeclaration[] } */
33- const variableDeclarations = body . filter (
34- ( child ) => child . type === 'VariableDeclaration'
35- )
36- const variableDeclarators = variableDeclarations . map (
37- ( declaration ) => declaration . declarations [ 0 ]
38- )
39- const refDeclarators = variableDeclarators . filter ( ( declarator ) =>
40- // @ts -ignore
41- [ 'ref' , 'shallowRef' ] . includes ( declarator . init ?. callee ?. name )
42- )
32+ return body . flatMap ( ( child ) => {
33+ if ( child . type === 'VariableDeclaration' ) {
34+ const declarator = child . declarations [ 0 ]
35+
36+ if (
37+ declarator . init ?. type === 'CallExpression' &&
38+ declarator . init . callee ?. type === 'Identifier' &&
39+ [ 'ref' , 'shallowRef' ] . includes ( declarator . init ?. callee ?. name )
40+ )
41+ return [ convertDeclaratorToScriptRef ( declarator ) ]
42+ }
4343
44- return refDeclarators . map ( convertDeclaratorToScriptRef )
44+ return [ ]
45+ } )
4546}
4647
4748/** @type {import("eslint").Rule.RuleModule } */
You can’t perform that action at this time.
0 commit comments