@huangjunsen/eslint-config 1.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.
Files changed (57) hide show
  1. package/.editorconfig +17 -0
  2. package/.eslintignore +17 -0
  3. package/.eslintrc.js +5 -0
  4. package/LICENSE +21 -0
  5. package/README.md +286 -0
  6. package/__tests__/fixtures/es5.js +4 -0
  7. package/__tests__/fixtures/index.js +3 -0
  8. package/__tests__/fixtures/node.js +24 -0
  9. package/__tests__/fixtures/react-display-name.js +7 -0
  10. package/__tests__/fixtures/react.jsx +132 -0
  11. package/__tests__/fixtures/ts-import-a.ts +3 -0
  12. package/__tests__/fixtures/ts-import-b.ts +3 -0
  13. package/__tests__/fixtures/ts-node.ts +20 -0
  14. package/__tests__/fixtures/ts-react.tsx +27 -0
  15. package/__tests__/fixtures/ts-vue.vue +36 -0
  16. package/__tests__/fixtures/ts.ts +17 -0
  17. package/__tests__/fixtures/tsconfig.json +8 -0
  18. package/__tests__/fixtures/use-babel-eslint.jsx +170 -0
  19. package/__tests__/fixtures/vue.vue +16 -0
  20. package/__tests__/use-babel-eslint.test.js +47 -0
  21. package/__tests__/validate-js-configs.test.js +259 -0
  22. package/__tests__/validate-ts-configs.test.js +263 -0
  23. package/es5.js +10 -0
  24. package/essential/es5.js +12 -0
  25. package/essential/index.js +12 -0
  26. package/essential/react.js +76 -0
  27. package/essential/rules/blacklist.js +48 -0
  28. package/essential/rules/es6-blacklist.js +62 -0
  29. package/essential/rules/set-style-to-warn.js +30 -0
  30. package/essential/rules/ts-blacklist.js +15 -0
  31. package/essential/typescript/index.js +7 -0
  32. package/essential/typescript/react.js +7 -0
  33. package/essential/typescript/vue.js +9 -0
  34. package/essential/vue.js +8 -0
  35. package/index.js +23 -0
  36. package/jsx-a11y.js +5 -0
  37. package/node.js +6 -0
  38. package/package.json +48 -0
  39. package/react.js +11 -0
  40. package/rules/base/best-practices.js +284 -0
  41. package/rules/base/es6.js +168 -0
  42. package/rules/base/possible-errors.js +126 -0
  43. package/rules/base/strict.js +6 -0
  44. package/rules/base/style.js +445 -0
  45. package/rules/base/variables.js +48 -0
  46. package/rules/es5.js +11 -0
  47. package/rules/imports.js +167 -0
  48. package/rules/jsx-a11y.js +23 -0
  49. package/rules/node.js +11 -0
  50. package/rules/react.js +354 -0
  51. package/rules/typescript.js +807 -0
  52. package/rules/vue.js +96 -0
  53. package/typescript/index.js +6 -0
  54. package/typescript/node.js +6 -0
  55. package/typescript/react.js +6 -0
  56. package/typescript/vue.js +10 -0
  57. package/vue.js +10 -0
package/rules/vue.js ADDED
@@ -0,0 +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
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ extends: [
3
+ '../index',
4
+ '../rules/typescript',
5
+ ].map(require.resolve),
6
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ extends: [
3
+ './index',
4
+ '../rules/node',
5
+ ].map(require.resolve),
6
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ extends: [
3
+ '../react',
4
+ '../rules/typescript',
5
+ ].map(require.resolve),
6
+ };
@@ -0,0 +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
+ };
package/vue.js ADDED
@@ -0,0 +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
+ };