Skip to content

vue/singleline-html-element-content-newline

要求单行元素内容前后有换行符

  • ⚙️ 此规则包含在 "plugin:vue/strongly-recommended"*.configs["flat/strongly-recommended"]"plugin:vue/vue2-strongly-recommended"*.configs["flat/vue2-strongly-recommended"]"plugin:vue/recommended"*.configs["flat/recommended"]"plugin:vue/vue2-recommended"*.configs["flat/vue2-recommended"] 中。
  • 🔧命令行 上的 --fix 选项可以自动修复此规则报告的一些问题。

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

📖 规则详情

此规则强制在单行元素的内容之前和之后换行。

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

Now loading...

🔧选项

¥🔧 Options

js
{
  "vue/singleline-html-element-content-newline": ["error", {
    "ignoreWhenNoAttributes": true,
    "ignoreWhenEmpty": true,
    "ignores": ["pre", "textarea", ...INLINE_ELEMENTS],
    "externalIgnores": []
  }]
}
  • ignoreWhenNoAttributes ...当给定元素没有属性时,允许将内容放在一行中。默认 true

    ¥ignoreWhenNoAttributes ... allows having contents in one line, when given element has no attributes. default true

  • ignoreWhenEmpty ...当元素没有内容时禁用报告。默认 true

    ¥ignoreWhenEmpty ... disables reporting when element has no content. default true

  • ignores ...元素名称忽略换行符样式的配置。默认 ["pre", "textarea", ...INLINE_ELEMENTS]

    ¥ignores ... the configuration for element names to ignore line breaks style. default ["pre", "textarea", ...INLINE_ELEMENTS]

  • externalIgnores ...外部元素名称忽略换行符样式的配置,它允许避免覆盖忽略的默认值。默认 []

    ¥externalIgnores ... the configuration for external element names to ignore line breaks style, it allows avoiding overwrite the default value of ignores. default []

信息

所有内联非 void 元素都可以在 此处 中找到。

¥All inline non void elements can be found here.

"ignoreWhenNoAttributes": true

Now loading...

"ignoreWhenNoAttributes": false

Now loading...

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v5.0.0 中引入

¥This rule was introduced in eslint-plugin-vue v5.0.0

🔍代码实现

¥🔍 Implementation

eslint-plugin-vue v10.0 中文网 - 粤ICP备13048890号