Skip to content

Commit 9f298ed

Browse files
committed
fix(no-ref-as-operand): do not report in tagged template expression
1 parent 527081f commit 9f298ed

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/rules/no-ref-as-operand.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ module.exports = {
234234
// `${refValue}`
235235
/** @param {Identifier} node */
236236
'TemplateLiteral>Identifier'(node) {
237+
if (node.parent.type === 'TaggedTemplateExpression') {
238+
return
239+
}
237240
reportIfRefWrapped(node)
238241
},
239242
// refValue.x

tests/lib/rules/no-ref-as-operand.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,22 @@ tester.run('no-ref-as-operand', rule, {
168168
}
169169
</script>
170170
`,
171+
`
172+
<script>
173+
import { ref } from 'vue'
174+
const foo = ref(0)
175+
func(foo)
176+
function func(foo) {}
177+
</script>
178+
`,
179+
`
180+
<script>
181+
import { ref } from 'vue'
182+
const foo = ref(0)
183+
tag\`\${foo}\`
184+
function tag(arr, ...args) {}
185+
</script>
186+
`,
171187
`
172188
<script setup>
173189
const model = defineModel();
@@ -196,7 +212,7 @@ tester.run('no-ref-as-operand', rule, {
196212
<script setup>
197213
const emit = defineEmits(['test'])
198214
const [model, mod] = defineModel();
199-
215+
200216
function update() {
201217
emit('test', model.value)
202218
}

0 commit comments

Comments
 (0)