Vize

max-lines

ファイルの行数が上限を超えた箇所を検出します。

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

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

悪い例

ファイルの行数が設定した上限を超えています。

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

<template>
  <ul>
    <li>{{ label }}</li>
    <li>{{ label }}</li>
    <li>{{ label }}</li>
    <li>{{ label }}</li>
    <li>{{ label }}</li>
    <li>{{ label }}</li>
    <li>{{ label }}</li>
    <li>{{ label }}</li>
    <li>{{ label }}</li>
    <li>{{ label }}</li>
  </ul>
</template>

良い例

ファイルの行数は設定した上限以内です。

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

設定(Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "max-lines": "warn"
    },
    "ruleOptions": {
      "max-lines": {
        "max": 10
      }
    }
  },
});

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

関連ページ