Pattern: Missing line break for single-line element
Issue: -
This rule enforces a line break before and after the contents of a single-line element.
<template>
<!-- ✓ GOOD -->
<div attr>
content
</div>
<tr attr>
<td>
{{ data1 }}
</td>
<td>
{{ data2 }}
</td>
</tr>
<div attr>
<!-- comment -->
</div>
<!-- ✗ BAD -->
<div attr>content</div>
<tr attr><td>{{ data1 }}</td><td>{{ data2 }}</td></tr>
<div attr><!-- comment --></div>
</template>
{
"vue/singleline-html-element-content-newline": ["error", {
"ignoreWhenNoAttributes": true,
"ignoreWhenEmpty": true,
"ignores": ["pre", "textarea", ...INLINE_ELEMENTS]
}]
}
ignoreWhenNoAttributes
... allows having contents in one line, when given element has no attributes. defaulttrue
ignoreWhenEmpty
... disables reporting when element has no content. defaulttrue
ignores
... the configuration for element names to ignore line breaks style. default["pre", "textarea", ...INLINE_ELEMENTS]
.
<template>
<!-- ✗ BAD -->
<div attr>content</div>
<tr attr><td>{{ data1 }}</td><td>{{ data2 }}</td></tr>
<div attr><!-- comment --></div>
</template>
<template>
<!-- ✗ BAD -->
<div>content</div>
<tr><td>{{ data1 }}</td><td>{{ data2 }}</td></tr>
<div><!-- comment --></div>
</template>