Skip to content

Commit

Permalink
Fix false positives for defineModel in vue/no-undef-properties ru…
Browse files Browse the repository at this point in the history
…le (#2364)
  • Loading branch information
ota-meshi committed Jan 13, 2024
1 parent af7de76 commit ad2ffda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
15 changes: 1 addition & 14 deletions lib/rules/no-undef-properties.js
Expand Up @@ -322,25 +322,12 @@ module.exports = {
propertyReferenceExtractor.extractFromPattern(pattern)
ctx.verifyReferences(propertyReferences)
},
onDefineModelEnter(node, model) {
onDefineModelEnter(_node, model) {
const ctx = getVueComponentContext(programNode)

ctx.defineProperties.set(model.name.modelName, {
isProps: true
})

if (
!node.parent ||
node.parent.type !== 'VariableDeclarator' ||
node.parent.init !== node
) {
return
}

const pattern = node.parent.id
const propertyReferences =
propertyReferenceExtractor.extractFromPattern(pattern)
ctx.verifyReferences(propertyReferences)
}
}),
utils.defineVueVisitor(context, {
Expand Down
11 changes: 10 additions & 1 deletion tests/lib/rules/no-undef-properties.js
Expand Up @@ -558,7 +558,16 @@ tester.run('no-undef-properties', rule, {
parserOptions: {
parser: require.resolve('@typescript-eslint/parser')
}
}
},

`
<script setup>
const model = defineModel();
const woof = computed(() => model.value);
</script>
<template>
<div id="app">Woof: {{ woof }}</div>
</template>`
],

invalid: [
Expand Down

0 comments on commit ad2ffda

Please sign in to comment.