@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
@@ -0,0 +1,263 @@
1
+ /**
2
+ * 验证 TS 规则
3
+ */
4
+
5
+ const assert = require('assert');
6
+ const eslint = require('eslint');
7
+ const path = require('path');
8
+ const sumBy = require('lodash/sumBy');
9
+
10
+ function isObject(obj) {
11
+ return typeof obj === 'object' && obj !== null;
12
+ }
13
+
14
+ describe('Validate TS configs', () => {
15
+ it('Validate eslint-config-encode/typescript', async () => {
16
+ const configPath = './typescript/index.js';
17
+ const filePath = path.join(__dirname, './fixtures/ts.ts');
18
+
19
+ const cli = new eslint.ESLint({
20
+ overrideConfigFile: configPath,
21
+ useEslintrc: false,
22
+ ignore: false,
23
+ overrideConfig: {
24
+ parserOptions: {
25
+ project: path.join(__dirname, './fixtures/tsconfig.json'),
26
+ },
27
+ },
28
+ });
29
+
30
+ // 验证导出的 config 是否正常
31
+ const config = cli.calculateConfigForFile(filePath);
32
+ assert.ok(isObject(config));
33
+
34
+ // 验证 lint 工作是否正常
35
+ const results = await cli.lintFiles([filePath]);
36
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
37
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
38
+ assert.equal(sumBy(results, 'warningCount'), 0);
39
+
40
+ // 验证 eslint-plugin-typescript 工作是否正常
41
+ const { messages } = results[0];
42
+ const errorReportedByReactPlugin = messages.filter((result) => {
43
+ return result.ruleId && result.ruleId.indexOf('@typescript-eslint/') !== -1;
44
+ });
45
+ assert.notEqual(errorReportedByReactPlugin.length, 0);
46
+
47
+ const errorReportedByNoRedeclare = messages.filter((result) => {
48
+ return result.ruleId === 'no-redeclare';
49
+ });
50
+ assert.equal(errorReportedByNoRedeclare.length, 0);
51
+
52
+ // 验证 eslint-import-resolver-typescript 工作是否正常
53
+ const filePath2 = path.join(__dirname, './fixtures/ts-import-a.ts');
54
+ const filePath3 = path.join(__dirname, './fixtures/ts-import-b.ts');
55
+ const reports2 = cli.lintFiles([filePath2, filePath3]);
56
+ assert.ok(reports2.errorCount !== 0 || reports2.warnCount !== 0);
57
+ });
58
+
59
+ it('Validate eslint-config-encode/typescript/vue', async () => {
60
+ const configPath = './typescript/vue.js';
61
+ const filePath = path.join(__dirname, './fixtures/ts-vue.vue');
62
+
63
+ const cli = new eslint.ESLint({
64
+ overrideConfigFile: configPath,
65
+ useEslintrc: false,
66
+ ignore: false,
67
+ overrideConfig: {
68
+ parserOptions: {
69
+ project: path.join(__dirname, './fixtures/tsconfig.json'),
70
+ },
71
+ },
72
+ });
73
+
74
+ // 验证导出的 config 是否正常
75
+ const config = await cli.calculateConfigForFile(filePath);
76
+ assert.ok(isObject(config));
77
+
78
+ // 验证 lint 工作是否正常
79
+ const results = await cli.lintFiles([filePath]);
80
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
81
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
82
+ assert.notEqual(sumBy(results, 'warningCount'), 0);
83
+
84
+ // 验证 eslint-plugin-vue 及 @typescript-eslint 工作是否正常
85
+ const { messages } = results[0];
86
+ const errorReportedByReactPlugin = messages.filter((result) => {
87
+ return result.ruleId && result.ruleId.indexOf('vue/') !== -1;
88
+ });
89
+ const errorReportedByTSPlugin = messages.filter((result) => {
90
+ return result.ruleId && result.ruleId.indexOf('@typescript-eslint/') !== -1;
91
+ });
92
+ assert.notEqual(errorReportedByReactPlugin.length, 0);
93
+ assert.notEqual(errorReportedByTSPlugin.length, 0);
94
+ });
95
+
96
+ it('Validate eslint-config-encode/essential/typescript', async () => {
97
+ const configPath = './essential/typescript/index.js';
98
+ const filePath = path.join(__dirname, './fixtures/ts.ts');
99
+
100
+ const cli = new eslint.ESLint({
101
+ overrideConfigFile: configPath,
102
+ useEslintrc: false,
103
+ ignore: false,
104
+ overrideConfig: {
105
+ parserOptions: {
106
+ project: path.join(__dirname, './fixtures/tsconfig.json'),
107
+ },
108
+ },
109
+ });
110
+
111
+ // 验证导出的 config 是否正常
112
+ const config = await cli.calculateConfigForFile(filePath);
113
+ assert.ok(isObject(config));
114
+
115
+ // 验证 lint 工作是否正常
116
+ const results = await cli.lintFiles([filePath]);
117
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
118
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
119
+ assert.notEqual(sumBy(results, 'warningCount'), 0);
120
+
121
+ // 验证黑名单中的规则已关闭
122
+ const { messages } = results[0];
123
+
124
+ // 验证 @typescript-eslint/semi 被关闭
125
+ const semiErrors = messages.filter((result) => {
126
+ return result.ruleId === '@typescript-eslint/semi';
127
+ });
128
+ assert.equal(semiErrors.length, 0);
129
+
130
+ // 验证一个风格问题被降级
131
+ const styleErrors = messages.filter((result) => {
132
+ return result.ruleId === 'object-curly-spacing';
133
+ });
134
+ assert.equal(styleErrors[0].severity, 1);
135
+ });
136
+
137
+ it('Validate eslint-config-encode/essential/typescript/react', async () => {
138
+ const configPath = './essential/typescript/react.js';
139
+ const filePath = path.join(__dirname, './fixtures/ts-react.tsx');
140
+
141
+ const cli = new eslint.ESLint({
142
+ overrideConfigFile: configPath,
143
+ useEslintrc: false,
144
+ ignore: false,
145
+ overrideConfig: {
146
+ parserOptions: {
147
+ project: path.join(__dirname, './fixtures/tsconfig.json'),
148
+ },
149
+ },
150
+ });
151
+
152
+ // 验证导出的 config 是否正常
153
+ const config = await cli.calculateConfigForFile(filePath);
154
+ assert.ok(isObject(config));
155
+
156
+ // 验证 lint 工作是否正常
157
+ const results = await cli.lintFiles([filePath]);
158
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
159
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
160
+ assert.notEqual(sumBy(results, 'warningCount'), 0);
161
+
162
+ // 验证对 tsx 工作是否正常
163
+ const { messages } = results[0];
164
+ const errorReportedByReactPlugin = messages.filter((result) => {
165
+ return result.ruleId && result.ruleId.indexOf('react/') !== -1;
166
+ });
167
+ assert.notEqual(errorReportedByReactPlugin.length, 0);
168
+ const errorReportedByTSPlugin = messages.filter((result) => {
169
+ return result.ruleId && result.ruleId.indexOf('@typescript-eslint/') !== -1;
170
+ });
171
+ assert.notEqual(errorReportedByTSPlugin.length, 0);
172
+
173
+ // 验证 @typescript-eslint/semi 被关闭
174
+ const semiErrors = messages.filter((result) => {
175
+ return result.ruleId === '@typescript-eslint/semi';
176
+ });
177
+ assert.equal(semiErrors.length, 0);
178
+
179
+ // 验证黑名单中的规则已关闭,取 react/jsx-indent 进行测试
180
+ const errorReportedByReactPluginBlackList = messages.filter((result) => {
181
+ return result.ruleId === 'react/jsx-indent';
182
+ });
183
+ assert.equal(errorReportedByReactPluginBlackList.length, 0);
184
+ });
185
+
186
+ it('Validate eslint-config-encode/essential/typescript/vue', async () => {
187
+ const configPath = './essential/typescript/vue.js';
188
+ const filePath = path.join(__dirname, './fixtures/ts-vue.vue');
189
+
190
+ const cli = new eslint.ESLint({
191
+ overrideConfigFile: configPath,
192
+ useEslintrc: false,
193
+ ignore: false,
194
+ overrideConfig: {
195
+ parserOptions: {
196
+ project: path.join(__dirname, './fixtures/tsconfig.json'),
197
+ },
198
+ },
199
+ });
200
+
201
+ // 验证导出的 config 是否正常
202
+ const config = await cli.calculateConfigForFile(filePath);
203
+ assert.ok(isObject(config));
204
+
205
+ // 验证 lint 工作是否正常
206
+ const results = await cli.lintFiles([filePath]);
207
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
208
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
209
+ assert.notEqual(sumBy(results, 'warningCount'), 0);
210
+
211
+ // 验证 vue plugin 工作是否正常
212
+ const result = results[0];
213
+ const errorReportedByReactPlugin = result.messages.filter((message) => {
214
+ return message.ruleId && message.ruleId.indexOf('vue/') !== -1;
215
+ });
216
+ assert.notEqual(errorReportedByReactPlugin.length, 0);
217
+
218
+ // 验证黑名单中的规则已关闭
219
+ const errorReportedByReactPluginBlackList = result.messages.filter((message) => {
220
+ return message.ruleId === '@typescript-eslint/indent';
221
+ });
222
+ assert.equal(errorReportedByReactPluginBlackList.length, 0);
223
+ });
224
+
225
+ it('Validate eslint-config-encode/typescript/node', async () => {
226
+ const configPath = './typescript/node.js';
227
+ const filePath = path.join(__dirname, './fixtures/ts-node.ts');
228
+
229
+ const cli = new eslint.ESLint({
230
+ overrideConfigFile: configPath,
231
+ useEslintrc: false,
232
+ ignore: false,
233
+ overrideConfig: {
234
+ parserOptions: {
235
+ project: path.join(__dirname, './fixtures/tsconfig.json'),
236
+ },
237
+ },
238
+ });
239
+
240
+ // 验证导出的 config 是否正常
241
+ const config = await cli.calculateConfigForFile(filePath);
242
+ assert.ok(isObject(config));
243
+ assert.strictEqual(config.env.node, true);
244
+ assert.strictEqual(config.plugins.includes('node'), true);
245
+
246
+ // 验证已开启的 link 规则是否校验正常
247
+ const results = await cli.lintFiles([filePath]);
248
+ const { messages, errorCount, warningCount } = results[0];
249
+ const ruleIds = Array.from(messages.map((item) => item.ruleId));
250
+
251
+ assert.strictEqual(ruleIds.includes('node/prefer-promises/fs'), true);
252
+ assert.strictEqual(ruleIds.includes('@typescript-eslint/no-unused-vars'), true);
253
+ assert.strictEqual(ruleIds.includes('no-console'), true);
254
+ assert.strictEqual(ruleIds.includes('no-var'), true);
255
+ assert.strictEqual(ruleIds.includes('eol-last'), true);
256
+ assert.equal(errorCount, 2);
257
+ assert.equal(warningCount, 3);
258
+
259
+ // 验证已关闭的 link 规则是否校验正常,以 @typescript-eslint/explicit-function-return-type 为例
260
+ assert.strictEqual(ruleIds.includes('@typescript-eslint/explicit-function-return-type'), false);
261
+ console.log("test success!",ruleIds.includes('@typescript-eslint/explicit-function-return-type'));
262
+ });
263
+ });
package/es5.js ADDED
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ extends: [
3
+ './rules/base/best-practices',
4
+ './rules/base/possible-errors',
5
+ './rules/base/style',
6
+ './rules/base/variables',
7
+ './rules/es5',
8
+ ].map(require.resolve),
9
+ root: true,
10
+ };
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ extends: [
3
+ '../es5',
4
+ './rules/set-style-to-warn',
5
+ './rules/blacklist',
6
+ ].map(require.resolve),
7
+ rules: {
8
+ // 逗号风格 - ES5 中不加最后一个逗号
9
+ // @unessential
10
+ 'comma-dangle': ['warn', 'never'],
11
+ },
12
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * essential 级别出口文件仅将会必要的规则设置为 error 级别
3
+ */
4
+
5
+ module.exports = {
6
+ extends: [
7
+ '../index',
8
+ './rules/set-style-to-warn',
9
+ './rules/blacklist',
10
+ './rules/es6-blacklist',
11
+ ].map(require.resolve),
12
+ };
@@ -0,0 +1,76 @@
1
+ module.exports = {
2
+ extends: [
3
+ '../react',
4
+ './rules/set-style-to-warn',
5
+ './rules/blacklist',
6
+ './rules/es6-blacklist',
7
+ ].map(require.resolve),
8
+ rules: {
9
+ // 标签的属性有多行时,结束标签需另起一行
10
+ // @unessential
11
+ 'react/jsx-closing-bracket-location': ['warn', 'line-aligned'],
12
+
13
+ // JSX 语法闭合标签的缩进和换行
14
+ // @unessential
15
+ 'react/jsx-closing-tag-location': 'warn',
16
+
17
+ // JSX 行内属性间仅有一个空格
18
+ // @unessential
19
+ 'react/jsx-props-no-multi-spaces': 'warn',
20
+
21
+ // JSX 属性的大括号内部两侧无空格
22
+ // @unessential
23
+ 'react/jsx-curly-spacing': ['warn', 'never', { allowMultiline: true }],
24
+
25
+ // JSX 属性使用 2 个空格缩进
26
+ // @unessential
27
+ 'react/jsx-indent-props': ['off', 2],
28
+
29
+ // 标签属性的换行,如果标签有多个属性,且存在换行,则每个属性都需要换行独占一行
30
+ // @unessential
31
+ 'react/jsx-max-props-per-line': ['warn', { maximum: 1, when: 'multiline' }],
32
+
33
+ // 禁止使用已经废弃的方法
34
+ // @unessential
35
+ 'react/no-deprecated': 'warn',
36
+
37
+ // 多行的 JSX 标签需用小括号包裹
38
+ // @unessential
39
+ 'react/jsx-wrap-multilines': [
40
+ 'warn',
41
+ {
42
+ declaration: true,
43
+ assignment: true,
44
+ return: true,
45
+ arrow: true,
46
+ },
47
+ ],
48
+
49
+ // 设置第一个属性的位置。multiline-multiprop:如果JSX标签占用多行并且有多个属性,则第一个属性应始终放在新行上
50
+ // @unessential
51
+ 'react/jsx-first-prop-new-line': ['warn', 'multiline-multiprop'],
52
+
53
+ // 不要在 JSX 属性的等号两边加空格
54
+ // @unessential
55
+ 'react/jsx-equals-spacing': ['warn', 'never'],
56
+
57
+ // JSX 使用 2 个空格缩进
58
+ // @unessential
59
+ 'react/jsx-indent': ['off', 2],
60
+
61
+ // 不要使用 findDOMNode,严格模式下已经弃用
62
+ // @unessential
63
+ 'react/no-find-dom-node': 'warn',
64
+
65
+ // 自闭合标签的斜线前有且仅有一个空格
66
+ // @unessential
67
+ 'react/jsx-tag-spacing': [
68
+ 'warn',
69
+ {
70
+ closingSlash: 'never',
71
+ beforeSelfClosing: 'always',
72
+ afterOpening: 'never',
73
+ },
74
+ ],
75
+ },
76
+ };
@@ -0,0 +1,48 @@
1
+ module.exports = {
2
+ rules: {
3
+ // 统一在点号之前换行
4
+ // @unessential
5
+ 'dot-location': ['warn', 'property'],
6
+
7
+ // 禁止使用 eval
8
+ // @unessential 部分场景必须使用 eval
9
+ 'no-eval': 'warn',
10
+
11
+ // 禁止使用类 eval 的方法,如 setTimeout 传入字符串
12
+ // @unessential
13
+ 'no-implied-eval': 'warn',
14
+
15
+ // 禁止使用 javascript:url,如 location.href = 'javascript:void(0)';
16
+ // @unessential
17
+ 'no-script-url': 'warn',
18
+
19
+ // 禁止变量与外层作用域已存在的变量同名
20
+ // @unessential
21
+ 'no-shadow': 'warn',
22
+
23
+ // 禁止出现多个连续空格
24
+ // @unessential
25
+ 'no-multi-spaces': [
26
+ 'warn',
27
+ {
28
+ ignoreEOLComments: false,
29
+ },
30
+ ],
31
+
32
+ // 使用 2 个空格缩进
33
+ // @unessential
34
+ indent: 'off',
35
+
36
+ // 使用分号
37
+ // @unessential
38
+ semi: 'off',
39
+
40
+ // 分号必须写在行尾
41
+ // @unessential
42
+ 'semi-style': 'off',
43
+
44
+ // 不要直接在对象上调用 Object.prototypes 上的方法
45
+ // @unessential
46
+ 'no-prototype-builtins': 'warn',
47
+ },
48
+ };
@@ -0,0 +1,62 @@
1
+ module.exports = {
2
+ rules: {
3
+ // 箭头函数的箭头前后各留一个空格
4
+ // @unessential
5
+ 'arrow-spacing': ['warn', { before: true, after: true }],
6
+
7
+ // generator 函数的 * 号前面无空格,后面有一个空格
8
+ // @unessential
9
+ 'generator-star-spacing': ['warn', { before: false, after: true }],
10
+
11
+ // 避免箭头函数与比较操作符产生混淆
12
+ // @unessential
13
+ 'no-confusing-arrow': 'warn',
14
+
15
+ // 回调函数使用箭头函数而不是匿名函数
16
+ // @unessential
17
+ 'prefer-arrow-callback': [
18
+ 'warn',
19
+ {
20
+ allowNamedFunctions: false,
21
+ allowUnboundThis: true,
22
+ },
23
+ ],
24
+
25
+ // 优先使用 const,只有当变量会被重新赋值时才使用 let
26
+ // @unessential
27
+ 'prefer-const': [
28
+ 'warn',
29
+ {
30
+ destructuring: 'any',
31
+ ignoreReadBeforeAssign: true,
32
+ },
33
+ ],
34
+
35
+ // 模板字符串中的大括号内部两侧无空格
36
+ // @unessential
37
+ 'template-curly-spacing': 'warn',
38
+
39
+ // yield* 表达式的 * 号前面无空格,后面有一个空格
40
+ // @unessential
41
+ 'yield-star-spacing': ['warn', 'after'],
42
+
43
+ // import 语句需要放到模块的最上方
44
+ // @unessential
45
+ 'import/first': 'warn',
46
+
47
+ // 使用对象属性和方法的简写语法
48
+ // @unessential
49
+ 'object-shorthand': [
50
+ 'warn',
51
+ 'always',
52
+ {
53
+ ignoreConstructors: false,
54
+ avoidQuotes: true,
55
+ },
56
+ ],
57
+
58
+ // 使用 const 或 let 声明变量,不要使用 var
59
+ // @unessential
60
+ 'no-var': 'warn',
61
+ },
62
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 将 error 级别的 style 规则降级为 warn
3
+ */
4
+
5
+ // 将传入 config 中 error 级别规则都改为 warn 级别
6
+ function setErrorRulesToWarn(configPath) {
7
+ const config = require(configPath);
8
+ const { rules } = config;
9
+
10
+ for (const ruleName in rules) {
11
+ if (Object.prototype.hasOwnProperty.call(rules, ruleName)) {
12
+ const ruleValue = rules[ruleName];
13
+ if (Array.isArray(ruleValue)) {
14
+ // 'array-bracket-spacing': [ 'error', 'never' ] 这种规则写法
15
+ if (ruleValue[0] === 'error') {
16
+ ruleValue[0] = 'warn';
17
+ }
18
+ } else if (ruleValue === 'error') {
19
+ // 'new-parens': 'error' 这种规则写法
20
+ rules[ruleName] = 'warn';
21
+ }
22
+ }
23
+ }
24
+
25
+ return {
26
+ rules,
27
+ };
28
+ }
29
+
30
+ module.exports = setErrorRulesToWarn('../../rules/base/style.js');
@@ -0,0 +1,15 @@
1
+ module.exports = {
2
+ rules: {
3
+ // 使用 2 个空格缩进
4
+ // @unessential
5
+ '@typescript-eslint/indent': 'off',
6
+
7
+ // 使用分号
8
+ // @unessential
9
+ '@typescript-eslint/semi': 'off',
10
+
11
+ '@typescript-eslint/adjacent-overload-signatures': 'warn',
12
+
13
+ '@typescript-eslint/no-parameter-properties': 'warn',
14
+ },
15
+ };
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ extends: [
3
+ '../index',
4
+ '../../rules/typescript',
5
+ '../rules/ts-blacklist',
6
+ ].map(require.resolve),
7
+ };
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ extends: [
3
+ '../react',
4
+ '../../rules/typescript',
5
+ '../rules/ts-blacklist',
6
+ ].map(require.resolve),
7
+ };
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ extends: [
3
+ './index',
4
+ '../../rules/vue', // vue 要置于最后,因为里面用了 vue-parser
5
+ ].map(require.resolve),
6
+ parserOptions: {
7
+ parser: '@typescript-eslint/parser',
8
+ },
9
+ };
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ extends: [
3
+ '../vue',
4
+ './rules/set-style-to-warn',
5
+ './rules/blacklist',
6
+ './rules/es6-blacklist',
7
+ ].map(require.resolve),
8
+ };
package/index.js ADDED
@@ -0,0 +1,23 @@
1
+ module.exports = {
2
+ extends: [
3
+ './rules/base/best-practices',
4
+ './rules/base/possible-errors',
5
+ './rules/base/style',
6
+ './rules/base/variables',
7
+ './rules/base/es6',
8
+ './rules/base/strict',
9
+ './rules/imports',
10
+ ].map(require.resolve),
11
+ parser: '@babel/eslint-parser',
12
+ parserOptions: {
13
+ requireConfigFile: false,
14
+ ecmaVersion: 2020,
15
+ sourceType: 'module',
16
+ ecmaFeatures: {
17
+ globalReturn: false,
18
+ impliedStrict: true,
19
+ jsx: true,
20
+ },
21
+ },
22
+ root: true,
23
+ };
package/jsx-a11y.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ extends: [
3
+ './rules/jsx-a11y',
4
+ ].map(require.resolve),
5
+ };
package/node.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ extends: [
3
+ './index',
4
+ './rules/node',
5
+ ].map(require.resolve),
6
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@huangjunsen/eslint-config",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "description": "JavaScript TypeScript Node 规范",
6
+ "keywords": [
7
+ "encode",
8
+ "javaScript",
9
+ "typescript",
10
+ "node",
11
+ "lint"
12
+ ],
13
+ "author": "Huangjunsen <951434130@qq.com>",
14
+ "homepage": "https://github.com/Huang-junsen/js-encode-fe-spec#readme",
15
+ "license": "ISC",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/Huang-junsen/js-encode-fe-spec.git"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/Huang-junsen/js-encode-fe-spec/issues"
22
+ },
23
+ "devDependencies": {
24
+ "@babel/core": "^7.24.4",
25
+ "@babel/eslint-parser": "^7.24.1",
26
+ "@babel/preset-react": "^7.24.1",
27
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
28
+ "@typescript-eslint/parser": "^7.7.0",
29
+ "eslint": "^8.7.0",
30
+ "eslint-config-egg": "^13.1.0",
31
+ "eslint-import-resolver-typescript": "^3.6.1",
32
+ "eslint-plugin-import": "^2.29.1",
33
+ "eslint-plugin-jsx-a11y": "^6.8.0",
34
+ "eslint-plugin-jsx-plus": "^0.1.0",
35
+ "eslint-plugin-react": "^7.34.1",
36
+ "eslint-plugin-react-hooks": "^4.6.0",
37
+ "eslint-plugin-vue": "^9.25.0",
38
+ "lodash": "^4.17.21",
39
+ "mocha": "^10.4.0",
40
+ "typescript": "5.0.4",
41
+ "vue-eslint-parser": "^9.4.2"
42
+ },
43
+ "scripts": {
44
+ "lint": "eslint ./",
45
+ "test": "mocha ./__tests__/*.test.js --timeout 5000",
46
+ "print-config": "eslint --print-config ./index.js > ./print-config.json"
47
+ }
48
+ }
package/react.js ADDED
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ extends: [
3
+ './index',
4
+ './rules/react',
5
+ ].map(require.resolve),
6
+ parserOptions: {
7
+ babelOptions: {
8
+ presets: ['@babel/preset-react'],
9
+ },
10
+ },
11
+ };