Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ad2ffda

Browse files
Fix false positives for defineModel in vue/no-undef-properties rule (#2364)
1 parent af7de76 commit ad2ffda

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

‎lib/rules/no-undef-properties.js‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -322,25 +322,12 @@ module.exports = {
322322
propertyReferenceExtractor.extractFromPattern(pattern)
323323
ctx.verifyReferences(propertyReferences)
324324
},
325-
onDefineModelEnter(node, model) {
325+
onDefineModelEnter(_node, model) {
326326
const ctx = getVueComponentContext(programNode)
327327

328328
ctx.defineProperties.set(model.name.modelName, {
329329
isProps: true
330330
})
331-
332-
if (
333-
!node.parent ||
334-
node.parent.type !== 'VariableDeclarator' ||
335-
node.parent.init !== node
336-
) {
337-
return
338-
}
339-
340-
const pattern = node.parent.id
341-
const propertyReferences =
342-
propertyReferenceExtractor.extractFromPattern(pattern)
343-
ctx.verifyReferences(propertyReferences)
344331
}
345332
}),
346333
utils.defineVueVisitor(context, {

‎tests/lib/rules/no-undef-properties.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,16 @@ tester.run('no-undef-properties', rule, {
558558
parserOptions: {
559559
parser: require.resolve('@typescript-eslint/parser')
560560
}
561-
}
561+
},
562+
563+
`
564+
<script setup>
565+
const model = defineModel();
566+
const woof = computed(() => model.value);
567+
</script>
568+
<template>
569+
<div id="app">Woof: {{ woof }}</div>
570+
</template>`
562571
],
563572

564573
invalid: [

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /