Skip to content

Commit 3f4795c

Browse files
committed
refactor: restrict type check
1 parent c741b59 commit 3f4795c

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

lib/rules/prefer-use-template-ref.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@ const utils = require('../utils')
1111
* @type {{node: Expression, ref: string}}
1212
*/
1313

14-
/**
15-
* @param declarator {VariableDeclarator}
16-
* @returns {ScriptRef}
17-
* */
18-
function convertDeclaratorToScriptRef(declarator) {
19-
return {
20-
// @ts-ignore
21-
node: declarator.init,
22-
// @ts-ignore
23-
ref: declarator.id.name
24-
}
25-
}
26-
2714
/**
2815
* @param body {(Statement | ModuleDeclaration)[]}
2916
* @returns {ScriptRef[]}
@@ -36,9 +23,13 @@ function getScriptRefsFromSetupFunction(body) {
3623
if (
3724
declarator.init?.type === 'CallExpression' &&
3825
declarator.init.callee?.type === 'Identifier' &&
39-
['ref', 'shallowRef'].includes(declarator.init?.callee?.name)
26+
declarator.id.type === 'Identifier' &&
27+
['ref', 'shallowRef'].includes(declarator.init.callee.name)
4028
)
41-
return [convertDeclaratorToScriptRef(declarator)]
29+
return {
30+
node: declarator.init,
31+
ref: declarator.id.name
32+
}
4233
}
4334

4435
return []

0 commit comments

Comments
 (0)