Appearance
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
.
🔧选项
¥🔧 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. default80
template
...强制<template>
的最大行长。默认为code
的值¥
template
... enforces a maximum line length for<template>
. defaults to value ofcode
tabWidth
...指定制表符的字符宽度。默认2
¥
tabWidth
... specifies the character width for tab characters. default2
comments
...强制注释的最大行长。默认为code
的值¥
comments
... enforces a maximum line length for comments. defaults to value ofcode
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 JSONignoreComments
...如果true
,则忽略所有尾随注释和自己一行的注释。默认false
¥
ignoreComments
... iftrue
, ignores all trailing comments and comments on their own line. defaultfalse
ignoreTrailingComments
...如果是true
,则仅忽略尾随注释。默认false
¥
ignoreTrailingComments
... iftrue
, ignores only trailing comments. defaultfalse
ignoreUrls
...如果true
,则忽略包含 URL 的行。默认false
¥
ignoreUrls
... iftrue
, ignores lines that contain a URL. defaultfalse
ignoreStrings
...如果是true
,则忽略包含双引号或单引号字符串的行。默认false
¥
ignoreStrings
... iftrue
, ignores lines that contain a double-quoted or single-quoted string. defaultfalse
ignoreTemplateLiterals
...如果是true
,则忽略包含模板字面量的行。默认false
¥
ignoreTemplateLiterals
... iftrue
, ignores lines that contain a template literal. defaultfalse
ignoreRegExpLiterals
...如果true
,则忽略包含 RegExp 字面量的行。默认false
¥
ignoreRegExpLiterals
... iftrue
, ignores lines that contain a RegExp literal. defaultfalse
ignoreHTMLAttributeValues
...如果true
,则忽略包含 HTML 属性值的行。默认false
¥
ignoreHTMLAttributeValues
... iftrue
, ignores lines that contain a HTML attribute value. defaultfalse
ignoreHTMLTextContents
...如果true
,则忽略包含 HTML 文本内容的行。默认false
¥
ignoreHTMLTextContents
... iftrue
, ignores lines that contain a HTML text content. defaultfalse
"code": 40
"template": 120
"comments": 65
"ignoreComments": true
"ignoreTrailingComments": true
"ignoreUrls": true
"ignoreStrings": true
"ignoreTemplateLiterals": true
"ignoreRegExpLiterals": true
"ignoreHTMLAttributeValues": true
"ignoreHTMLTextContents": true
📚扩展阅读
¥📚 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