@houheaven/eslint-config-helper 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +149 -28
- package/lib/format-es5.js +23 -0
- package/lib/format-es6.js +25 -0
- package/lib/format-html.js +23 -0
- package/lib/format-import.js +23 -0
- package/lib/format-typescript.js +28 -0
- package/lib/format-vue2.js +23 -0
- package/lib/format-vue3.js +23 -0
- package/lib/html.js +13 -22
- package/lib/import.js +23 -0
- package/lib/javascript-es5.js +23 -0
- package/lib/javascript-es6.js +25 -0
- package/lib/rules/eslint/_deprecated.js +132 -0
- package/lib/rules/eslint/_removed.js +25 -0
- package/lib/rules/eslint/es6.js +279 -110
- package/lib/rules/eslint/layout-formatting.js +441 -0
- package/lib/rules/eslint/possible-errors.js +140 -131
- package/lib/rules/eslint/suggestions.js +666 -0
- package/lib/rules/html/accessibility.js +47 -23
- package/lib/rules/html/best-practice.js +122 -36
- package/lib/rules/html/seo.js +16 -11
- package/lib/rules/html/style.js +53 -15
- package/lib/rules/import/helpful-warnings.js +23 -18
- package/lib/rules/import/module-systems.js +16 -17
- package/lib/rules/import/static-analysis.js +54 -38
- package/lib/rules/import/style-guide.js +89 -61
- package/lib/rules/typescript/_deprecated.js +57 -0
- package/lib/rules/typescript/conflict.js +16 -0
- package/lib/rules/typescript/deprecated.js +41 -0
- package/lib/rules/typescript/extension.js +207 -0
- package/lib/rules/typescript/fixable.js +215 -0
- package/lib/rules/typescript/other.js +125 -0
- package/lib/rules/typescript/stylistic.js +34 -0
- package/lib/rules/typescript/suggestion.js +53 -0
- package/lib/rules/typescript/type-checked.js +263 -0
- package/lib/rules/vue/_deprecated.js +37 -0
- package/lib/rules/vue/common-base.js +1 -11
- package/lib/rules/vue/common-essential.js +25 -38
- package/lib/rules/vue/common-extension.js +321 -0
- package/lib/rules/vue/common-recommended.js +64 -31
- package/lib/rules/vue/common-strongly-recommended.js +37 -20
- package/lib/rules/vue/{common-extra.js → common-uncategorized.js} +141 -52
- package/lib/rules/vue/vue2-essential.js +16 -14
- package/lib/rules/vue/vue2-uncategorized.js +15 -0
- package/lib/rules/vue/vue3-essential.js +54 -24
- package/lib/rules/vue/vue3-strongly-recommended.js +8 -10
- package/lib/rules/vue/vue3-uncategorized.js +115 -0
- package/lib/support/es5-support.js +29 -0
- package/lib/support/es6-support.js +39 -0
- package/lib/support/html-support.js +38 -0
- package/lib/support/import-bugfix.js +65 -0
- package/lib/support/import-support.js +25 -0
- package/lib/support/typescript-support.js +27 -0
- package/lib/support/vue2-support.js +43 -0
- package/lib/support/vue3-support.js +43 -0
- package/lib/support/vue3-ts-support.js +51 -0
- package/lib/typescript.js +24 -32
- package/lib/utils/utils.js +160 -0
- package/lib/vue2.js +16 -22
- package/lib/vue3-ts.js +31 -0
- package/lib/vue3.js +13 -17
- package/package.json +38 -22
- package/lib/configs/eslint-es5.js +0 -24
- package/lib/configs/eslint.js +0 -23
- package/lib/configs/format-html.js +0 -22
- package/lib/configs/format-js.js +0 -134
- package/lib/configs/format-vue.js +0 -278
- package/lib/configs/html.js +0 -20
- package/lib/configs/import-bugfix.js +0 -36
- package/lib/configs/import.js +0 -44
- package/lib/configs/typescript.js +0 -10
- package/lib/configs/vue2.js +0 -28
- package/lib/configs/vue3.js +0 -28
- package/lib/eslint.js +0 -18
- package/lib/format.js +0 -40
- package/lib/rules/eslint/best-practices.js +0 -422
- package/lib/rules/eslint/node.js +0 -48
- package/lib/rules/eslint/strict-mode.js +0 -12
- package/lib/rules/eslint/stylistic-issues.js +0 -578
- package/lib/rules/eslint/variables.js +0 -73
- package/lib/rules/typescript/all.js +0 -193
- package/lib/rules/typescript/base.js +0 -10
- package/lib/rules/typescript/eslint-recommended.js +0 -36
- package/lib/rules/typescript/recommended-requiring-type-checking.js +0 -26
- package/lib/rules/typescript/recommended.js +0 -36
- package/lib/rules/typescript/strict.js +0 -47
- package/lib/rules/vue/common-eslint.js +0 -220
- package/lib/rules/vue/vue2-recommended.js +0 -17
- package/lib/rules/vue/vue2-strongly-recommended.js +0 -16
- package/lib/rules/vue/vue3-recommended.js +0 -17
|
@@ -5,40 +5,64 @@
|
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
rules: {
|
|
8
|
-
//
|
|
9
|
-
// https://
|
|
10
|
-
"@html-eslint/
|
|
8
|
+
// 禁止使用抽象的 role 属性
|
|
9
|
+
// https://html-eslint.org/docs/rules/no-abstract-roles
|
|
10
|
+
"@html-eslint/no-abstract-roles": "error",
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
// https://
|
|
14
|
-
"@html-eslint/no-
|
|
12
|
+
// 禁止使用 accesskey 属性(为元素分配键盘快捷键)
|
|
13
|
+
// https://html-eslint.org/docs/rules/no-accesskey-attrs
|
|
14
|
+
"@html-eslint/no-accesskey-attrs": "error",
|
|
15
15
|
|
|
16
|
-
//
|
|
17
|
-
// https://
|
|
18
|
-
"@html-eslint/
|
|
16
|
+
// 禁止在 body 标签上使用 aria-hidden 属性
|
|
17
|
+
// https://html-eslint.org/docs/rules/no-aria-hidden-body
|
|
18
|
+
"@html-eslint/no-aria-hidden-body": "error",
|
|
19
|
+
|
|
20
|
+
// 禁止在可聚焦元素上使用 aria-hidden="true"
|
|
21
|
+
// https://html-eslint.org/docs/rules/no-aria-hidden-on-focusable
|
|
22
|
+
"@html-eslint/no-aria-hidden-on-focusable": "error",
|
|
23
|
+
|
|
24
|
+
// 要求所有标题元素(h1–h6)以及具有“heading”角色的元素都必须有可访问的文本内容
|
|
25
|
+
// https://html-eslint.org/docs/rules/no-empty-headings
|
|
26
|
+
"@html-eslint/no-empty-headings": "off",
|
|
27
|
+
|
|
28
|
+
// 禁止在 <button> 内使用标题元素
|
|
29
|
+
// https://html-eslint.org/docs/rules/no-heading-inside-button
|
|
30
|
+
"@html-eslint/no-heading-inside-button": "error",
|
|
31
|
+
|
|
32
|
+
// 禁止在元素上使用无效的 ARIA role
|
|
33
|
+
// https://html-eslint.org/docs/rules/no-invalid-role
|
|
34
|
+
"@html-eslint/no-invalid-role": "error",
|
|
19
35
|
|
|
20
36
|
// 禁止 <meta name="viewport"> 使用 user-scalable=no
|
|
21
|
-
// https://
|
|
37
|
+
// https://html-eslint.org/docs/rules/no-non-scalable-viewport
|
|
22
38
|
"@html-eslint/no-non-scalable-viewport": "off",
|
|
23
39
|
|
|
24
40
|
// 禁止 tabindex 属性值为正数
|
|
25
|
-
// https://
|
|
41
|
+
// https://html-eslint.org/docs/rules/no-positive-tabindex
|
|
26
42
|
"@html-eslint/no-positive-tabindex": "off",
|
|
27
43
|
|
|
28
|
-
//
|
|
29
|
-
// https://
|
|
30
|
-
"@html-eslint/
|
|
44
|
+
// 禁止 h1-h6 越级显示
|
|
45
|
+
// https://html-eslint.org/docs/rules/no-skip-heading-levels
|
|
46
|
+
"@html-eslint/no-skip-heading-levels": "error",
|
|
31
47
|
|
|
32
|
-
//
|
|
33
|
-
// https://
|
|
34
|
-
"@html-eslint/
|
|
48
|
+
// 强制要求在 <form> 元素上使用有效的 method 属性
|
|
49
|
+
// https://html-eslint.org/docs/rules/require-form-method
|
|
50
|
+
"@html-eslint/require-form-method": "off",
|
|
35
51
|
|
|
36
|
-
//
|
|
37
|
-
// https://
|
|
38
|
-
"@html-eslint/
|
|
52
|
+
// 要求 frame、iframe 标签设置 title 属性
|
|
53
|
+
// https://html-eslint.org/docs/rules/require-frame-title
|
|
54
|
+
"@html-eslint/require-frame-title": "error",
|
|
55
|
+
|
|
56
|
+
// 要求 img 标签必须设置 alt 属性
|
|
57
|
+
// https://html-eslint.org/docs/rules/require-img-alt
|
|
58
|
+
"@html-eslint/require-img-alt": "error",
|
|
59
|
+
|
|
60
|
+
// 强制要求为输入元素(如<input type="text">, <select>和<textarea>)提供无障碍标签
|
|
61
|
+
// https://html-eslint.org/docs/rules/require-input-label
|
|
62
|
+
"@html-eslint/require-input-label": "off",
|
|
39
63
|
|
|
40
|
-
//
|
|
41
|
-
// https://
|
|
42
|
-
"@html-eslint/
|
|
64
|
+
// 要求 <head> 中必须设置 <meta name="viewport">
|
|
65
|
+
// https://html-eslint.org/docs/rules/require-meta-viewport
|
|
66
|
+
"@html-eslint/require-meta-viewport": "error",
|
|
43
67
|
},
|
|
44
68
|
};
|
|
@@ -5,60 +5,146 @@
|
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
rules: {
|
|
8
|
-
//
|
|
9
|
-
// https://
|
|
10
|
-
"@html-eslint/
|
|
8
|
+
// 强制规定 HTML 元素嵌套的最大允许深度
|
|
9
|
+
// https://html-eslint.org/docs/rules/max-element-depth
|
|
10
|
+
"@html-eslint/max-element-depth": ["error", {
|
|
11
|
+
max: 8,
|
|
12
|
+
}],
|
|
13
|
+
|
|
14
|
+
// 禁止使用重复的属性
|
|
15
|
+
// https://html-eslint.org/docs/rules/no-duplicate-attrs
|
|
16
|
+
"@html-eslint/no-duplicate-attrs": "error",
|
|
17
|
+
|
|
18
|
+
// 禁止 class 属性中的类名重复
|
|
19
|
+
// https://html-eslint.org/docs/rules/no-duplicate-class
|
|
20
|
+
"@html-eslint/no-duplicate-class": "warn",
|
|
11
21
|
|
|
12
22
|
// 禁止 id 属性重复
|
|
13
|
-
// https://
|
|
23
|
+
// https://html-eslint.org/docs/rules/no-duplicate-id
|
|
14
24
|
"@html-eslint/no-duplicate-id": "error",
|
|
15
25
|
|
|
26
|
+
// <head> 标签中禁止使用重复的元素(<title>、<base>、<meta charset>、<meta name="viewport">、<link rel="canonical">)
|
|
27
|
+
// https://html-eslint.org/docs/rules/no-duplicate-in-head
|
|
28
|
+
"@html-eslint/no-duplicate-in-head": "error",
|
|
29
|
+
|
|
16
30
|
// 禁止使用行内样式
|
|
17
|
-
// https://
|
|
18
|
-
"@html-eslint/no-inline-styles": "
|
|
31
|
+
// https://html-eslint.org/docs/rules/no-inline-styles
|
|
32
|
+
"@html-eslint/no-inline-styles": "error",
|
|
19
33
|
|
|
20
|
-
//
|
|
21
|
-
// https://
|
|
22
|
-
"@html-eslint/
|
|
34
|
+
// 禁止使用无效的 HTML 实体
|
|
35
|
+
// https://html-eslint.org/docs/rules/no-invalid-entity
|
|
36
|
+
"@html-eslint/no-invalid-entity": "error",
|
|
37
|
+
|
|
38
|
+
// 禁止交互元素之间相互嵌套
|
|
39
|
+
// https://html-eslint.org/docs/rules/no-nested-interactive
|
|
40
|
+
"@html-eslint/no-nested-interactive": "error",
|
|
23
41
|
|
|
24
42
|
// 禁止在 HTML5 中使用过时的标签
|
|
25
|
-
//
|
|
26
|
-
|
|
43
|
+
// applet, acronym, bgsound, dir, frame, frameset, noframes, isindex, keygen, listing, menuitem, nextid, noembed,
|
|
44
|
+
// plaintext, rb, rtc, strike, xmp, basefont, big, blink, center, font, marquee, multicol, nobr, spacer, tt
|
|
45
|
+
// https://html-eslint.org/docs/rules/no-obsolete-tags
|
|
46
|
+
"@html-eslint/no-obsolete-tags": "error",
|
|
27
47
|
|
|
28
|
-
//
|
|
29
|
-
// https://
|
|
30
|
-
"@html-eslint/
|
|
48
|
+
// 禁止使用指定的属性值
|
|
49
|
+
// https://html-eslint.org/docs/rules/no-restricted-attr-values
|
|
50
|
+
"@html-eslint/no-restricted-attr-values": [
|
|
51
|
+
"error",
|
|
52
|
+
{
|
|
53
|
+
attrPatterns: ["class", "alt"],
|
|
54
|
+
attrValuePatterns: ["data-test-.*"],
|
|
55
|
+
message: "'data-test-x' is restricted.",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
attrPatterns: [".*"],
|
|
59
|
+
attrValuePatterns: ["^fooooo$"],
|
|
60
|
+
message: "'fooooo' is restricted.",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
31
63
|
|
|
32
|
-
//
|
|
33
|
-
// https://
|
|
34
|
-
"@html-eslint/
|
|
64
|
+
// 禁用特定的属性
|
|
65
|
+
// https://html-eslint.org/docs/rules/no-restricted-attrs
|
|
66
|
+
"@html-eslint/no-restricted-attrs": [
|
|
67
|
+
"error",
|
|
68
|
+
{
|
|
69
|
+
tagPatterns: ["^div$", "^img$"],
|
|
70
|
+
attrPatterns: ["test-.*"],
|
|
71
|
+
message: "'test-x' is restricted.",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
tagPatterns: ["^p$"],
|
|
75
|
+
attrPatterns: ["^test$"],
|
|
76
|
+
message: "'test' is restricted.",
|
|
77
|
+
},
|
|
78
|
+
],
|
|
35
79
|
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
80
|
+
// 禁止在 <style> 中使用类型属性(除非不使用CSS),以及在 <script> 中使用类型属性(除非使用的语言与CSS/JavaScript不同)
|
|
81
|
+
// HTML5 默认值如下:
|
|
82
|
+
// <script> - type="text/javascript"
|
|
83
|
+
// <style>, <link> - type="text/css"
|
|
84
|
+
// https://html-eslint.org/docs/rules/no-script-style-type
|
|
85
|
+
"@html-eslint/no-script-style-type": "off",
|
|
39
86
|
|
|
40
|
-
//
|
|
41
|
-
// https://
|
|
42
|
-
"@html-eslint/no-
|
|
87
|
+
// 禁止使用不安全的 target='_blank' 属性(需要加上 rel="noreferrer")
|
|
88
|
+
// https://html-eslint.org/docs/rules/no-target-blank
|
|
89
|
+
"@html-eslint/no-target-blank": "off",
|
|
43
90
|
|
|
44
|
-
//
|
|
45
|
-
// https://
|
|
46
|
-
"@html-eslint/
|
|
91
|
+
// 强制要求使用 HTTPS 处理嵌入的资源(image、media、style、script)
|
|
92
|
+
// https://html-eslint.org/docs/rules/prefer-https
|
|
93
|
+
"@html-eslint/prefer-https": "off",
|
|
47
94
|
|
|
48
|
-
//
|
|
49
|
-
// https://
|
|
50
|
-
"@html-eslint/
|
|
51
|
-
"
|
|
95
|
+
// 强制要求使用指定属性
|
|
96
|
+
// https://html-eslint.org/docs/rules/require-attrs
|
|
97
|
+
"@html-eslint/require-attrs": [
|
|
98
|
+
"error",
|
|
52
99
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
message: "'data-x' is restricted.",
|
|
100
|
+
tag: "img",
|
|
101
|
+
attr: "alt",
|
|
56
102
|
},
|
|
57
103
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
104
|
+
tag: "test-svg",
|
|
105
|
+
attr: "viewBox",
|
|
106
|
+
value: "0 0 100 100",
|
|
61
107
|
},
|
|
62
108
|
],
|
|
109
|
+
|
|
110
|
+
// 强制要求 button 标签设置一个有效的 type 属性
|
|
111
|
+
// https://html-eslint.org/docs/rules/require-button-type
|
|
112
|
+
"@html-eslint/require-button-type": "off",
|
|
113
|
+
|
|
114
|
+
// 强制要求标签闭合
|
|
115
|
+
// https://html-eslint.org/docs/rules/require-closing-tags
|
|
116
|
+
"@html-eslint/require-closing-tags": ["warn", {
|
|
117
|
+
selfClosing: "always",
|
|
118
|
+
selfClosingCustomPatterns: ["-"],
|
|
119
|
+
}],
|
|
120
|
+
|
|
121
|
+
// 强制要求设置 <!DOCTYPE html> 文档申明
|
|
122
|
+
// https://html-eslint.org/docs/rules/require-doctype
|
|
123
|
+
"@html-eslint/require-doctype": "warn",
|
|
124
|
+
|
|
125
|
+
// 强制要求某些元素(如 img 和 iframe)必须明确设置宽度和高度属性
|
|
126
|
+
// https://html-eslint.org/docs/rules/require-explicit-size
|
|
127
|
+
"@html-eslint/require-explicit-size": ["off", {
|
|
128
|
+
allowClass: ["has-size-class"],
|
|
129
|
+
allowId: ["has-size-id", "has-size-id2"],
|
|
130
|
+
}],
|
|
131
|
+
|
|
132
|
+
// 强制 <li> 必须包裹在 <ul>、<ol>、<menu> 中
|
|
133
|
+
// https://html-eslint.org/docs/rules/require-li-container
|
|
134
|
+
"@html-eslint/require-li-container": "error",
|
|
135
|
+
|
|
136
|
+
// 强制在 <head> 中使用 <meta charset="..."> 文件编码
|
|
137
|
+
// https://html-eslint.org/docs/rules/require-meta-charset
|
|
138
|
+
"@html-eslint/require-meta-charset": "error",
|
|
139
|
+
|
|
140
|
+
// 该规则强制使用基线特征
|
|
141
|
+
// 新推出(Newly available):该功能适用于最新的设备和浏览器版本,该功能可能在较旧设备或浏览器上无法使用
|
|
142
|
+
// 广泛可用(Widely available):该功能已确立并得到广泛支持,适用于多种设备和浏览器版本,它已经在多个浏览器中提供至少两年半(30个月)了
|
|
143
|
+
// https://html-eslint.org/docs/rules/use-baseline
|
|
144
|
+
"@html-eslint/use-baseline": ["error", {
|
|
145
|
+
// available: "newly",
|
|
146
|
+
available: "widely",
|
|
147
|
+
// available: 2020,
|
|
148
|
+
}],
|
|
63
149
|
},
|
|
64
150
|
};
|
package/lib/rules/html/seo.js
CHANGED
|
@@ -5,20 +5,25 @@
|
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
rules: {
|
|
8
|
-
//
|
|
9
|
-
// https://
|
|
8
|
+
// 禁止多个 <h1> 标签
|
|
9
|
+
// https://html-eslint.org/docs/rules/no-multiple-h1
|
|
10
|
+
"@html-eslint/no-multiple-h1": "error",
|
|
11
|
+
|
|
12
|
+
// 强制要求 <html> 标签必须有 lang 属性
|
|
13
|
+
// https://html-eslint.org/docs/rules/require-lang
|
|
10
14
|
"@html-eslint/require-lang": "off",
|
|
11
15
|
|
|
12
|
-
//
|
|
13
|
-
// https://
|
|
14
|
-
"@html-eslint/require-
|
|
16
|
+
// 强制要求 <head> 标签中必须有 <meta name="description" ...>
|
|
17
|
+
// https://html-eslint.org/docs/rules/require-meta-description
|
|
18
|
+
"@html-eslint/require-meta-description": "error",
|
|
15
19
|
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
|
|
20
|
+
// 强制要求使用指定的元标签以实现开放图协议
|
|
21
|
+
// 默认值:["og:title", "og:type", "og:url", "og:image"]
|
|
22
|
+
// https://html-eslint.org/docs/rules/require-open-graph-protocol
|
|
23
|
+
"@html-eslint/require-open-graph-protocol": "off",
|
|
19
24
|
|
|
20
|
-
//
|
|
21
|
-
// https://
|
|
22
|
-
"@html-eslint/
|
|
25
|
+
// 强制要求 <head> 标签中必须有 <title> 标签
|
|
26
|
+
// https://html-eslint.org/docs/rules/require-title
|
|
27
|
+
"@html-eslint/require-title": "error",
|
|
23
28
|
},
|
|
24
29
|
};
|
package/lib/rules/html/style.js
CHANGED
|
@@ -5,28 +5,66 @@
|
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
rules: {
|
|
8
|
-
//
|
|
9
|
-
// https://
|
|
10
|
-
"@html-eslint/
|
|
8
|
+
// 元素属性数量超过指定数量时,强制在属性之间添加换行符
|
|
9
|
+
// https://html-eslint.org/docs/rules/attrs-newline
|
|
10
|
+
"@html-eslint/attrs-newline": ["warn", {
|
|
11
|
+
ifAttrsMoreThan: 6,
|
|
12
|
+
closeStyle: "newline",
|
|
13
|
+
}],
|
|
11
14
|
|
|
12
15
|
// 要求标签之间使用换行
|
|
13
|
-
// https://
|
|
14
|
-
"@html-eslint/element-newline": "
|
|
16
|
+
// https://html-eslint.org/docs/rules/element-newline
|
|
17
|
+
"@html-eslint/element-newline": ["warn", {
|
|
18
|
+
skip: ["pre", "code", "tr", "label", "h1"],
|
|
19
|
+
// 行内元素可以不用换行
|
|
20
|
+
inline: ["$inline"],
|
|
21
|
+
}],
|
|
15
22
|
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
|
|
23
|
+
// 强制 id 属性命名规范
|
|
24
|
+
// 取值:camelCase、snake_case、PascalCase、kebab-case
|
|
25
|
+
// https://html-eslint.org/docs/rules/id-naming-convention
|
|
26
|
+
"@html-eslint/id-naming-convention": ["error", "kebab-case"],
|
|
19
27
|
|
|
20
|
-
//
|
|
21
|
-
// https://
|
|
22
|
-
"@html-eslint/
|
|
28
|
+
// 强制使用一致的缩进
|
|
29
|
+
// https://html-eslint.org/docs/rules/indent
|
|
30
|
+
"@html-eslint/indent": ["warn", 2, {
|
|
31
|
+
Attribute: 1,
|
|
32
|
+
tagChildrenIndent: {
|
|
33
|
+
html: 0,
|
|
34
|
+
},
|
|
35
|
+
}],
|
|
23
36
|
|
|
24
|
-
//
|
|
25
|
-
// https://
|
|
26
|
-
"@html-eslint/
|
|
37
|
+
// 强制标签和属性名称使用小写
|
|
38
|
+
// https://html-eslint.org/docs/rules/lowercase
|
|
39
|
+
"@html-eslint/lowercase": "warn",
|
|
40
|
+
|
|
41
|
+
// 禁止标签属性周围出现多余的空格
|
|
42
|
+
// https://html-eslint.org/docs/rules/no-extra-spacing-attrs
|
|
43
|
+
"@html-eslint/no-extra-spacing-attrs": ["warn", {
|
|
44
|
+
enforceBeforeSelfClose: true,
|
|
45
|
+
disallowMissing: true,
|
|
46
|
+
disallowTabs: true,
|
|
47
|
+
disallowInAssignment: true,
|
|
48
|
+
}],
|
|
49
|
+
|
|
50
|
+
// 禁止文本和注释中有多个连续的空格或 tab
|
|
51
|
+
// https://html-eslint.org/docs/rules/no-extra-spacing-text
|
|
52
|
+
"@html-eslint/no-extra-spacing-text": ["warn", {
|
|
53
|
+
skip: ["pre"],
|
|
54
|
+
}],
|
|
27
55
|
|
|
28
56
|
// 禁止出现多个空行
|
|
29
|
-
// https://
|
|
57
|
+
// https://html-eslint.org/docs/rules/no-multiple-empty-lines
|
|
30
58
|
"@html-eslint/no-multiple-empty-lines": ["warn", { max: 2 }],
|
|
59
|
+
|
|
60
|
+
// 禁止出现行末空格
|
|
61
|
+
// https://html-eslint.org/docs/rules/no-trailing-spaces
|
|
62
|
+
"@html-eslint/no-trailing-spaces": "warn",
|
|
63
|
+
|
|
64
|
+
// 强制使用一致的引号
|
|
65
|
+
// https://html-eslint.org/docs/rules/quotes
|
|
66
|
+
"@html-eslint/quotes": ["warn", "double", {
|
|
67
|
+
enforceTemplatedAttrValue: true,
|
|
68
|
+
}],
|
|
31
69
|
},
|
|
32
70
|
};
|
|
@@ -6,25 +6,21 @@
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
rules: {
|
|
8
8
|
// 禁止无效的导出(重复导出名称或默认值)
|
|
9
|
-
// https://github.com/
|
|
9
|
+
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/export.md
|
|
10
10
|
"import/export": "error",
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
// https://github.com/
|
|
14
|
-
"import/no-
|
|
12
|
+
// 禁止导入被 JSDoc(@deprecated)、TomDoc(Deprecated:)标记为废弃的函数
|
|
13
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-deprecated.md
|
|
14
|
+
"import/no-deprecated": "error",
|
|
15
15
|
|
|
16
|
-
//
|
|
17
|
-
// https://github.com/
|
|
18
|
-
"import/no-named-
|
|
19
|
-
|
|
20
|
-
// 禁止使用 jsdoc-marked-deprecated 导入
|
|
21
|
-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
|
|
22
|
-
"import/no-deprecated": "off",
|
|
16
|
+
// 禁止空的命名导入块
|
|
17
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-empty-named-blocks.md
|
|
18
|
+
"import/no-empty-named-blocks": "warn",
|
|
23
19
|
|
|
24
20
|
// 禁止使用无关的包
|
|
25
|
-
// https://github.com/
|
|
21
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-extraneous-dependencies.md
|
|
26
22
|
// paths are treated both as absolute paths, and relative to process.cwd()
|
|
27
|
-
"import/no-extraneous-dependencies": ["
|
|
23
|
+
"import/no-extraneous-dependencies": ["off", {
|
|
28
24
|
devDependencies: [
|
|
29
25
|
"test/**", // tape, common npm pattern
|
|
30
26
|
"tests/**", // also common npm pattern
|
|
@@ -55,14 +51,23 @@ module.exports = {
|
|
|
55
51
|
// 禁止使用易变的导出(var、let)
|
|
56
52
|
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
|
|
57
53
|
"import/no-mutable-exports": "error",
|
|
54
|
+
|
|
55
|
+
// 禁止命名后的变量、函数作为默认导入的名称
|
|
56
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-named-as-default.md
|
|
57
|
+
"import/no-named-as-default": "error",
|
|
58
|
+
|
|
59
|
+
// warn on accessing default export property names that are also named exports
|
|
60
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-named-as-default-member.md
|
|
61
|
+
"import/no-named-as-default-member": "error",
|
|
58
62
|
|
|
59
|
-
//
|
|
60
|
-
// https://github.com/
|
|
61
|
-
// TODO: enable once it supports CJS
|
|
63
|
+
// 模块没有任何导出,或者导出后,没有被项目其他文件所使用
|
|
64
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-unused-modules.md
|
|
62
65
|
"import/no-unused-modules": ["off", {
|
|
66
|
+
missingExports: false, // 文件中没有任何导出 export
|
|
67
|
+
unusedExports: true, // 文件导出后,没有被项目其他文件所使用
|
|
68
|
+
ignoreUnusedTypeExports: false, // 是否忽略 TS 中未使用的类型声明
|
|
63
69
|
ignoreExports: [],
|
|
64
|
-
|
|
65
|
-
unusedExports: true,
|
|
70
|
+
// src: [],
|
|
66
71
|
}],
|
|
67
72
|
},
|
|
68
73
|
};
|
|
@@ -5,30 +5,29 @@
|
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
rules: {
|
|
8
|
-
// Warn if a module could be mistakenly parsed as a script by a consumer
|
|
9
|
-
// leveraging Unambiguous JavaScript Grammar
|
|
10
|
-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
|
|
11
|
-
// this should not be enabled until this proposal has at least been *presented* to TC39.
|
|
12
|
-
// At the moment, it"s not a thing.
|
|
13
|
-
"import/unambiguous": "off",
|
|
14
|
-
|
|
15
|
-
// 禁用 require()
|
|
16
|
-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
|
|
17
|
-
"import/no-commonjs": "off",
|
|
18
|
-
|
|
19
8
|
// 禁用 AMD require/define
|
|
20
|
-
// https://github.com/
|
|
9
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-amd.md
|
|
21
10
|
"import/no-amd": "error",
|
|
22
11
|
|
|
23
|
-
// 禁用
|
|
24
|
-
// https://github.com/
|
|
25
|
-
"import/no-
|
|
26
|
-
|
|
12
|
+
// 禁用 commonjs require()
|
|
13
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-commonjs.md
|
|
14
|
+
"import/no-commonjs": "off",
|
|
15
|
+
|
|
27
16
|
// 除了主模块以外,在使用 CommonJS 导出的任何文件中都不能使用 import 声明
|
|
28
|
-
// https://github.com/
|
|
17
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-import-module-exports.md
|
|
29
18
|
"import/no-import-module-exports": ["error", {
|
|
30
19
|
exceptions: [],
|
|
31
20
|
}],
|
|
32
21
|
|
|
22
|
+
// 禁用 Node.js 内置模块
|
|
23
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-nodejs-modules.md
|
|
24
|
+
"import/no-nodejs-modules": ["off", {
|
|
25
|
+
"allow": ["path"],
|
|
26
|
+
}],
|
|
27
|
+
|
|
28
|
+
// 强制导入模块时使用绝对路径或相对路径,而不是别名或别名路径
|
|
29
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/unambiguous.md
|
|
30
|
+
"import/unambiguous": "off",
|
|
31
|
+
|
|
33
32
|
},
|
|
34
33
|
};
|
|
@@ -5,65 +5,81 @@
|
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
rules: {
|
|
8
|
-
//
|
|
9
|
-
// https://github.com/
|
|
10
|
-
"import/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
// 确保默认导入时,原模块中存在默认导出
|
|
9
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/default.md
|
|
10
|
+
"import/default": "error",
|
|
11
|
+
|
|
12
|
+
// 在导入 Node.js 内置模块时,可以强制使用或省略 "node:" 协议。
|
|
13
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/enforce-node-protocol-usage.md
|
|
14
|
+
"import/enforce-node-protocol-usage": ["warn", "never"],
|
|
14
15
|
|
|
15
16
|
// 确保命名导入时,原模块中存在导出的值
|
|
16
|
-
// https://github.com/
|
|
17
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/named.md
|
|
17
18
|
"import/named": "error",
|
|
18
19
|
|
|
19
|
-
// 确保默认导入时,原模块中存在默认导出
|
|
20
|
-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
|
|
21
|
-
"import/default": "error",
|
|
22
|
-
|
|
23
20
|
// 确保命名空间导入时,原模块中存在导出的值
|
|
24
|
-
// https://github.com/
|
|
25
|
-
"import/namespace": "error",
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
|
|
29
|
-
"import/no-restricted-paths": "off",
|
|
21
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/namespace.md
|
|
22
|
+
"import/namespace": ["error", {
|
|
23
|
+
allowComputed: false,
|
|
24
|
+
}],
|
|
30
25
|
|
|
31
26
|
// 禁止使用绝对路径导入模块
|
|
32
|
-
// https://github.com/
|
|
33
|
-
"import/no-absolute-path": "
|
|
27
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-absolute-path.md
|
|
28
|
+
"import/no-absolute-path": "warn",
|
|
29
|
+
|
|
30
|
+
// 禁止模块间的死循环相互导入
|
|
31
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-cycle.md
|
|
32
|
+
"import/no-cycle": ["error", {
|
|
33
|
+
maxDepth: "∞",
|
|
34
|
+
ignoreExternal: true,
|
|
35
|
+
}],
|
|
34
36
|
|
|
35
37
|
// 禁止 require() 使用表达式调用
|
|
36
|
-
// https://github.com/
|
|
38
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-dynamic-require.md
|
|
37
39
|
"import/no-dynamic-require": "error",
|
|
38
40
|
|
|
39
41
|
// 防止导入其他模块的子模块
|
|
40
|
-
// https://github.com/
|
|
42
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-internal-modules.md
|
|
41
43
|
"import/no-internal-modules": ["off", {
|
|
42
44
|
allow: [],
|
|
43
45
|
}],
|
|
44
46
|
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
|
|
47
|
+
// 防止通过相对路径导入包
|
|
48
|
+
// 适用于类似 monorepo 仓库中,不能通过相对路径来引入包
|
|
49
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-relative-packages.md
|
|
50
|
+
"import/no-relative-packages": "off",
|
|
51
|
+
|
|
52
|
+
// 防止导入到相对父路径中的文件夹
|
|
53
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-relative-parent-imports.md
|
|
54
|
+
"import/no-relative-parent-imports": "off",
|
|
55
|
+
|
|
56
|
+
// 限制特定文件夹中的文件不能被导入
|
|
57
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
|
|
58
|
+
"import/no-restricted-paths": "off",
|
|
48
59
|
|
|
49
60
|
// 禁止模块导入自身
|
|
50
|
-
// https://github.com/
|
|
61
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-self-import.md
|
|
51
62
|
"import/no-self-import": "error",
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
// https://github.com/
|
|
55
|
-
"import/no-
|
|
63
|
+
|
|
64
|
+
// 确保导入的文件/模块必须存在
|
|
65
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-unresolved.md
|
|
66
|
+
"import/no-unresolved": ["error", {
|
|
67
|
+
amd: true,
|
|
68
|
+
commonjs: true,
|
|
69
|
+
caseSensitive: true,
|
|
70
|
+
caseSensitiveStrict: true,
|
|
71
|
+
// ignore: [],
|
|
72
|
+
}],
|
|
56
73
|
|
|
57
74
|
// 导入时防止出现不必要的路径部分
|
|
58
|
-
// https://github.com/
|
|
59
|
-
"import/no-useless-path-segments": ["
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"import/no-relative-parent-imports": "off",
|
|
75
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-useless-path-segments.md
|
|
76
|
+
"import/no-useless-path-segments": ["warn", {
|
|
77
|
+
commonjs: true,
|
|
78
|
+
noUselessIndex: false,
|
|
79
|
+
}],
|
|
64
80
|
|
|
65
|
-
//
|
|
66
|
-
// https://github.com/
|
|
67
|
-
"import/no-
|
|
81
|
+
// 禁止在导入时使用 webpack loader 语法
|
|
82
|
+
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-webpack-loader-syntax.md
|
|
83
|
+
"import/no-webpack-loader-syntax": "error",
|
|
68
84
|
},
|
|
69
85
|
};
|