vue/require-component-registration
Require explicit import or registration for components.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
opinionated |
No | Rule options |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
List explicit component names supplied by application plugins or Musea previewSetup. PascalCase and kebab-case spellings are accepted; globals are names, not regular expressions. ignorePatterns takes regular expressions, as eslint-plugin-vue vue/no-undef-components does. A static is attribute names a component on <component> or with a vue: prefix; on another element it is a customized built-in element and is not checked. Options do not enable the rule. Later layers replace the list; an empty list clears inherited names.
Bad
MissingWidget is neither registered nor included in the configured global-component allowlist.
<template>
<MissingWidget />
</template>
Good
MyButton is listed in the example's globals option. That option exempts a known global component; it does not register or import it.
<template>
<MyButton />
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/require-component-registration": "warn"
},
"ruleOptions": {
"vue/require-component-registration": {
"globals": [
"MyButton",
"MyIcon"
]
}
}
},
});
Then run vp run lint.