Vize

vue/require-default-export

コンポーネントの script をデフォルトエクスポートにします。

既定の重大度 プリセット 自動修正 オプション
error なし なし なし

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

悪い例

コンポーネントの script にデフォルトエクスポートがありません。

<script lang="ts">
const label = "a";
</script>
<template>
  <p>label</p>
</template>

良い例

コンポーネントを script のデフォルトエクスポートにします。

<script lang="ts">
const label = "a";
export default { name: "Label" };
</script>
<template>
  <p>label</p>
</template>

設定(Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "vue/require-default-export": "error"
    }
  },
});

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

関連ページ