vue/max-lines-per-block
SFC ブロックの行数が上限を超えた箇所を検出します。
| 既定の重大度 | プリセット | 自動修正 | オプション |
|---|---|---|---|
warning |
なし | なし | なし |
適用範囲:Vue SFC のテンプレートと各ブロック。ルールに必要な script の文脈も例に含めています。
悪い例
template ブロックの行数が設定した上限を超えています。
<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>
良い例
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": {
"vue/max-lines-per-block": "warn"
},
"ruleOptions": {
"vue/max-lines-per-block": {
"template": 10
}
}
},
});
設定したら vp run lint を実行します。