Skip to content

vue/max-len

强制 .vue 文件中的最大行长度

¥enforce a maximum line length in .vue files

📖 规则详情

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

¥This rule enforces a maximum line length to increase code readability and maintainability. This rule is the similar rule as core max-len rule but it applies to the source code in .vue.

Now loading...

🔧选项

¥🔧 Options

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

    ¥code ... enforces a maximum line length. default 80

  • template ...强制 <template> 的最大行长。默认为 code 的值

    ¥template ... enforces a maximum line length for <template>. defaults to value of code

  • tabWidth ...指定制表符的字符宽度。默认 2

    ¥tabWidth ... specifies the character width for tab characters. default 2

  • comments ...强制注释的最大行长。默认为 code 的值

    ¥comments ... enforces a maximum line length for comments. defaults to value of code

  • ignorePattern ...忽略与正则表达式匹配的行。只能匹配一行,用 YAML 或 JSON 编写时需要双重转义

    ¥ignorePattern ... ignores lines matching a regular expression. can only match a single line and need to be double escaped when written in YAML or JSON

  • ignoreComments ...如果 true,则忽略所有尾随注释和自己一行的注释。默认 false

    ¥ignoreComments ... if true, ignores all trailing comments and comments on their own line. default false

  • ignoreTrailingComments ...如果是 true,则仅忽略尾随注释。默认 false

    ¥ignoreTrailingComments ... if true, ignores only trailing comments. default false

  • ignoreUrls ...如果 true,则忽略包含 URL 的行。默认 false

    ¥ignoreUrls ... if true, ignores lines that contain a URL. default false

  • ignoreStrings ...如果是 true,则忽略包含双引号或单引号字符串的行。默认 false

    ¥ignoreStrings ... if true, ignores lines that contain a double-quoted or single-quoted string. default false

  • ignoreTemplateLiterals ...如果是 true,则忽略包含模板字面量的行。默认 false

    ¥ignoreTemplateLiterals ... if true, ignores lines that contain a template literal. default false

  • ignoreRegExpLiterals ...如果 true,则忽略包含 RegExp 字面量的行。默认 false

    ¥ignoreRegExpLiterals ... if true, ignores lines that contain a RegExp literal. default false

  • ignoreHTMLAttributeValues ...如果 true,则忽略包含 HTML 属性值的行。默认 false

    ¥ignoreHTMLAttributeValues ... if true, ignores lines that contain a HTML attribute value. default false

  • ignoreHTMLTextContents ...如果 true,则忽略包含 HTML 文本内容的行。默认 false

    ¥ignoreHTMLTextContents ... if true, ignores lines that contain a HTML text content. default false

"code": 40

Now loading...

"template": 120

Now loading...

"comments": 65

Now loading...

"ignoreComments": true

Now loading...

"ignoreTrailingComments": true

Now loading...

"ignoreUrls": true

Now loading...

"ignoreStrings": true

Now loading...

"ignoreTemplateLiterals": true

Now loading...

"ignoreRegExpLiterals": true

Now loading...

"ignoreHTMLAttributeValues": true

Now loading...

"ignoreHTMLTextContents": true

Now loading...

📚扩展阅读

¥📚 Further Reading

🚀版本

¥🚀 Version

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

¥This rule was introduced in eslint-plugin-vue v6.1.0

🔍代码实现

¥🔍 Implementation

使用 ❤️ 来自 ESLint 核心

¥Taken with ❤️ from ESLint core

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