What language is this for?
JavaScript — Vue.js Single File Component (<script setup>)
Which rule?
javascript:S3827 (“undeclared variable”)
Why do you believe it’s a false-positive/false-negative?
defineModel() is a stable Vue 3.4+ compiler macro (same category as defineProps() and
defineEmits()), used inside <script setup> to declare a two-way bindable prop (v-model).
Like the other macros, it is compiled away by @vue/compiler-sfc and never exists as a real
identifier in the emitted JS — there’s nothing to declare, and no ReferenceError happens at
runtime.
defineProps() and defineEmits() are already recognized by the analyzer and never trigger
S3827. defineModel() (stable since Vue 3.4, Dec 2023) is not yet in that list, so any
component using it gets a false-positive report.
Reference: Component v-model | Vue.js
Are you using:
SonarQube Server / Community Build — sonar-javascript plugin 13.4 (build 43982)
How can we reproduce the problem?
Example.vue:
<script setup>
const modelValue = defineModel({ default: '' }) // <-- S3827 raised here
const selected = defineModel('selected', { default: () => [] }) // <-- and here
</script>