JS.VUE.BLOCK.TAG.NEWLINE

Enforce line breaks after opening and before closing block-level tags

Rule Details

This rule enforces a line break (or no line break) after opening and before closing block tags.

{'vue/block-tag-newline': ['error']}

Copy
<!-- GOOD -->
<template><input></template>

<script>
export default {}
</script>

{'vue/block-tag-newline': ['error']}

Copy
<!-- BAD -->
<template>
<input></template>

<script>
export default {}</script>

Options

Copy
{
  "vue/block-tag-newline": ["error", {
    "singleline": "always" | "never" | "consistent" | "ignore",
    "multiline": "always" | "never" | "consistent" | "ignore",
    "maxEmptyLines": 0,
    "blocks": {
      "template": {
        "singleline": "always" | "never" | "consistent" | "ignore",
        "multiline": "always" | "never" | "consistent" | "ignore",
        "maxEmptyLines": 0,
      },
      "script": {
        "singleline": "always" | "never" | "consistent" | "ignore",
        "multiline": "always" | "never" | "consistent" | "ignore",
        "maxEmptyLines": 0,
      },
      "my-block": {
        "singleline": "always" | "never" | "consistent" | "ignore",
        "multiline": "always" | "never" | "consistent" | "ignore",
        "maxEmptyLines": 0,
      }
    }
  }]
}
  • singleline ... the configuration for single-line blocks.
  • "consistent" ... (default) requires consistent usage of line breaks for each pair of tags. It reports an error if one tag in the pair has a linebreak inside it and the other tag does not.
  • "always" ... require one line break after opening and before closing block tags.
  • "never" ... disallow line breaks after opening and before closing block tags.
  • multiline ... the configuration for multi-line blocks.
  • "consistent" ... requires consistent usage of line breaks for each pair of tags. It reports an error if one tag in the pair has a linebreak inside it and the other tag does not.
  • "always" ... (default) require one line break after opening and before closing block tags.
  • "never" ... disallow line breaks after opening and before closing block tags.
  • maxEmptyLines ... specifies the maximum number of empty lines allowed. default 0.
  • blocks ... specifies for each block name.

{ "singleline": "never", "multiline": "always" }

{'vue/block-tag-newline': ['error', { 'singleline': 'never', 'multiline': 'always' }]}

Copy
<!-- GOOD -->
<template><input></template>

<script>
export default {
}
</script>

{'vue/block-tag-newline': ['error', { 'singleline': 'never', 'multiline': 'always' }]}

Copy
<!-- BAD -->
<template>
<input>
</template>

<script>export default {
}</script>

{ "singleline": "always", "multiline": "always", "maxEmptyLines": 1 }

{'vue/block-tag-newline': ['error', { 'singleline': 'always', 'multiline': 'always', 'maxEmptyLines': 1 }]}

Copy
<!-- GOOD -->
<template>

<input>

</template>

<script>

export default {
}

</script>

{'vue/block-tag-newline': ['error', { 'singleline': 'always', 'multiline': 'always', 'maxEmptyLines': 1 }]}

Copy
<!-- BAD -->
<template>
<input>
</template>

<script>
export default {
}
</script>

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/