@huangjunsen/eslint-config 1.0.0 → 1.0.2

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.
Files changed (56) hide show
  1. package/.editorconfig +17 -17
  2. package/.eslintignore +17 -17
  3. package/.eslintrc.js +5 -5
  4. package/CHANGELOG.md +7 -0
  5. package/README.md +0 -286
  6. package/__tests__/fixtures/es5.js +4 -4
  7. package/__tests__/fixtures/index.js +3 -3
  8. package/__tests__/fixtures/node.js +23 -23
  9. package/__tests__/fixtures/react-display-name.js +7 -7
  10. package/__tests__/fixtures/react.jsx +132 -132
  11. package/__tests__/fixtures/ts-import-a.ts +3 -3
  12. package/__tests__/fixtures/ts-import-b.ts +3 -3
  13. package/__tests__/fixtures/ts-node.ts +19 -19
  14. package/__tests__/fixtures/ts-react.tsx +27 -27
  15. package/__tests__/fixtures/ts-vue.vue +36 -36
  16. package/__tests__/fixtures/ts.ts +17 -17
  17. package/__tests__/fixtures/vue.vue +16 -16
  18. package/__tests__/validate-js-configs.test.js +259 -259
  19. package/es5.js +10 -10
  20. package/essential/es5.js +12 -12
  21. package/essential/index.js +12 -12
  22. package/essential/react.js +76 -76
  23. package/essential/rules/blacklist.js +48 -48
  24. package/essential/rules/es6-blacklist.js +62 -62
  25. package/essential/rules/set-style-to-warn.js +30 -30
  26. package/essential/rules/ts-blacklist.js +15 -15
  27. package/essential/typescript/index.js +7 -7
  28. package/essential/typescript/react.js +7 -7
  29. package/essential/typescript/vue.js +9 -9
  30. package/essential/vue.js +8 -8
  31. package/flat/index.js +32 -0
  32. package/flat/react.js +19 -0
  33. package/flat/typescript.js +15 -0
  34. package/flat/vue.js +12 -0
  35. package/index.js +23 -23
  36. package/jsx-a11y.js +5 -5
  37. package/node.js +6 -6
  38. package/package.json +28 -10
  39. package/react.js +11 -11
  40. package/rules/base/best-practices.js +284 -284
  41. package/rules/base/es6.js +168 -168
  42. package/rules/base/possible-errors.js +126 -126
  43. package/rules/base/strict.js +6 -6
  44. package/rules/base/style.js +445 -445
  45. package/rules/base/variables.js +48 -48
  46. package/rules/es5.js +11 -11
  47. package/rules/imports.js +167 -167
  48. package/rules/jsx-a11y.js +23 -23
  49. package/rules/node.js +11 -11
  50. package/rules/react.js +354 -354
  51. package/rules/vue.js +96 -96
  52. package/typescript/node.js +6 -6
  53. package/typescript/react.js +6 -6
  54. package/typescript/vue.js +10 -10
  55. package/vue.js +10 -10
  56. package/LICENSE +0 -21
package/rules/vue.js CHANGED
@@ -1,96 +1,96 @@
1
- /**
2
- * 本文件的规则由 eslint-plugin-vue 提供,使用 vue-eslint-parser 作为 parser
3
- * @link https://eslint.vuejs.org/rules/
4
- */
5
-
6
- module.exports = {
7
- parser: 'vue-eslint-parser',
8
- plugins: ['vue'],
9
- rules: {
10
- // 给 template 提供 eslint-disable 的能力,支持如下注释:
11
- // eslint-disable,eslint-enable,eslint-disable-line,eslint-disable-next-line
12
- 'vue/comment-directive': 'error',
13
-
14
- // 本条是对JS规范 no-unused-vars 的补充,防止变量被错误地标记为未使用
15
- 'vue/jsx-uses-vars': 'error',
16
-
17
- // 组件的 data 必须是一个函数
18
- 'vue/no-shared-component-data': 'error',
19
-
20
- // Prop 定义类型应该是构造函数
21
- 'vue/require-prop-type-constructor': 'error',
22
-
23
- // Prop 的默认值必须匹配它的类型
24
- 'vue/require-valid-default-prop': 'error',
25
-
26
- // 为 v-for 设置键值
27
- 'vue/require-v-for-key': 'error',
28
-
29
- // 避免 v-if 和 v-for 用在一起
30
- 'vue/no-use-v-if-with-v-for': 'warn',
31
-
32
- // 计算属性禁止包含异步方法
33
- 'vue/no-async-in-computed-properties': 'error',
34
-
35
- // 禁止在对象字面量中出现重复的键
36
- 'vue/no-dupe-keys': 'error',
37
-
38
- // 禁止出现重复的属性
39
- 'vue/no-duplicate-attributes': 'error',
40
-
41
- // 禁止出现语法错误
42
- // @link https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
43
- 'vue/no-parsing-error': [
44
- 'error',
45
- {
46
- 'x-invalid-end-tag': false,
47
- 'invalid-first-character-of-tag-name': false,
48
- },
49
- ],
50
-
51
- // 禁止使用 vue 中的关键字
52
- 'vue/no-reserved-keys': 'error',
53
-
54
- // 禁止在计算属性中对属性修改
55
- 'vue/no-side-effects-in-computed-properties': 'error',
56
-
57
- // 禁止 <template> 使用 key 属性
58
- 'vue/no-template-key': 'warn',
59
-
60
- // 禁止在 <textarea> 中出现 {{message}}
61
- 'vue/no-textarea-mustache': 'error',
62
-
63
- // 禁止注册没有使用的组件
64
- 'vue/no-unused-components': 'warn',
65
-
66
- // 禁止在 v-for 等指令或者 scope 中申明没有使用到的变量
67
- 'vue/no-unused-vars': 'warn',
68
-
69
- // <component> 必须有 v-bind:is
70
- 'vue/require-component-is': 'warn',
71
-
72
- // render 函数必须有返回值
73
- 'vue/require-render-return': 'error',
74
-
75
- // 计算属性必须有返回值
76
- 'vue/return-in-computed-property': 'error',
77
-
78
- // 强制在 v-on 指令使用 exact 修饰符,当同一个标签上有另一个带修饰符的 v-on 指令
79
- 'vue/use-v-on-exact': 'error',
80
-
81
- // 检查指令的合法性
82
- 'vue/valid-template-root': 'error',
83
- 'vue/valid-v-bind': 'error',
84
- 'vue/valid-v-cloak': 'error',
85
- 'vue/valid-v-else-if': 'error',
86
- 'vue/valid-v-else': 'error',
87
- 'vue/valid-v-for': 'error',
88
- 'vue/valid-v-html': 'error',
89
- 'vue/valid-v-if': 'error',
90
- 'vue/valid-v-model': 'error',
91
- 'vue/valid-v-on': 'error',
92
- 'vue/valid-v-once': 'error',
93
- 'vue/valid-v-pre': 'error',
94
- 'vue/valid-v-show': 'error',
95
- },
96
- };
1
+ /**
2
+ * 本文件的规则由 eslint-plugin-vue 提供,使用 vue-eslint-parser 作为 parser
3
+ * @link https://eslint.vuejs.org/rules/
4
+ */
5
+
6
+ module.exports = {
7
+ parser: 'vue-eslint-parser',
8
+ plugins: ['vue'],
9
+ rules: {
10
+ // 给 template 提供 eslint-disable 的能力,支持如下注释:
11
+ // eslint-disable,eslint-enable,eslint-disable-line,eslint-disable-next-line
12
+ 'vue/comment-directive': 'error',
13
+
14
+ // 本条是对JS规范 no-unused-vars 的补充,防止变量被错误地标记为未使用
15
+ 'vue/jsx-uses-vars': 'error',
16
+
17
+ // 组件的 data 必须是一个函数
18
+ 'vue/no-shared-component-data': 'error',
19
+
20
+ // Prop 定义类型应该是构造函数
21
+ 'vue/require-prop-type-constructor': 'error',
22
+
23
+ // Prop 的默认值必须匹配它的类型
24
+ 'vue/require-valid-default-prop': 'error',
25
+
26
+ // 为 v-for 设置键值
27
+ 'vue/require-v-for-key': 'error',
28
+
29
+ // 避免 v-if 和 v-for 用在一起
30
+ 'vue/no-use-v-if-with-v-for': 'warn',
31
+
32
+ // 计算属性禁止包含异步方法
33
+ 'vue/no-async-in-computed-properties': 'error',
34
+
35
+ // 禁止在对象字面量中出现重复的键
36
+ 'vue/no-dupe-keys': 'error',
37
+
38
+ // 禁止出现重复的属性
39
+ 'vue/no-duplicate-attributes': 'error',
40
+
41
+ // 禁止出现语法错误
42
+ // @link https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
43
+ 'vue/no-parsing-error': [
44
+ 'error',
45
+ {
46
+ 'x-invalid-end-tag': false,
47
+ 'invalid-first-character-of-tag-name': false,
48
+ },
49
+ ],
50
+
51
+ // 禁止使用 vue 中的关键字
52
+ 'vue/no-reserved-keys': 'error',
53
+
54
+ // 禁止在计算属性中对属性修改
55
+ 'vue/no-side-effects-in-computed-properties': 'error',
56
+
57
+ // 禁止 <template> 使用 key 属性
58
+ 'vue/no-template-key': 'warn',
59
+
60
+ // 禁止在 <textarea> 中出现 {{message}}
61
+ 'vue/no-textarea-mustache': 'error',
62
+
63
+ // 禁止注册没有使用的组件
64
+ 'vue/no-unused-components': 'warn',
65
+
66
+ // 禁止在 v-for 等指令或者 scope 中申明没有使用到的变量
67
+ 'vue/no-unused-vars': 'warn',
68
+
69
+ // <component> 必须有 v-bind:is
70
+ 'vue/require-component-is': 'warn',
71
+
72
+ // render 函数必须有返回值
73
+ 'vue/require-render-return': 'error',
74
+
75
+ // 计算属性必须有返回值
76
+ 'vue/return-in-computed-property': 'error',
77
+
78
+ // 强制在 v-on 指令使用 exact 修饰符,当同一个标签上有另一个带修饰符的 v-on 指令
79
+ 'vue/use-v-on-exact': 'error',
80
+
81
+ // 检查指令的合法性
82
+ 'vue/valid-template-root': 'error',
83
+ 'vue/valid-v-bind': 'error',
84
+ 'vue/valid-v-cloak': 'error',
85
+ 'vue/valid-v-else-if': 'error',
86
+ 'vue/valid-v-else': 'error',
87
+ 'vue/valid-v-for': 'error',
88
+ 'vue/valid-v-html': 'error',
89
+ 'vue/valid-v-if': 'error',
90
+ 'vue/valid-v-model': 'error',
91
+ 'vue/valid-v-on': 'error',
92
+ 'vue/valid-v-once': 'error',
93
+ 'vue/valid-v-pre': 'error',
94
+ 'vue/valid-v-show': 'error',
95
+ },
96
+ };
@@ -1,6 +1,6 @@
1
- module.exports = {
2
- extends: [
3
- './index',
4
- '../rules/node',
5
- ].map(require.resolve),
6
- };
1
+ module.exports = {
2
+ extends: [
3
+ './index',
4
+ '../rules/node',
5
+ ].map(require.resolve),
6
+ };
@@ -1,6 +1,6 @@
1
- module.exports = {
2
- extends: [
3
- '../react',
4
- '../rules/typescript',
5
- ].map(require.resolve),
6
- };
1
+ module.exports = {
2
+ extends: [
3
+ '../react',
4
+ '../rules/typescript',
5
+ ].map(require.resolve),
6
+ };
package/typescript/vue.js CHANGED
@@ -1,10 +1,10 @@
1
- module.exports = {
2
- extends: [
3
- './index',
4
- '../rules/vue',
5
- ].map(require.resolve),
6
- parserOptions: {
7
- // https://github.com/mysticatea/vue-eslint-parser#parseroptionsparser
8
- parser: '@typescript-eslint/parser',
9
- },
10
- };
1
+ module.exports = {
2
+ extends: [
3
+ './index',
4
+ '../rules/vue',
5
+ ].map(require.resolve),
6
+ parserOptions: {
7
+ // https://github.com/mysticatea/vue-eslint-parser#parseroptionsparser
8
+ parser: '@typescript-eslint/parser',
9
+ },
10
+ };
package/vue.js CHANGED
@@ -1,10 +1,10 @@
1
- module.exports = {
2
- extends: [
3
- './index',
4
- './rules/vue',
5
- ].map(require.resolve),
6
- parserOptions: {
7
- // https://github.com/mysticatea/vue-eslint-parser#parseroptionsparser
8
- parser: '@babel/eslint-parser',
9
- },
10
- };
1
+ module.exports = {
2
+ extends: [
3
+ './index',
4
+ './rules/vue',
5
+ ].map(require.resolve),
6
+ parserOptions: {
7
+ // https://github.com/mysticatea/vue-eslint-parser#parseroptionsparser
8
+ parser: '@babel/eslint-parser',
9
+ },
10
+ };
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 黄俊森
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.