Skip to content

Commit 6e22d51

Browse files
authored
fix(no-ref-as-operand): do not report in tagged template expression (#2726)
1 parent 527081f commit 6e22d51

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ module.exports = {
233233
},
234234
// `${refValue}`
235235
/** @param {Identifier} node */
236-
'TemplateLiteral>Identifier'(node) {
236+
':not(TaggedTemplateExpression)>TemplateLiteral>Identifier'(node) {
237237
reportIfRefWrapped(node)
238238
},
239239
// refValue.x

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

+17-1
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)