vue/require-component-is
動的 component 要素に :is を指定します。
既定の重大度: error
プリセット: essential, happy-path, nuxt, ecosystem, opinionated
自動修正: なし。修正内容を確認してください
適用範囲: Vue SFC のテンプレート・ブロック。必要な script の文脈も例に含めています。
オプション: ルール固有のオプションはありません。重大度とプリセットは設定できます。
設定(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/require-component-is": "error"
}
},
},
});
vp run lint
悪い
動的な <component> に is がなく、描画するコンポーネントを選べません。
<template>
<component />
</template>
良い
:is="currentComponent" で描画対象を指定します。対象は実行時に変更できます。
<template>
<component :is="currentComponent" />
</template>
良い例は上記の設定でこのルールの検出を避ける例です。他のルールでは検出される場合があります。