@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
@@ -1,259 +1,259 @@
1
- /**
2
- * 验证 JS
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 JS configs', () => {
15
- it('Validate eslint-config-encode', async () => {
16
- const configPath = './index.js';
17
- const filePath = path.join(__dirname, './fixtures/index.js');
18
-
19
- const cli = new eslint.ESLint({
20
- overrideConfigFile: configPath,
21
- useEslintrc: false, // 如果不关这个参数,会将目录下的 eslintrc 与 overrideConfigFile merge
22
- ignore: false,
23
- });
24
-
25
- // 验证导出的 config 是否正常
26
- const config = await cli.calculateConfigForFile(filePath);
27
- assert.ok(isObject(config));
28
-
29
- // 验证 lint 工作是否正常
30
- const results = await cli.lintFiles([filePath]);
31
- assert.equal(sumBy(results, 'fatalErrorCount'), 0);
32
- assert.notEqual(sumBy(results, 'errorCount'), 0);
33
- assert.notEqual(sumBy(results, 'warningCount'), 0);
34
- });
35
-
36
- it('Validate eslint-config-encode/es5', async () => {
37
- const configPath = './es5.js';
38
- const filePath = path.join(__dirname, './fixtures/es5.js');
39
-
40
- const cli = new eslint.ESLint({
41
- overrideConfigFile: configPath,
42
- useEslintrc: false,
43
- ignore: false,
44
- });
45
-
46
- // 验证导出的 config 是否正常
47
- const config = await cli.calculateConfigForFile(filePath);
48
- assert.ok(isObject(config));
49
-
50
- // 验证 lint 工作是否正常
51
- const results = await cli.lintFiles([filePath]);
52
- assert.equal(sumBy(results, 'fatalErrorCount'), 0);
53
- assert.notEqual(sumBy(results, 'errorCount'), 0);
54
- assert.equal(sumBy(results, 'warningCount'), 0);
55
-
56
- // 验证 es5 覆盖的规则是否正常,取 comma-dangle 进行测试
57
- const { messages } = results[0];
58
- const errorReportedByReactPlugin = messages.filter((result) => {
59
- return result.ruleId === 'comma-dangle';
60
- });
61
- assert.notEqual(errorReportedByReactPlugin.length, 0);
62
- });
63
-
64
- it('Validate eslint-config-encode/vue', async () => {
65
- const configPath = './vue.js';
66
- const filePath = path.join(__dirname, './fixtures/vue.vue');
67
-
68
- const cli = new eslint.ESLint({
69
- overrideConfigFile: configPath,
70
- useEslintrc: false,
71
- ignore: false,
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.equal(sumBy(results, 'warningCount'), 0);
83
-
84
- // 验证 eslint-plugin-vue 工作是否正常
85
- const { messages } = results[0];
86
- const errorReportedByReactPlugin = messages.filter((result) => {
87
- return result.ruleId && result.ruleId.indexOf('vue/') !== -1;
88
- });
89
- assert.notEqual(errorReportedByReactPlugin.length, 0);
90
- });
91
-
92
- it('Validate eslint-config-encode/essential', async () => {
93
- const configPath = './essential/index.js';
94
- const filePath = path.join(__dirname, './fixtures/index.js');
95
-
96
- const cli = new eslint.ESLint({
97
- overrideConfigFile: configPath,
98
- useEslintrc: false,
99
- ignore: false,
100
- });
101
-
102
- // 验证导出的 config 是否正常
103
- const config = await cli.calculateConfigForFile(filePath);
104
- assert.ok(isObject(config));
105
-
106
- // 验证 lint 工作是否正常
107
- const results = await cli.lintFiles([filePath]);
108
- assert.equal(sumBy(results, 'fatalErrorCount'), 0);
109
- assert.equal(sumBy(results, 'errorCount'), 0);
110
- assert.notEqual(sumBy(results, 'warningCount'), 0);
111
-
112
- // 验证黑名单中的规则已关闭
113
- const { messages } = results[0];
114
-
115
- // 验证 semi 被关闭
116
- const semiErrors = messages.filter((result) => {
117
- return result.ruleId === 'semi';
118
- });
119
- assert.equal(semiErrors.length, 0);
120
-
121
- // 验证 comma-spacing 被降级
122
- const commaSpacingErrors = messages.filter((result) => {
123
- return result.ruleId === 'comma-spacing';
124
- });
125
- assert.equal(commaSpacingErrors[0].severity, 1);
126
- });
127
-
128
- it('Validate eslint-config-encode/essential/es5', async () => {
129
- const configPath = './essential/es5.js';
130
- const filePath = path.join(__dirname, './fixtures/es5.js');
131
-
132
- const cli = new eslint.ESLint({
133
- overrideConfigFile: configPath,
134
- useEslintrc: false,
135
- ignore: false,
136
- });
137
-
138
- // 验证导出的 config 是否正常
139
- const config = await cli.calculateConfigForFile(filePath);
140
- assert.ok(isObject(config));
141
-
142
- // 验证 lint 工作是否正常
143
- const results = await cli.lintFiles([filePath]);
144
- assert.equal(sumBy(results, 'fatalErrorCount'), 0);
145
- assert.notEqual(sumBy(results, 'errorCount'), 0);
146
- assert.notEqual(sumBy(results, 'warningCount'), 0);
147
- // 验证 es5 覆盖的规则是否正常,取 comma-dangle 进行测试
148
- const { messages } = results[0];
149
- const errorReportedByReactPlugin = messages.filter((result) => {
150
- return result.ruleId === 'comma-dangle';
151
- });
152
- assert.notEqual(errorReportedByReactPlugin.length, 0);
153
-
154
- // 验证黑名单中的规则已关闭,取 semi 进行测试
155
- const errorReportedByReactPluginBlackList = messages.filter((result) => {
156
- return result.ruleId === 'semi';
157
- });
158
- assert.equal(errorReportedByReactPluginBlackList.length, 0);
159
- });
160
-
161
- it('Validate eslint-config-encode/essential/react', async () => {
162
- const configPath = './essential/react.js';
163
- const filePath = path.join(__dirname, './fixtures/react.jsx');
164
-
165
- const cli = new eslint.ESLint({
166
- overrideConfigFile: configPath,
167
- useEslintrc: false,
168
- ignore: false,
169
- });
170
-
171
- // 验证导出的 config 是否正常
172
- const config = await cli.calculateConfigForFile(filePath);
173
- assert.ok(isObject(config));
174
-
175
- // 验证 lint 工作是否正常
176
- const results = await cli.lintFiles([filePath]);
177
- assert.equal(sumBy(results, 'fatalErrorCount'), 0);
178
- assert.notEqual(sumBy(results, 'errorCount'), 0);
179
- assert.notEqual(sumBy(results, 'warningCount'), 0);
180
- // 验证 react plugin 工作是否正常
181
- const { messages } = results[0];
182
- const errorReportedByReactPlugin = messages.filter((result) => {
183
- return result.ruleId && result.ruleId.indexOf('react/') !== -1;
184
- });
185
- assert.notEqual(errorReportedByReactPlugin.length, 0);
186
-
187
- // 验证黑名单中的规则已关闭,取 react/jsx-indent 进行测试
188
- const errorReportedByReactPluginBlackList = messages.filter((result) => {
189
- return result.ruleId === 'react/jsx-indent';
190
- });
191
- assert.equal(errorReportedByReactPluginBlackList.length, 0);
192
- });
193
-
194
- it('Validate eslint-config-encode/essential/vue', async () => {
195
- const configPath = './essential/vue.js';
196
- const filePath = path.join(__dirname, './fixtures/vue.vue');
197
-
198
- const cli = new eslint.ESLint({
199
- overrideConfigFile: configPath,
200
- useEslintrc: false,
201
- ignore: false,
202
- });
203
-
204
- // 验证导出的 config 是否正常
205
- const config = await cli.calculateConfigForFile(filePath);
206
- assert.ok(isObject(config));
207
-
208
- // 验证 lint 工作是否正常
209
- const results = await cli.lintFiles([filePath]);
210
- assert.equal(sumBy(results, 'fatalErrorCount'), 0);
211
- assert.notEqual(sumBy(results, 'errorCount'), 0);
212
- assert.equal(sumBy(results, 'warningCount'), 0);
213
-
214
- // 验证 vue plugin 工作是否正常
215
- const { messages } = results[0];
216
- const errorReportedByReactPlugin = messages.filter((result) => {
217
- return result.ruleId && result.ruleId.indexOf('vue/') !== -1;
218
- });
219
- assert.notEqual(errorReportedByReactPlugin.length, 0);
220
-
221
- // 验证黑名单中的规则已关闭
222
- const errorReportedByReactPluginBlackList = messages.filter((result) => {
223
- return result.ruleId === 'indent';
224
- });
225
- assert.equal(errorReportedByReactPluginBlackList.length, 0);
226
- });
227
-
228
- it('Validate eslint-config-encode/node', async () => {
229
- const configPath = './node.js';
230
- const filePath = path.join(__dirname, './fixtures/node.js');
231
-
232
- const cli = new eslint.ESLint({
233
- overrideConfigFile: configPath,
234
- useEslintrc: false,
235
- ignore: false,
236
- });
237
-
238
- // 验证导出的 config 是否正常
239
- const config = await cli.calculateConfigForFile(filePath);
240
- assert.ok(isObject(config));
241
- assert.strictEqual(config.env.node, true);
242
- assert.strictEqual(config.plugins.includes('node'), true);
243
-
244
- // 验证已开启的 link 规则是否校验正常
245
- const results = await cli.lintFiles([filePath]);
246
- const { messages, errorCount, warningCount } = results[0];
247
- const ruleIds = Array.from(messages.map((item) => item.ruleId));
248
- assert.strictEqual(ruleIds.includes('node/prefer-promises/fs'), true);
249
- assert.strictEqual(ruleIds.includes('no-unused-vars'), true);
250
- assert.strictEqual(ruleIds.includes('node/no-new-require'), true);
251
- assert.strictEqual(ruleIds.includes('semi'), true);
252
- assert.strictEqual(ruleIds.includes('quotes'), true);
253
- assert.strictEqual(errorCount, 7);
254
- assert.strictEqual(warningCount, 4);
255
-
256
- // 验证已关闭的 link 规则是否校验正常,以 node/exports-style 为例
257
- assert.strictEqual(ruleIds.includes('node/exports-style'), false);
258
- });
259
- });
1
+ /**
2
+ * 验证 JS
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 JS configs', () => {
15
+ it('Validate eslint-config-encode', async () => {
16
+ const configPath = './index.js';
17
+ const filePath = path.join(__dirname, './fixtures/index.js');
18
+
19
+ const cli = new eslint.ESLint({
20
+ overrideConfigFile: configPath,
21
+ useEslintrc: false, // 如果不关这个参数,会将目录下的 eslintrc 与 overrideConfigFile merge
22
+ ignore: false,
23
+ });
24
+
25
+ // 验证导出的 config 是否正常
26
+ const config = await cli.calculateConfigForFile(filePath);
27
+ assert.ok(isObject(config));
28
+
29
+ // 验证 lint 工作是否正常
30
+ const results = await cli.lintFiles([filePath]);
31
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
32
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
33
+ assert.notEqual(sumBy(results, 'warningCount'), 0);
34
+ });
35
+
36
+ it('Validate eslint-config-encode/es5', async () => {
37
+ const configPath = './es5.js';
38
+ const filePath = path.join(__dirname, './fixtures/es5.js');
39
+
40
+ const cli = new eslint.ESLint({
41
+ overrideConfigFile: configPath,
42
+ useEslintrc: false,
43
+ ignore: false,
44
+ });
45
+
46
+ // 验证导出的 config 是否正常
47
+ const config = await cli.calculateConfigForFile(filePath);
48
+ assert.ok(isObject(config));
49
+
50
+ // 验证 lint 工作是否正常
51
+ const results = await cli.lintFiles([filePath]);
52
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
53
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
54
+ assert.equal(sumBy(results, 'warningCount'), 0);
55
+
56
+ // 验证 es5 覆盖的规则是否正常,取 comma-dangle 进行测试
57
+ const { messages } = results[0];
58
+ const errorReportedByReactPlugin = messages.filter((result) => {
59
+ return result.ruleId === 'comma-dangle';
60
+ });
61
+ assert.notEqual(errorReportedByReactPlugin.length, 0);
62
+ });
63
+
64
+ it('Validate eslint-config-encode/vue', async () => {
65
+ const configPath = './vue.js';
66
+ const filePath = path.join(__dirname, './fixtures/vue.vue');
67
+
68
+ const cli = new eslint.ESLint({
69
+ overrideConfigFile: configPath,
70
+ useEslintrc: false,
71
+ ignore: false,
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.equal(sumBy(results, 'warningCount'), 0);
83
+
84
+ // 验证 eslint-plugin-vue 工作是否正常
85
+ const { messages } = results[0];
86
+ const errorReportedByReactPlugin = messages.filter((result) => {
87
+ return result.ruleId && result.ruleId.indexOf('vue/') !== -1;
88
+ });
89
+ assert.notEqual(errorReportedByReactPlugin.length, 0);
90
+ });
91
+
92
+ it('Validate eslint-config-encode/essential', async () => {
93
+ const configPath = './essential/index.js';
94
+ const filePath = path.join(__dirname, './fixtures/index.js');
95
+
96
+ const cli = new eslint.ESLint({
97
+ overrideConfigFile: configPath,
98
+ useEslintrc: false,
99
+ ignore: false,
100
+ });
101
+
102
+ // 验证导出的 config 是否正常
103
+ const config = await cli.calculateConfigForFile(filePath);
104
+ assert.ok(isObject(config));
105
+
106
+ // 验证 lint 工作是否正常
107
+ const results = await cli.lintFiles([filePath]);
108
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
109
+ assert.equal(sumBy(results, 'errorCount'), 0);
110
+ assert.notEqual(sumBy(results, 'warningCount'), 0);
111
+
112
+ // 验证黑名单中的规则已关闭
113
+ const { messages } = results[0];
114
+
115
+ // 验证 semi 被关闭
116
+ const semiErrors = messages.filter((result) => {
117
+ return result.ruleId === 'semi';
118
+ });
119
+ assert.equal(semiErrors.length, 0);
120
+
121
+ // 验证 comma-spacing 被降级
122
+ const commaSpacingErrors = messages.filter((result) => {
123
+ return result.ruleId === 'comma-spacing';
124
+ });
125
+ assert.equal(commaSpacingErrors[0].severity, 1);
126
+ });
127
+
128
+ it('Validate eslint-config-encode/essential/es5', async () => {
129
+ const configPath = './essential/es5.js';
130
+ const filePath = path.join(__dirname, './fixtures/es5.js');
131
+
132
+ const cli = new eslint.ESLint({
133
+ overrideConfigFile: configPath,
134
+ useEslintrc: false,
135
+ ignore: false,
136
+ });
137
+
138
+ // 验证导出的 config 是否正常
139
+ const config = await cli.calculateConfigForFile(filePath);
140
+ assert.ok(isObject(config));
141
+
142
+ // 验证 lint 工作是否正常
143
+ const results = await cli.lintFiles([filePath]);
144
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
145
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
146
+ assert.notEqual(sumBy(results, 'warningCount'), 0);
147
+ // 验证 es5 覆盖的规则是否正常,取 comma-dangle 进行测试
148
+ const { messages } = results[0];
149
+ const errorReportedByReactPlugin = messages.filter((result) => {
150
+ return result.ruleId === 'comma-dangle';
151
+ });
152
+ assert.notEqual(errorReportedByReactPlugin.length, 0);
153
+
154
+ // 验证黑名单中的规则已关闭,取 semi 进行测试
155
+ const errorReportedByReactPluginBlackList = messages.filter((result) => {
156
+ return result.ruleId === 'semi';
157
+ });
158
+ assert.equal(errorReportedByReactPluginBlackList.length, 0);
159
+ });
160
+
161
+ it('Validate eslint-config-encode/essential/react', async () => {
162
+ const configPath = './essential/react.js';
163
+ const filePath = path.join(__dirname, './fixtures/react.jsx');
164
+
165
+ const cli = new eslint.ESLint({
166
+ overrideConfigFile: configPath,
167
+ useEslintrc: false,
168
+ ignore: false,
169
+ });
170
+
171
+ // 验证导出的 config 是否正常
172
+ const config = await cli.calculateConfigForFile(filePath);
173
+ assert.ok(isObject(config));
174
+
175
+ // 验证 lint 工作是否正常
176
+ const results = await cli.lintFiles([filePath]);
177
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
178
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
179
+ assert.notEqual(sumBy(results, 'warningCount'), 0);
180
+ // 验证 react plugin 工作是否正常
181
+ const { messages } = results[0];
182
+ const errorReportedByReactPlugin = messages.filter((result) => {
183
+ return result.ruleId && result.ruleId.indexOf('react/') !== -1;
184
+ });
185
+ assert.notEqual(errorReportedByReactPlugin.length, 0);
186
+
187
+ // 验证黑名单中的规则已关闭,取 react/jsx-indent 进行测试
188
+ const errorReportedByReactPluginBlackList = messages.filter((result) => {
189
+ return result.ruleId === 'react/jsx-indent';
190
+ });
191
+ assert.equal(errorReportedByReactPluginBlackList.length, 0);
192
+ });
193
+
194
+ it('Validate eslint-config-encode/essential/vue', async () => {
195
+ const configPath = './essential/vue.js';
196
+ const filePath = path.join(__dirname, './fixtures/vue.vue');
197
+
198
+ const cli = new eslint.ESLint({
199
+ overrideConfigFile: configPath,
200
+ useEslintrc: false,
201
+ ignore: false,
202
+ });
203
+
204
+ // 验证导出的 config 是否正常
205
+ const config = await cli.calculateConfigForFile(filePath);
206
+ assert.ok(isObject(config));
207
+
208
+ // 验证 lint 工作是否正常
209
+ const results = await cli.lintFiles([filePath]);
210
+ assert.equal(sumBy(results, 'fatalErrorCount'), 0);
211
+ assert.notEqual(sumBy(results, 'errorCount'), 0);
212
+ assert.equal(sumBy(results, 'warningCount'), 0);
213
+
214
+ // 验证 vue plugin 工作是否正常
215
+ const { messages } = results[0];
216
+ const errorReportedByReactPlugin = messages.filter((result) => {
217
+ return result.ruleId && result.ruleId.indexOf('vue/') !== -1;
218
+ });
219
+ assert.notEqual(errorReportedByReactPlugin.length, 0);
220
+
221
+ // 验证黑名单中的规则已关闭
222
+ const errorReportedByReactPluginBlackList = messages.filter((result) => {
223
+ return result.ruleId === 'indent';
224
+ });
225
+ assert.equal(errorReportedByReactPluginBlackList.length, 0);
226
+ });
227
+
228
+ it('Validate eslint-config-encode/node', async () => {
229
+ const configPath = './node.js';
230
+ const filePath = path.join(__dirname, './fixtures/node.js');
231
+
232
+ const cli = new eslint.ESLint({
233
+ overrideConfigFile: configPath,
234
+ useEslintrc: false,
235
+ ignore: false,
236
+ });
237
+
238
+ // 验证导出的 config 是否正常
239
+ const config = await cli.calculateConfigForFile(filePath);
240
+ assert.ok(isObject(config));
241
+ assert.strictEqual(config.env.node, true);
242
+ assert.strictEqual(config.plugins.includes('node'), true);
243
+
244
+ // 验证已开启的 link 规则是否校验正常
245
+ const results = await cli.lintFiles([filePath]);
246
+ const { messages, errorCount, warningCount } = results[0];
247
+ const ruleIds = Array.from(messages.map((item) => item.ruleId));
248
+ assert.strictEqual(ruleIds.includes('node/prefer-promises/fs'), true);
249
+ assert.strictEqual(ruleIds.includes('no-unused-vars'), true);
250
+ assert.strictEqual(ruleIds.includes('node/no-new-require'), true);
251
+ assert.strictEqual(ruleIds.includes('semi'), true);
252
+ assert.strictEqual(ruleIds.includes('quotes'), true);
253
+ assert.strictEqual(errorCount, 7);
254
+ assert.strictEqual(warningCount, 4);
255
+
256
+ // 验证已关闭的 link 规则是否校验正常,以 node/exports-style 为例
257
+ assert.strictEqual(ruleIds.includes('node/exports-style'), false);
258
+ });
259
+ });
package/es5.js CHANGED
@@ -1,10 +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
- };
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
+ };
package/essential/es5.js CHANGED
@@ -1,12 +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
- };
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
+ };
@@ -1,12 +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
- };
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
+ };