JS.VUE.HTML.CLOSING.BRACKET.NEWLINE

Require or disallow a line break before tag's closing brackets

People have their own preference about the location of closing brackets. This rule enforces a line break (or no line break) before tag's closing brackets.

Copy
<div
  id="foo"
  class="bar"> <!-- On the same line with the last attribute. -->
</div>

<div
  id="foo"
  class="bar"
> <!-- On the next line. -->
</div>

Rule Details

This rule aims to warn the right angle brackets which are at the location other than the configured location.

{'vue/html-closing-bracket-newline': ['error']}

Copy
<template>
  <!-- GOOD -->
  <div id="foo" class="bar">
  <div
    id="foo"
    class="bar"
  >

  <!-- BAD -->
  <div id="foo" class="bar"
  >
  <div
    id="foo"
    class="bar">
</template>

Options

Copy
{
  "vue/html-closing-bracket-newline": ["error", {
    "singleline": "never",
    "multiline": "always"
  }]
}
  • singleline ... the configuration for single-line elements. It's a single-line element if the element does not have attributes or the last attribute is on the same line as the opening bracket.
  • "never" (default) ... disallow line breaks before the closing bracket.
  • "always" ... require one line break before the closing bracket.
  • multiline ... the configuration for multiline elements. It's a multiline element if the last attribute is not on the same line of the opening bracket.
  • "never" ... disallow line breaks before the closing bracket.
  • "always" (default) ... require one line break before the closing bracket.

Plus, you can use vue/html-indent rule to enforce indent-level of the closing brackets.

"multiline": "never"

{'vue/html-closing-bracket-newline': ['error', { 'multiline': 'never' }]}

Copy
<template>
  <!-- GOOD -->
  <div
    id="foo"
    class="bar">

  <!-- BAD -->
  <div
    id="foo"
    class="bar"
  >
</template>

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/