@@ -8,7 +8,7 @@ const utils = require('../utils')
88
99/**
1010 *@typedef ScriptRef
11- *@type {{node: Expression, ref: string} }
11+ *@type {[string, CallExpression] }
1212 */
1313
1414/**
@@ -26,10 +26,7 @@ function getScriptRefsFromSetupFunction(body) {
2626declarator . id . type === 'Identifier' &&
2727[ 'ref' , 'shallowRef' ] . includes ( declarator . init . callee . name )
2828)
29- return {
30- node :declarator . init ,
31- ref :declarator . id . name
32- }
29+ return [ [ declarator . id . name , declarator . init ] ]
3330}
3431
3532return [ ]
@@ -86,21 +83,21 @@ module.exports = {
8683} ) ,
8784{
8885'Program:exit' ( ) {
86+ const scriptRefsMap = new Map ( scriptRefs )
87+
8988for ( const templateRef of templateRefs ) {
90- const scriptRef = scriptRefs . find (
91- ( scriptRef ) => scriptRef . ref === templateRef
92- )
89+ const scriptRef = scriptRefsMap . get ( templateRef )
9390
9491if ( ! scriptRef ) {
9592continue
9693}
9794
9895context . report ( {
99- node :scriptRef . node ,
96+ node :scriptRef ,
10097messageId :'preferUseTemplateRef' ,
10198data :{
102- //@ts -ignore
103- name :scriptRef . node ?. callee ? .name
99+ //@ts -expect-error `scriptRef.callee` is `Identifier`
100+ name :scriptRef . callee . name
104101}
105102} )
106103}