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

Rule proposal: vue/no-undef-directives #2946

@hoonweiting

Description

@hoonweiting

Please describe what the rule should do:

The rule should warn when a custom directive is used, but not imported. The rule should also accept some kind of ignore option to avoid false positives with globally-registered custom directives.

What category should the rule belong to?

  • Enforces code style (layout)
  • Warns about a potential error (problem)
  • Suggests an alternate way of doing something (suggestion)
  • Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

Should warn on:

<template>
  <input v-focus>
</template>

<script setup>
// vFocus is not imported or defined anywhere
</script>
<template>
  <a v-sref="someValue">
    <!-- anchor contents -->
  </a>
</template>

<script setup>
// vSref is not imported or defined anywhere
</script>

Should not warn on:

<template>
  <input v-focus>
</template>

<script setup>
import vFocus from '../path/to/vFocus';
</script>
<template>
  <a v-sref="someValue">
    <!-- anchor contents -->
  </a>
</template>

<script setup>
import vSref from '../path/to/vSref';
</script>

Additional context

There is a runtime warning in the browser console, but it would be cool if we can catch these issues when linting too.

[Vue warn]: Failed to resolve directive: sref

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions