跳至内容

vue/max-len

.vue 文件中强制执行最大行长

📖 规则详细信息

此规则强制执行最大行长以提高代码可读性和可维护性。此规则与核心 max-len 规则类似,但它适用于 .vue 中的源代码。

正在加载...

🔧 选项

js
{
    "vue/max-len": ["error", {
        "code": 80,
        "template": 80,
        "tabWidth": 2,
        "comments": 80,
        "ignorePattern": "",
        "ignoreComments": false,
        "ignoreTrailingComments": false,
        "ignoreUrls": false,
        "ignoreStrings": false,
        "ignoreTemplateLiterals": false,
        "ignoreRegExpLiterals": false,
        "ignoreHTMLAttributeValues": false,
        "ignoreHTMLTextContents": false,
    }]
}
  • code ... 强制执行最大行长。默认 80
  • template ... 强制执行 <template> 的最大行长。默认为 code 的值
  • tabWidth ... 指定制表符的字符宽度。默认 2
  • comments ... 强制执行注释的最大行长。默认为 code 的值
  • ignorePattern ... 忽略与正则表达式匹配的行。只能匹配单行,并且在 YAML 或 JSON 中编写时需要双重转义
  • ignoreComments ... 如果为 true,则忽略所有尾随注释和独立行的注释。默认 false
  • ignoreTrailingComments ... 如果为 true,则仅忽略尾随注释。默认 false
  • ignoreUrls ... 如果为 true,则忽略包含 URL 的行。默认 false
  • ignoreStrings ... 如果为 true,则忽略包含双引号或单引号字符串的行。默认 false
  • ignoreTemplateLiterals ... 如果为 true,则忽略包含模板字面量行的。默认 false
  • ignoreRegExpLiterals ... 如果为 true,则忽略包含正则表达式字面量行的。默认 false
  • ignoreHTMLAttributeValues ... 如果为 true,则忽略包含 HTML 属性值的行。默认 false
  • ignoreHTMLTextContents ... 如果为 true,则忽略包含 HTML 文本内容的行。默认 false

"code": 40

正在加载...

"template": 120

正在加载...

"comments": 65

正在加载...

"ignoreComments": true

正在加载...

"ignoreTrailingComments": true

正在加载...

"ignoreUrls": true

正在加载...

"ignoreStrings": true

正在加载...

"ignoreTemplateLiterals": true

正在加载...

"ignoreRegExpLiterals": true

正在加载...

"ignoreHTMLAttributeValues": true

正在加载...

"ignoreHTMLTextContents": true

正在加载...

📚 进一步阅读

🚀 版本

此规则在 eslint-plugin-vue v6.1.0 中引入。

🔍 实现

来自 ESLint 核心,充满 ❤️ 的爱