WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit f46ad20

Browse files
committed
docs: update
1 parent 5ab0de6 commit f46ad20

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

docs/rules/no-undef-directives.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,24 @@ description: disallow use of undefined custom directives
1313

1414
## :book: Rule Details
1515

16-
This rule reports use of undefined custom directives in `<template>`.
16+
This rule reports directives that are used in the `<template>`, but that are not registered in the `<script setup>` or the Options API's `directives` section.
17+
18+
Undefined directives will be resolved from globally registered directives. However, if you are not using global directives, you can use this rule to prevent run-time errors.
1719

1820
<eslint-code-block :rules="{'vue/no-undef-directives': ['error']}">
1921

2022
```vue
23+
<script setup>
24+
import vFocus from './vFocus';
25+
</script>
26+
2127
<template>
22-
<!-- ✗ BAD -->
28+
<!-- ✓ GOOD -->
2329
<input v-focus>
30+
31+
<!-- ✗ BAD -->
2432
<div v-foo></div>
2533
</template>
26-
27-
<script setup>
28-
// vFocus is not imported
29-
</script>
3034
```
3135

3236
</eslint-code-block>
@@ -37,12 +41,19 @@ This rule reports use of undefined custom directives in `<template>`.
3741
<template>
3842
<!-- ✓ GOOD -->
3943
<input v-focus>
44+
45+
<!-- ✗ BAD -->
4046
<div v-foo></div>
4147
</template>
4248
43-
<script setup>
49+
<script>
4450
import vFocus from './vFocus';
45-
const vFoo = {}
51+
52+
export default {
53+
directives: {
54+
focus: vFocus
55+
}
56+
}
4657
</script>
4758
```
4859

tests/lib/rules/no-undef-directives-repro.js

Whitespace-only changes.

0 commit comments

Comments
 (0)