vue/max-lines-per-block
Enforce a maximum number of lines in each Vue SFC block.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
None | No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The template block has more lines than the configured maximum.
<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>
Good
The template block stays within the configured maximum.
<script setup lang="ts">
const label = "a";
</script>
<template>
<p>{{ label }}</p>
</template>
Configuration (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
}
}
},
});
Then run vp run lint.