Skip to content

Latest commit

 

History

History
161 lines (122 loc) · 3.36 KB

padding-line-between-tags.md

File metadata and controls

161 lines (122 loc) · 3.36 KB
pageClass sidebarDepth title description
rule-details
0
vue/padding-line-between-tags
Require or disallow newlines between sibling tags in template

vue/padding-line-between-tags

Require or disallow newlines between sibling tags in template

  • This rule has not been released yet.
  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule requires or disallows newlines between sibling HTML tags.

<template>
  <div>
    <!-- ✓ GOOD: -->
    <div></div>

    <div>
    </div>
    
    <div />
    <!-- ✗ BAD: -->
    <div></div>
    <div>
    </div>
    <div />
  </div>
</template>

🔧 Options

{
  "vue/padding-line-between-tags": ["error", [
    { "blankLine": "always", "prev": "*", "next": "*" }
  ]]
}

This rule requires blank lines between each sibling HTML tag by default.

A configuration is an object which has 3 properties; blankLine, prev and next. For example, { blankLine: "always", prev: "br", next: "div" } means “one or more blank lines are required between a br tag and a div tag.” You can supply any number of configurations.

  • blankLine is one of the following:
    • always requires one or more blank lines.
    • never disallows blank lines.
  • prev any tag name without brackets.
  • next any tag name without brackets.

Disallow blank lines between all tags

{ blankLine: 'never', prev: '*', next: '*' }

<template>
  <div>
    <div></div>
    <div>
    </div>
    <div />
  </div>
</template>

Require newlines after <br>

{ blankLine: 'always', prev: 'br', next: '*' }

<template>
  <div>
    <ul>
      <li>
      </li>
      <br />

      <li>
      </li>
    </ul>
  </div>
</template>

Require newlines before <br>

{ blankLine: 'always', prev: '*', next: 'br' }

<template>
  <div>
    <ul>
      <li>
      </li>
      
      <br />
      <li>
      </li>
    </ul>
  </div>
</template>

Require newlines between <br> and <img>

{ blankLine: 'always', prev: 'br', next: 'img' }

<template>
  <div>
    <ul>
      <li>
      </li>
      <br />

      <img />
      <li>
      </li>
    </ul>
  </div>
</template>

🔍 Implementation