Skip to content

vue/block-tag-newline

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

  • 🔧 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 (or no line break) after opening and before closing block tags.

Now loading...
Now loading...

🔧 Options

json
{
  "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" }

Now loading...
Now loading...

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

Now loading...
Now loading...

🚀 Version

This rule was introduced in eslint-plugin-vue v7.1.0

🔍 Implementation