Vize

vue/prop-name-casing

宣言する prop 名の形式を揃えます。

既定の重大度 プリセット 自動修正 オプション
warning happy-path, nuxt, ecosystem, opinionated なし ルールのオプション

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

宣言した props の名前を検査します。子に渡す属性名の表記を検査するルールではありません。

悪い例

宣言した prop の user_name をアンダースコア区切りにしています。

<script setup lang="ts">
defineProps<{ user_name: string }>();
</script>
<template><p>{{ user_name }}</p></template>

良い例

宣言とテンプレートの参照を、camelCase の userName に揃えます。

<script setup lang="ts">
defineProps<{ userName: string }>();
</script>
<template><p>{{ userName }}</p></template>

設定(Vite+)

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

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

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

関連ページ