@deot/dev-eslint 2.7.0 → 2.8.1

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/dist/index.cjs ADDED
@@ -0,0 +1,348 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const pluginTs = require('@typescript-eslint/eslint-plugin');
6
+ const parserTs = require('@typescript-eslint/parser');
7
+ const js = require('@eslint/js');
8
+ const globals = require('globals');
9
+ const pluginJsdoc = require('eslint-plugin-jsdoc');
10
+ const pluginMarkdown = require('eslint-plugin-markdown');
11
+ const pluginImport = require('eslint-plugin-import');
12
+ const pluginStylistic = require('@stylistic/eslint-plugin');
13
+
14
+ const pickOptions = async (key, options) => {
15
+ const configOptions = {
16
+ enable: typeof options?.[key] === "boolean" ? options[key] : true,
17
+ overrides: {},
18
+ ...typeof options?.[key] === "object" ? options[key] : {}
19
+ };
20
+ const overrides = options?.overrides?.[key] || {};
21
+ return {
22
+ ...configOptions,
23
+ overrides: {
24
+ ...configOptions.overrides,
25
+ ...overrides
26
+ }
27
+ };
28
+ };
29
+ const cleanRules = (key, all, recommended, current) => {
30
+ current = JSON.parse(JSON.stringify(current));
31
+ const deprecated = [];
32
+ const removed = [];
33
+ const invaild = [];
34
+ const keys = Object.keys(current);
35
+ keys.forEach((i) => {
36
+ /* istanbul ignore next -- @preserve */
37
+ if (all[i] === void 0 && recommended[i] === void 0) {
38
+ removed.push(i);
39
+ }
40
+ /* istanbul ignore next -- @preserve */
41
+ if (recommended[i] === void 0 && (all[i] !== 0 && all[i] !== "off") && (current[i] === 0 || current[i] === "off")) {
42
+ invaild.push(i);
43
+ }
44
+ });
45
+ Object.keys(recommended).forEach((i) => {
46
+ if (all[i] === void 0) {
47
+ deprecated.push(i);
48
+ delete current[i];
49
+ }
50
+ });
51
+ const isTest = process.env.NODE_ENV === "UNIT" && !process.env.CI;
52
+ /* istanbul ignore next -- @preserve */
53
+ if (isTest && removed.length) {
54
+ console.error(key + ": " + removed.join(",") + " has removed!\n");
55
+ }
56
+ /* istanbul ignore next -- @preserve */
57
+ if (isTest && invaild.length) {
58
+ console.error(key + ": " + invaild.join(",") + " has off default!\n");
59
+ }
60
+ /* istanbul ignore next -- @preserve */
61
+ if (isTest && deprecated.length) {
62
+ console.error(key + ": " + deprecated.join(",") + " has deprecated!\n");
63
+ }
64
+ return current;
65
+ };
66
+
67
+ const typescript = async (options$) => {
68
+ const options = await pickOptions("typescript", options$);
69
+ if (!options.enable) {
70
+ return [];
71
+ }
72
+ const recommendedRules = pluginTs.configs["eslint-recommended"].overrides[0].rules;
73
+ const allRules = pluginTs.configs["all"].rules;
74
+ const rules = {
75
+ ...recommendedRules,
76
+ "@typescript-eslint/no-shadow": 2,
77
+ // https://github.com/typescript-eslint/typescript-eslint/issues/2483
78
+ "@typescript-eslint/no-unused-vars": 1,
79
+ "@typescript-eslint/member-delimiter-style": 1,
80
+ // ignore duplicate rules
81
+ "no-unused-vars": 0
82
+ };
83
+ return [
84
+ // 单独安装plugins, 方便扩展
85
+ {
86
+ plugins: {
87
+ "@typescript-eslint": pluginTs
88
+ }
89
+ },
90
+ {
91
+ files: ["*.ts", "*.tsx", "*.mts", "*.cts"].map((i) => "**/" + i),
92
+ languageOptions: {
93
+ parser: parserTs,
94
+ parserOptions: {
95
+ sourceType: "module"
96
+ }
97
+ },
98
+ rules: {
99
+ ...cleanRules(
100
+ "typescript",
101
+ { ...allRules, ...recommendedRules },
102
+ // all使用了extends, 但这里使用flat config
103
+ recommendedRules,
104
+ rules
105
+ ),
106
+ ...options.overrides
107
+ }
108
+ }
109
+ ];
110
+ };
111
+
112
+ const javascript = async (options$) => {
113
+ const options = await pickOptions("javascript", options$);
114
+ if (!options.enable) {
115
+ return [];
116
+ }
117
+ const allRules = js.configs.all.rules;
118
+ const recommendedRules = js.configs.recommended.rules;
119
+ const rules = {
120
+ ...recommendedRules,
121
+ "no-undef": 1,
122
+ "no-debugger": 1,
123
+ "no-unused-vars": 1,
124
+ "no-useless-escape": 0
125
+ };
126
+ return [
127
+ {
128
+ languageOptions: {
129
+ ecmaVersion: "latest",
130
+ globals: {
131
+ ...globals.browser,
132
+ ...globals.es2021,
133
+ ...globals.node
134
+ },
135
+ parserOptions: {
136
+ ecmaFeatures: {
137
+ jsx: true
138
+ },
139
+ ecmaVersion: 2022,
140
+ sourceType: "module"
141
+ },
142
+ sourceType: "module"
143
+ },
144
+ rules: {
145
+ ...cleanRules("javascript", allRules, recommendedRules, rules),
146
+ ...options.overrides
147
+ }
148
+ }
149
+ ];
150
+ };
151
+
152
+ const jsdoc = async (options$) => {
153
+ const options = await pickOptions("jsdoc", options$);
154
+ if (!options.enable) {
155
+ return [];
156
+ }
157
+ const recommendedRules = pluginJsdoc.configs["flat/recommended-typescript"].rules;
158
+ const rules = {
159
+ ...recommendedRules,
160
+ "jsdoc/check-tag-names": 0
161
+ };
162
+ return [
163
+ // 单独安装plugins,
164
+ {
165
+ plugins: {
166
+ jsdoc: pluginJsdoc
167
+ }
168
+ },
169
+ {
170
+ rules: {
171
+ ...cleanRules("jsdoc", recommendedRules, recommendedRules, rules),
172
+ ...options.overrides
173
+ }
174
+ }
175
+ ];
176
+ };
177
+
178
+ const markdown = async (options$) => {
179
+ const options = await pickOptions("markdown", options$);
180
+ if (!options.enable) {
181
+ return [];
182
+ }
183
+ const config = pluginMarkdown.configs.recommended.overrides[1];
184
+ return [
185
+ {
186
+ plugins: {
187
+ markdown: pluginMarkdown
188
+ }
189
+ },
190
+ {
191
+ files: ["**/*.md"],
192
+ processor: "markdown/markdown"
193
+ },
194
+ {
195
+ files: ["**/*.md/*.ts"],
196
+ rules: {
197
+ "@typescript-eslint/no-unused-vars": 0
198
+ }
199
+ },
200
+ {
201
+ files: ["**/*.md/**"],
202
+ languageOptions: {
203
+ parserOptions: {
204
+ ecmaFeatures: {
205
+ impliedStrict: true
206
+ }
207
+ }
208
+ },
209
+ rules: {
210
+ ...config.rules,
211
+ "no-console": 1,
212
+ ...options.overrides
213
+ }
214
+ }
215
+ ];
216
+ };
217
+
218
+ const ignores = async (ignores$ = []) => {
219
+ let defaults = [
220
+ "**/node_modules",
221
+ "**/dist",
222
+ "**/tmp",
223
+ "**/temp",
224
+ "**/coverage",
225
+ "**/package-lock.json",
226
+ "**/yarn.lock",
227
+ "**/pnpm-lock.yaml"
228
+ ];
229
+ if (ignores$ && ignores$.length) {
230
+ defaults = defaults.filter((i) => {
231
+ if (ignores$.includes(i)) {
232
+ return false;
233
+ }
234
+ const reverse = "!" + i;
235
+ if (ignores$.includes(reverse)) {
236
+ ignores$ = ignores$?.filter((j) => j !== reverse);
237
+ return false;
238
+ }
239
+ return true;
240
+ });
241
+ }
242
+ return [
243
+ {
244
+ ignores: [
245
+ ...defaults,
246
+ ...ignores$
247
+ ]
248
+ }
249
+ ];
250
+ };
251
+
252
+ const imports = async (options$) => {
253
+ const options = await pickOptions("import", options$);
254
+ if (!options.enable) {
255
+ return [];
256
+ }
257
+ const recommendedRules = pluginImport.configs.recommended.rules;
258
+ const rules = {
259
+ ...recommendedRules,
260
+ "import/newline-after-import": 1,
261
+ "import/no-unresolved": 0
262
+ };
263
+ return [
264
+ // 单独安装plugins,
265
+ {
266
+ plugins: {
267
+ import: pluginImport
268
+ },
269
+ settings: {
270
+ "import/parsers": {
271
+ espree: [".js", ".cjs", ".mjs", ".jsx"]
272
+ }
273
+ }
274
+ },
275
+ {
276
+ rules: {
277
+ ...cleanRules(
278
+ "import",
279
+ Object.keys(pluginImport.rules).reduce((pre, key) => {
280
+ pre[`import/${key}`] = 2;
281
+ return pre;
282
+ }, {}),
283
+ recommendedRules,
284
+ rules
285
+ ),
286
+ ...options.overrides
287
+ }
288
+ }
289
+ ];
290
+ };
291
+
292
+ const stylistic = async (options$) => {
293
+ const options = await pickOptions("stylistic", options$);
294
+ if (!options.enable) {
295
+ return [];
296
+ }
297
+ const config = pluginStylistic.configs.customize({
298
+ indent: "tab",
299
+ quotes: "single",
300
+ semi: true,
301
+ jsx: true
302
+ });
303
+ const allRules = config.rules;
304
+ const rules = {
305
+ ...allRules,
306
+ "@stylistic/comma-dangle": ["warn", {
307
+ arrays: "never",
308
+ objects: "ignore",
309
+ imports: "never",
310
+ exports: "never",
311
+ functions: "ignore"
312
+ }],
313
+ "@stylistic/brace-style": ["error", "1tbs", {
314
+ allowSingleLine: true
315
+ }],
316
+ "@stylistic/member-delimiter-style": 1,
317
+ "@stylistic/max-statements-per-line": ["off", { max: 1 }]
318
+ };
319
+ return [
320
+ // 单独安装plugins, 方便扩展
321
+ {
322
+ plugins: {
323
+ "@stylistic": pluginStylistic
324
+ }
325
+ },
326
+ {
327
+ rules: {
328
+ ...cleanRules("stylistic", allRules, allRules, rules),
329
+ ...options.overrides
330
+ }
331
+ }
332
+ ];
333
+ };
334
+
335
+ const configure = async (options, ...userConfigs) => {
336
+ const configs = [
337
+ ...await ignores(options?.ignores),
338
+ ...await javascript(options),
339
+ ...await typescript(options),
340
+ ...await jsdoc(options),
341
+ ...await markdown(options),
342
+ ...await imports(options),
343
+ ...await stylistic(options)
344
+ ];
345
+ return configs.concat(userConfigs);
346
+ };
347
+
348
+ exports.configure = configure;
@@ -0,0 +1,29 @@
1
+ import type { ESLint } from 'eslint';
2
+ import type { Linter } from 'eslint';
3
+
4
+ export declare interface ConfigOptions {
5
+ enable?: boolean;
6
+ overrides?: Rules;
7
+ }
8
+
9
+ export declare const configure: (options?: Options, ...userConfigs: FlatConfig[]) => Promise<FlatConfig[]>;
10
+
11
+ export declare type FlatConfig = Linter.FlatConfig;
12
+
13
+ export declare type Modules = 'stylistic' | 'javascript' | 'typescript' | 'markdown' | 'jsdoc' | 'vue' | 'react' | 'import';
14
+
15
+ export declare type Options = {
16
+ ignores?: string[];
17
+ overrides?: {
18
+ [key in Modules]?: Rules;
19
+ };
20
+ } & {
21
+ [key in Modules]?: boolean | ConfigOptions;
22
+ };
23
+
24
+ declare type Plugin_2 = ESLint.Plugin;
25
+ export { Plugin_2 as Plugin }
26
+
27
+ export declare type Rules = Linter.RulesRecord;
28
+
29
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,344 @@
1
+ import pluginTs from '@typescript-eslint/eslint-plugin';
2
+ import parserTs from '@typescript-eslint/parser';
3
+ import js from '@eslint/js';
4
+ import globals from 'globals';
5
+ import pluginJsdoc from 'eslint-plugin-jsdoc';
6
+ import pluginMarkdown from 'eslint-plugin-markdown';
7
+ import pluginImport from 'eslint-plugin-import';
8
+ import pluginStylistic from '@stylistic/eslint-plugin';
9
+
10
+ const pickOptions = async (key, options) => {
11
+ const configOptions = {
12
+ enable: typeof options?.[key] === "boolean" ? options[key] : true,
13
+ overrides: {},
14
+ ...typeof options?.[key] === "object" ? options[key] : {}
15
+ };
16
+ const overrides = options?.overrides?.[key] || {};
17
+ return {
18
+ ...configOptions,
19
+ overrides: {
20
+ ...configOptions.overrides,
21
+ ...overrides
22
+ }
23
+ };
24
+ };
25
+ const cleanRules = (key, all, recommended, current) => {
26
+ current = JSON.parse(JSON.stringify(current));
27
+ const deprecated = [];
28
+ const removed = [];
29
+ const invaild = [];
30
+ const keys = Object.keys(current);
31
+ keys.forEach((i) => {
32
+ /* istanbul ignore next -- @preserve */
33
+ if (all[i] === void 0 && recommended[i] === void 0) {
34
+ removed.push(i);
35
+ }
36
+ /* istanbul ignore next -- @preserve */
37
+ if (recommended[i] === void 0 && (all[i] !== 0 && all[i] !== "off") && (current[i] === 0 || current[i] === "off")) {
38
+ invaild.push(i);
39
+ }
40
+ });
41
+ Object.keys(recommended).forEach((i) => {
42
+ if (all[i] === void 0) {
43
+ deprecated.push(i);
44
+ delete current[i];
45
+ }
46
+ });
47
+ const isTest = process.env.NODE_ENV === "UNIT" && !process.env.CI;
48
+ /* istanbul ignore next -- @preserve */
49
+ if (isTest && removed.length) {
50
+ console.error(key + ": " + removed.join(",") + " has removed!\n");
51
+ }
52
+ /* istanbul ignore next -- @preserve */
53
+ if (isTest && invaild.length) {
54
+ console.error(key + ": " + invaild.join(",") + " has off default!\n");
55
+ }
56
+ /* istanbul ignore next -- @preserve */
57
+ if (isTest && deprecated.length) {
58
+ console.error(key + ": " + deprecated.join(",") + " has deprecated!\n");
59
+ }
60
+ return current;
61
+ };
62
+
63
+ const typescript = async (options$) => {
64
+ const options = await pickOptions("typescript", options$);
65
+ if (!options.enable) {
66
+ return [];
67
+ }
68
+ const recommendedRules = pluginTs.configs["eslint-recommended"].overrides[0].rules;
69
+ const allRules = pluginTs.configs["all"].rules;
70
+ const rules = {
71
+ ...recommendedRules,
72
+ "@typescript-eslint/no-shadow": 2,
73
+ // https://github.com/typescript-eslint/typescript-eslint/issues/2483
74
+ "@typescript-eslint/no-unused-vars": 1,
75
+ "@typescript-eslint/member-delimiter-style": 1,
76
+ // ignore duplicate rules
77
+ "no-unused-vars": 0
78
+ };
79
+ return [
80
+ // 单独安装plugins, 方便扩展
81
+ {
82
+ plugins: {
83
+ "@typescript-eslint": pluginTs
84
+ }
85
+ },
86
+ {
87
+ files: ["*.ts", "*.tsx", "*.mts", "*.cts"].map((i) => "**/" + i),
88
+ languageOptions: {
89
+ parser: parserTs,
90
+ parserOptions: {
91
+ sourceType: "module"
92
+ }
93
+ },
94
+ rules: {
95
+ ...cleanRules(
96
+ "typescript",
97
+ { ...allRules, ...recommendedRules },
98
+ // all使用了extends, 但这里使用flat config
99
+ recommendedRules,
100
+ rules
101
+ ),
102
+ ...options.overrides
103
+ }
104
+ }
105
+ ];
106
+ };
107
+
108
+ const javascript = async (options$) => {
109
+ const options = await pickOptions("javascript", options$);
110
+ if (!options.enable) {
111
+ return [];
112
+ }
113
+ const allRules = js.configs.all.rules;
114
+ const recommendedRules = js.configs.recommended.rules;
115
+ const rules = {
116
+ ...recommendedRules,
117
+ "no-undef": 1,
118
+ "no-debugger": 1,
119
+ "no-unused-vars": 1,
120
+ "no-useless-escape": 0
121
+ };
122
+ return [
123
+ {
124
+ languageOptions: {
125
+ ecmaVersion: "latest",
126
+ globals: {
127
+ ...globals.browser,
128
+ ...globals.es2021,
129
+ ...globals.node
130
+ },
131
+ parserOptions: {
132
+ ecmaFeatures: {
133
+ jsx: true
134
+ },
135
+ ecmaVersion: 2022,
136
+ sourceType: "module"
137
+ },
138
+ sourceType: "module"
139
+ },
140
+ rules: {
141
+ ...cleanRules("javascript", allRules, recommendedRules, rules),
142
+ ...options.overrides
143
+ }
144
+ }
145
+ ];
146
+ };
147
+
148
+ const jsdoc = async (options$) => {
149
+ const options = await pickOptions("jsdoc", options$);
150
+ if (!options.enable) {
151
+ return [];
152
+ }
153
+ const recommendedRules = pluginJsdoc.configs["flat/recommended-typescript"].rules;
154
+ const rules = {
155
+ ...recommendedRules,
156
+ "jsdoc/check-tag-names": 0
157
+ };
158
+ return [
159
+ // 单独安装plugins,
160
+ {
161
+ plugins: {
162
+ jsdoc: pluginJsdoc
163
+ }
164
+ },
165
+ {
166
+ rules: {
167
+ ...cleanRules("jsdoc", recommendedRules, recommendedRules, rules),
168
+ ...options.overrides
169
+ }
170
+ }
171
+ ];
172
+ };
173
+
174
+ const markdown = async (options$) => {
175
+ const options = await pickOptions("markdown", options$);
176
+ if (!options.enable) {
177
+ return [];
178
+ }
179
+ const config = pluginMarkdown.configs.recommended.overrides[1];
180
+ return [
181
+ {
182
+ plugins: {
183
+ markdown: pluginMarkdown
184
+ }
185
+ },
186
+ {
187
+ files: ["**/*.md"],
188
+ processor: "markdown/markdown"
189
+ },
190
+ {
191
+ files: ["**/*.md/*.ts"],
192
+ rules: {
193
+ "@typescript-eslint/no-unused-vars": 0
194
+ }
195
+ },
196
+ {
197
+ files: ["**/*.md/**"],
198
+ languageOptions: {
199
+ parserOptions: {
200
+ ecmaFeatures: {
201
+ impliedStrict: true
202
+ }
203
+ }
204
+ },
205
+ rules: {
206
+ ...config.rules,
207
+ "no-console": 1,
208
+ ...options.overrides
209
+ }
210
+ }
211
+ ];
212
+ };
213
+
214
+ const ignores = async (ignores$ = []) => {
215
+ let defaults = [
216
+ "**/node_modules",
217
+ "**/dist",
218
+ "**/tmp",
219
+ "**/temp",
220
+ "**/coverage",
221
+ "**/package-lock.json",
222
+ "**/yarn.lock",
223
+ "**/pnpm-lock.yaml"
224
+ ];
225
+ if (ignores$ && ignores$.length) {
226
+ defaults = defaults.filter((i) => {
227
+ if (ignores$.includes(i)) {
228
+ return false;
229
+ }
230
+ const reverse = "!" + i;
231
+ if (ignores$.includes(reverse)) {
232
+ ignores$ = ignores$?.filter((j) => j !== reverse);
233
+ return false;
234
+ }
235
+ return true;
236
+ });
237
+ }
238
+ return [
239
+ {
240
+ ignores: [
241
+ ...defaults,
242
+ ...ignores$
243
+ ]
244
+ }
245
+ ];
246
+ };
247
+
248
+ const imports = async (options$) => {
249
+ const options = await pickOptions("import", options$);
250
+ if (!options.enable) {
251
+ return [];
252
+ }
253
+ const recommendedRules = pluginImport.configs.recommended.rules;
254
+ const rules = {
255
+ ...recommendedRules,
256
+ "import/newline-after-import": 1,
257
+ "import/no-unresolved": 0
258
+ };
259
+ return [
260
+ // 单独安装plugins,
261
+ {
262
+ plugins: {
263
+ import: pluginImport
264
+ },
265
+ settings: {
266
+ "import/parsers": {
267
+ espree: [".js", ".cjs", ".mjs", ".jsx"]
268
+ }
269
+ }
270
+ },
271
+ {
272
+ rules: {
273
+ ...cleanRules(
274
+ "import",
275
+ Object.keys(pluginImport.rules).reduce((pre, key) => {
276
+ pre[`import/${key}`] = 2;
277
+ return pre;
278
+ }, {}),
279
+ recommendedRules,
280
+ rules
281
+ ),
282
+ ...options.overrides
283
+ }
284
+ }
285
+ ];
286
+ };
287
+
288
+ const stylistic = async (options$) => {
289
+ const options = await pickOptions("stylistic", options$);
290
+ if (!options.enable) {
291
+ return [];
292
+ }
293
+ const config = pluginStylistic.configs.customize({
294
+ indent: "tab",
295
+ quotes: "single",
296
+ semi: true,
297
+ jsx: true
298
+ });
299
+ const allRules = config.rules;
300
+ const rules = {
301
+ ...allRules,
302
+ "@stylistic/comma-dangle": ["warn", {
303
+ arrays: "never",
304
+ objects: "ignore",
305
+ imports: "never",
306
+ exports: "never",
307
+ functions: "ignore"
308
+ }],
309
+ "@stylistic/brace-style": ["error", "1tbs", {
310
+ allowSingleLine: true
311
+ }],
312
+ "@stylistic/member-delimiter-style": 1,
313
+ "@stylistic/max-statements-per-line": ["off", { max: 1 }]
314
+ };
315
+ return [
316
+ // 单独安装plugins, 方便扩展
317
+ {
318
+ plugins: {
319
+ "@stylistic": pluginStylistic
320
+ }
321
+ },
322
+ {
323
+ rules: {
324
+ ...cleanRules("stylistic", allRules, allRules, rules),
325
+ ...options.overrides
326
+ }
327
+ }
328
+ ];
329
+ };
330
+
331
+ const configure = async (options, ...userConfigs) => {
332
+ const configs = [
333
+ ...await ignores(options?.ignores),
334
+ ...await javascript(options),
335
+ ...await typescript(options),
336
+ ...await jsdoc(options),
337
+ ...await markdown(options),
338
+ ...await imports(options),
339
+ ...await stylistic(options)
340
+ ];
341
+ return configs.concat(userConfigs);
342
+ };
343
+
344
+ export { configure };
package/package.json CHANGED
@@ -1,24 +1,34 @@
1
1
  {
2
2
  "name": "@deot/dev-eslint",
3
- "version": "2.7.0",
4
- "main": "index.js",
3
+ "version": "2.8.1",
4
+ "main": "dist/index.js",
5
+ "type": "module",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.cjs",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
5
14
  "files": [
6
- "index.js"
15
+ "dist"
7
16
  ],
8
17
  "license": "MIT",
9
18
  "publishConfig": {
10
19
  "access": "public"
11
20
  },
12
21
  "dependencies": {
13
- "@babel/eslint-plugin": "^7.23.5",
14
- "@typescript-eslint/eslint-plugin": "^6.13.2",
15
- "@typescript-eslint/parser": "^6.13.2",
16
- "eslint-config-airbnb-base": "^15.0.0",
22
+ "@stylistic/eslint-plugin": "^1.5.1",
23
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
24
+ "@typescript-eslint/parser": "^6.14.0",
17
25
  "eslint-plugin-import": "^2.29.0",
18
- "eslint-plugin-jsdoc": "^46.9.0",
19
- "eslint-plugin-markdown": "^3.0.1"
26
+ "eslint-plugin-jsdoc": "^46.9.1",
27
+ "eslint-plugin-markdown": "^3.0.1",
28
+ "globals": "^13.24.0"
20
29
  },
21
30
  "devDependencies": {
31
+ "@types/eslint": "^8.44.9",
22
32
  "eslint": "^8.55.0"
23
33
  }
24
34
  }
package/index.js DELETED
@@ -1,236 +0,0 @@
1
- module.exports = {
2
- "root": true,
3
- "parser": "@typescript-eslint/parser",
4
- "parserOptions": {
5
- "requireConfigFile": false,
6
- "ecmaVersion": 2020,
7
- "sourceType": "module",
8
- "ecmaFeatures": {
9
- "jsx": true,
10
- "tsx": true
11
- }
12
- },
13
- "env":
14
- {
15
- "browser": true,
16
- "node": true,
17
- "es6": true,
18
- "mocha": true
19
- },
20
- // 四个级别: base/essential/strongly-recommended/recommended, 使用最高约束
21
- "extends": [
22
- "eslint:recommended",
23
- "plugin:@typescript-eslint/recommended",
24
- "plugin:jsdoc/recommended-typescript",
25
- "plugin:markdown/recommended",
26
- "airbnb-base"
27
- ],
28
- "plugins": [
29
- "@babel",
30
- "@typescript-eslint",
31
- "markdown",
32
- "jsdoc"
33
- ],
34
- "settings": {
35
- "import/resolver": {
36
- "node": {
37
- "extensions": [
38
- ".js"
39
- ]
40
- }
41
- }
42
- },
43
- "globals": {
44
- "_global": "readonly"
45
- },
46
-
47
- // 避免全局类型出错
48
- "overrides": [
49
- {
50
- // .md有效
51
- "files": ["**/*.md"],
52
- "processor": "markdown/markdown"
53
- },
54
- {
55
- // 在md文件中标识:```js
56
- "files": ["**/*.md/*.js"],
57
- "rules": {
58
- "no-console": 0,
59
- "import/no-unresolved": 0,
60
- "no-undef": 0
61
- }
62
- },
63
-
64
- {
65
- "files": ["*.ts", "*.tsx"],
66
- "rules": {
67
- "no-undef": 0
68
- }
69
- }
70
- ],
71
-
72
- "rules":
73
- {
74
- // jsdoc
75
- "jsdoc/check-tag-names": 0,
76
-
77
- "import/no-import-module-exports": 0,
78
-
79
- // ts
80
- "@typescript-eslint/ban-ts-ignore": 0,
81
- "@typescript-eslint/explicit-function-return-type": 0,
82
- "@typescript-eslint/no-explicit-any": 0,
83
- "@typescript-eslint/no-var-requires": 0,
84
- "@typescript-eslint/no-empty-function": 0,
85
- "@typescript-eslint/no-use-before-define": 0,
86
- "@typescript-eslint/ban-ts-comment": 0,
87
- "@typescript-eslint/ban-types": 0,
88
- "@typescript-eslint/no-non-null-assertion": 0,
89
- "@typescript-eslint/explicit-module-boundary-types": 0,
90
- "@typescript-eslint/no-unused-vars": 1,
91
- "@typescript-eslint/no-inferrable-types": 0,
92
- // https://github.com/typescript-eslint/typescript-eslint/issues/2483
93
- "@typescript-eslint/no-shadow": "error",
94
- "@typescript-eslint/member-delimiter-style": 'warn',
95
- "no-shadow": "off",
96
-
97
- // "@typescript-eslint/no-unused-vars": [
98
- // "warn",
99
- // {
100
- // argsIgnorePattern: "^_",
101
- // varsIgnorePattern: "^_",
102
- // }
103
- // ],
104
-
105
- // airbnb
106
- "comma-dangle": ["warn", {
107
- "arrays": "never",
108
- "objects": "ignore",
109
- "imports": "never",
110
- "exports": "never",
111
- "functions": "ignore"
112
- }],
113
- "camelcase": 0,
114
- "dot-notation": 0,
115
- "new-parens": ["warn"],
116
- "no-mixed-spaces-and-tabs": ["warn", "smart-tabs"],
117
- "object-curly-newline": 0, // { a, b, c } 允许不换行
118
- "arrow-body-style": 0, // a => 1
119
- "arrow-parens": 0, // a => 1
120
- "quote-props": 0, // "a-1": 2
121
- "guard-for-in": 0, // xx.hasOwnProperty(key)
122
- "no-restricted-syntax": 0,
123
- "global-require": 0,
124
- "eqeqeq": 0,
125
- "no-plusplus": 0,
126
- "no-unused-expressions": 0,
127
- "no-undef": ["warn"],
128
- "no-unused-vars": 0,
129
- "import/no-extraneous-dependencies": 0,
130
- "import/prefer-default-export": 0,
131
- "import/newline-after-import": ["warn"],
132
- "import/first": 0,
133
- "import/no-unresolved": 0,
134
- "import/extensions": 0,
135
- "no-multiple-empty-lines": 0,
136
- "no-restricted-globals": 0,
137
- "no-param-reassign": 0,
138
- "no-use-before-define": 0,
139
- "consistent-return": 0,
140
- "no-useless-return": 0,
141
- "prefer-const": 0,
142
- "no-else-return": 0,
143
- "no-useless-escape": 0,
144
- "func-names": 0,
145
- "prefer-arrow-callback": 0,
146
- "no-bitwise": 0,
147
- "padded-blocks": 0, // {} 允许空行
148
- "no-return-assign": 0,
149
- "max-len": ["warn", { "code": 150, "ignoreComments": true }],
150
- "prefer-destructuring": 0,
151
- "prefer-template": 0,
152
- "no-nested-ternary": 0,
153
- "prefer-rest-params": 0,
154
- "class-methods-use-this": 0,
155
- // tab缩进
156
- "indent": ["warn", "tab", { "SwitchCase": 1 }],
157
- "no-tabs": 0,
158
- "quotes": 0,
159
- "no-console": 0,
160
- "no-debugger": 1,
161
- "no-var": 1,
162
- "import/named": 0,
163
- "semi": [
164
- 1,
165
- "always"
166
- ],
167
- "no-trailing-spaces": 0,
168
- "eol-last": 0,
169
- "no-underscore-dangle": 0,
170
- "no-alert": 0,
171
- "no-lone-blocks": 0,
172
- // 关键字周围强制使用空格
173
- "keyword-spacing": [
174
- "error",
175
- {
176
- "before": true,
177
- "after": true
178
- }
179
- ],
180
- // 大括号中强制使用空格
181
- "object-curly-spacing": [
182
- "warn",
183
- "always"
184
- ],
185
- // 单行代码块前后要加空格
186
- "block-spacing": [
187
- "warn",
188
- "always"
189
- ],
190
- // 逗号后面加空格
191
- "comma-spacing": [
192
- "warn",
193
- {
194
- "before": false,
195
- "after": true
196
- }
197
- ],
198
- // 分号后面加空格
199
- "semi-spacing": [
200
- "warn",
201
- {
202
- "before": false,
203
- "after": true
204
- }
205
- ],
206
- // 在注释前有空白
207
- "spaced-comment": [
208
- "warn",
209
- "always"
210
- ],
211
- // 箭头函数前后要有空格
212
- "arrow-spacing": [
213
- "warn",
214
- {
215
- "before": true,
216
- "after": true
217
- }
218
- ],
219
- // 对象字面量的属性中键和值之间使用一致的间距
220
- "key-spacing": [
221
- "warn",
222
- {
223
- "beforeColon": false,
224
- "afterColon": true
225
- }
226
- ],
227
- // 要求操作符周围有空格
228
- "space-infix-ops": [
229
- "warn",
230
- {
231
- "int32Hint": false
232
- }
233
- ],
234
- "jsx-quotes": 1,
235
- }
236
- };