Skip to content

Latest commit

 

History

History
101 lines (67 loc) · 2.33 KB

singleline-html-element-content-newline.md

File metadata and controls

101 lines (67 loc) · 2.33 KB

require a line break before and after the contents of a singleline element (vue/singleline-html-element-content-newline)

  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule enforces a line break before and after the contents of a singleline element.

👎 Examples of incorrect code:

<div attr>content</div>

<tr attr><td>{{ data1 }}</td><td>{{ data2 }}</td></tr>

<div attr><!-- comment --></div>

👍 Examples of correct code:

<div attr>
  content
</div>

<tr attr>
  <td>
    {{ data1 }}
  </td>
  <td>
    {{ data2 }}
  </td>
</tr>

<div attr>
  <!-- comment -->
</div>

🔧 Options

{
  "vue/singleline-html-element-content-newline": ["error", {
    "ignoreWhenNoAttributes": true,
    "ignores": ["pre", "textarea"]
  }]
}
  • ignoreWhenNoAttributes ... allows having contents in one line, when given element has no attributes. default true
  • ignores ... the configuration for element names to ignore line breaks style.
    default ["pre", "textarea"]

👎 Examples of incorrect code for {ignoreWhenNoAttributes: false}:

/* eslint vue/singleline-html-element-content-newline: ["error", { "ignoreWhenNoAttributes": false}] */

<div>content</div>

<tr><td>{{ data1 }}</td><td>{{ data2 }}</td></tr>

<div><!-- comment --></div>

👍 Examples of correct code for {ignoreWhenNoAttributes: true} (default):

/* eslint vue/singleline-html-element-content-newline: ["error", { "ignoreWhenNoAttributes": true}] */

<div>content</div>

<tr><td>{{ data1 }}</td><td>{{ data2 }}</td></tr>

<div><!-- comment --></div>

👎 Examples of incorrect code for {ignoreWhenNoAttributes: true} (default):

/* eslint vue/singleline-html-element-content-newline: ["error", { "ignoreWhenNoAttributes": true}] */

<div attr>content</div>

<tr attr><td>{{ data1 }}</td><td>{{ data2 }}</td></tr>

<div attr><!-- comment --></div>

👍 Examples of correct code for ignores:

/* eslint vue/singleline-html-element-content-newline: ["error", { "ignores": ["VueComponent", "pre", "textarea"]}] */

<VueComponent>content</VueComponent>

<VueComponent attr><span>content</span></VueComponent>