Vize

vue/component-name-in-template-casing

テンプレート内のコンポーネント名を指定した形式に揃えます。

既定の重大度 プリセット 自動修正 オプション
warning nuxt, opinionated あり ルールのオプション

適用範囲:Vue SFC のテンプレートと各ブロック。ルールに必要な script の文脈も例に含めています。

悪い例

PascalCase の方針に対し、コンポーネントを kebab-case と camelCase で記述しています。

<script setup>
import MyComponent from "./MyComponent.vue";
</script>
<template>
  <my-component />
  <myComponent />
</template>

良い例

MyComponent を PascalCase で記述します。標準の slot は小文字のままです。

<script setup>
import MyComponent from "./MyComponent.vue";
</script>
<template>
  <MyComponent />
  <RouterView />
  <slot />
</template>

設定(Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "vue/component-name-in-template-casing": "warn"
    }
  },
});

設定したら vp run lint を実行します。

関連ページ