# svelte/max-lines-per-block
enforce maximum number of lines in svelte component blocks
- ❗
This rule has not been released yet.
# 📖 Rule Details
This rule enforces a maximum number of lines per block (<script>, <style>, or template) in Svelte single-file components, in order to aid in maintainability and reduce complexity.
ESLint’s core max-lines rule counts all lines in a .svelte file including CSS in <style> blocks, which penalizes components for styling rather than logic complexity. This rule allows limiting each block independently — for example, enforcing script and template limits while leaving style unchecked.
# 💡 Usage Example
If ESLint’s max-lines rule triggers on your Svelte components because of large <style> blocks, you can replace it with this rule to check only the blocks that matter:
{
// Before: counts ALL lines including CSS
// "max-lines": ["error", { "max": 300 }]
// After: only checks script and template, ignores style
"svelte/max-lines-per-block": [
"error",
{
"script": 300,
"template": 200,
"skipBlankLines": true,
"skipComments": true
}
]
}
# 🔧 Options
{
"svelte/max-lines-per-block": [
"error",
{
"script": 300,
"template": 400,
"style": 500,
"skipBlankLines": true,
"skipComments": true
}
]
}
script… Maximum number of inner lines in<script>blocks. Omit to skip checking.template… Maximum number of lines in the template (markup) region. Lines inside<script>,<style>, and<svelte:options>are excluded. Omit to skip checking.style… Maximum number of inner lines in<style>blocks. Omit to skip checking.skipBlankLines… Ignore blank (whitespace-only) lines when counting. Default:false.skipComments… Ignore comment lines when counting. Default:false.
Each block option is optional. If a block option is not specified, that block is not checked.