vue-pug/max-attributes-per-line
Pug attribute blocks में प्रति line attributes की अधिकतम संख्या लागू करें।
✅ configs.recommended में चालू (warn पर)। 🔧 --fix से ठीक होने योग्य।
Pug templates के अंदर vue/max-attributes-per-line की जगह लेता है।
Rule का विवरण
Attributes गिने जाते हैं प्रति attribute block: a(w x)(y z) में दो-दो attributes के दो blocks हैं।
- एक line के block में
singlelineतक attributes हो सकते हैं (default3)। उससे ऊपर, पहले के बाद का हर attribute रिपोर्ट होता है। - जिस block में कोई भी line break हो, value के अंदर वाला भी, वह multiline है। उसकी हर line में
multilineतक attributes हो सकते हैं (default1); अतिरिक्त वाले रिपोर्ट होते हैं।
Fix रिपोर्ट हुए attribute से पहले के whitespace को line break से बदलता है, जो tag से एक level गहरा indent होता है (comma अपने से पहले वाले attribute के साथ रहता है)। ( के बाद और ) से पहले के line breaks vue-pug/attribute-parens-newline पर छोड़े गए हैं। Tag interpolation (#[a(x y z w)]) के अंदर के tags नहीं जाँचे जाते: वे text line का हिस्सा हैं।
गलत
vue
<template lang="pug">
input(type="text" name="q" placeholder="Search" required)
</template>vue
<template lang="pug">
input(
type="text" name="q"
required
)
</template>सही
vue
<template lang="pug">
input(type="text" name="q" required)
</template>vue
<template lang="pug">
input(
type="text"
name="q"
placeholder="Search"
required
)
</template>Options
js
'vue-pug/max-attributes-per-line': ['warn', { singleline: 3, multiline: 1 }]singleline(integer ≥ 1, default3): एक line के block के लिए अधिकतम।multiline(integer ≥ 1, default1): multiline block में प्रति line अधिकतम।
[{ "singleline": 1 }] के साथ गलत
vue
<template lang="pug">
a(href="/" target="_blank") Home
</template>[{ "singleline": 1 }] के साथ सही
vue
<template lang="pug">
a(href="/") Home
</template>