@deot/dev-eslint 2.6.3 → 2.8.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,347 @@
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
+ /* istanbul ignore next -- @preserve */
52
+ if (removed.length) {
53
+ console.error(key + ": " + removed.join(",") + " has removed!\n");
54
+ }
55
+ /* istanbul ignore next -- @preserve */
56
+ if (invaild.length) {
57
+ console.error(key + ": " + invaild.join(",") + " has off default!\n");
58
+ }
59
+ /* istanbul ignore next -- @preserve */
60
+ if (deprecated.length) {
61
+ console.error(key + ": " + deprecated.join(",") + " has deprecated!\n");
62
+ }
63
+ return current;
64
+ };
65
+
66
+ const typescript = async (options$) => {
67
+ const options = await pickOptions("typescript", options$);
68
+ if (!options.enable) {
69
+ return [];
70
+ }
71
+ const recommendedRules = pluginTs.configs["eslint-recommended"].overrides[0].rules;
72
+ const allRules = pluginTs.configs["all"].rules;
73
+ const rules = {
74
+ ...recommendedRules,
75
+ "@typescript-eslint/no-shadow": 2,
76
+ // https://github.com/typescript-eslint/typescript-eslint/issues/2483
77
+ "@typescript-eslint/no-unused-vars": 1,
78
+ "@typescript-eslint/member-delimiter-style": 1,
79
+ // ignore duplicate rules
80
+ "no-unused-vars": 0
81
+ };
82
+ return [
83
+ // 单独安装plugins, 方便扩展
84
+ {
85
+ plugins: {
86
+ "@typescript-eslint": pluginTs
87
+ }
88
+ },
89
+ {
90
+ files: ["*.ts", "*.tsx", "*.mts", "*.cts"].map((i) => "**/" + i),
91
+ languageOptions: {
92
+ parser: parserTs,
93
+ parserOptions: {
94
+ sourceType: "module"
95
+ }
96
+ },
97
+ rules: {
98
+ ...cleanRules(
99
+ "typescript",
100
+ { ...allRules, ...recommendedRules },
101
+ // all使用了extends, 但这里使用flat config
102
+ recommendedRules,
103
+ rules
104
+ ),
105
+ ...options.overrides
106
+ }
107
+ }
108
+ ];
109
+ };
110
+
111
+ const javascript = async (options$) => {
112
+ const options = await pickOptions("javascript", options$);
113
+ if (!options.enable) {
114
+ return [];
115
+ }
116
+ const allRules = js.configs.all.rules;
117
+ const recommendedRules = js.configs.recommended.rules;
118
+ const rules = {
119
+ ...recommendedRules,
120
+ "no-undef": 1,
121
+ "no-debugger": 1,
122
+ "no-unused-vars": 1,
123
+ "no-useless-escape": 0
124
+ };
125
+ return [
126
+ {
127
+ languageOptions: {
128
+ ecmaVersion: "latest",
129
+ globals: {
130
+ ...globals.browser,
131
+ ...globals.es2021,
132
+ ...globals.node
133
+ },
134
+ parserOptions: {
135
+ ecmaFeatures: {
136
+ jsx: true
137
+ },
138
+ ecmaVersion: 2022,
139
+ sourceType: "module"
140
+ },
141
+ sourceType: "module"
142
+ },
143
+ rules: {
144
+ ...cleanRules("javascript", allRules, recommendedRules, rules),
145
+ ...options.overrides
146
+ }
147
+ }
148
+ ];
149
+ };
150
+
151
+ const jsdoc = async (options$) => {
152
+ const options = await pickOptions("jsdoc", options$);
153
+ if (!options.enable) {
154
+ return [];
155
+ }
156
+ const recommendedRules = pluginJsdoc.configs["flat/recommended-typescript"].rules;
157
+ const rules = {
158
+ ...recommendedRules,
159
+ "jsdoc/check-tag-names": 0
160
+ };
161
+ return [
162
+ // 单独安装plugins,
163
+ {
164
+ plugins: {
165
+ jsdoc: pluginJsdoc
166
+ }
167
+ },
168
+ {
169
+ rules: {
170
+ ...cleanRules("jsdoc", recommendedRules, recommendedRules, rules),
171
+ ...options.overrides
172
+ }
173
+ }
174
+ ];
175
+ };
176
+
177
+ const markdown = async (options$) => {
178
+ const options = await pickOptions("markdown", options$);
179
+ if (!options.enable) {
180
+ return [];
181
+ }
182
+ const config = pluginMarkdown.configs.recommended.overrides[1];
183
+ return [
184
+ {
185
+ plugins: {
186
+ markdown: pluginMarkdown
187
+ }
188
+ },
189
+ {
190
+ files: ["**/*.md"],
191
+ processor: "markdown/markdown"
192
+ },
193
+ {
194
+ files: ["**/*.md/*.ts"],
195
+ rules: {
196
+ "@typescript-eslint/no-unused-vars": 0
197
+ }
198
+ },
199
+ {
200
+ files: ["**/*.md/**"],
201
+ languageOptions: {
202
+ parserOptions: {
203
+ ecmaFeatures: {
204
+ impliedStrict: true
205
+ }
206
+ }
207
+ },
208
+ rules: {
209
+ ...config.rules,
210
+ "no-console": 1,
211
+ ...options.overrides
212
+ }
213
+ }
214
+ ];
215
+ };
216
+
217
+ const ignores = async (ignores$ = []) => {
218
+ let defaults = [
219
+ "**/node_modules",
220
+ "**/dist",
221
+ "**/tmp",
222
+ "**/temp",
223
+ "**/coverage",
224
+ "**/package-lock.json",
225
+ "**/yarn.lock",
226
+ "**/pnpm-lock.yaml"
227
+ ];
228
+ if (ignores$ && ignores$.length) {
229
+ defaults = defaults.filter((i) => {
230
+ if (ignores$.includes(i)) {
231
+ return false;
232
+ }
233
+ const reverse = "!" + i;
234
+ if (ignores$.includes(reverse)) {
235
+ ignores$ = ignores$?.filter((j) => j !== reverse);
236
+ return false;
237
+ }
238
+ return true;
239
+ });
240
+ }
241
+ return [
242
+ {
243
+ ignores: [
244
+ ...defaults,
245
+ ...ignores$
246
+ ]
247
+ }
248
+ ];
249
+ };
250
+
251
+ const imports = async (options$) => {
252
+ const options = await pickOptions("import", options$);
253
+ if (!options.enable) {
254
+ return [];
255
+ }
256
+ const recommendedRules = pluginImport.configs.recommended.rules;
257
+ const rules = {
258
+ ...recommendedRules,
259
+ "import/newline-after-import": 1,
260
+ "import/no-unresolved": 0
261
+ };
262
+ return [
263
+ // 单独安装plugins,
264
+ {
265
+ plugins: {
266
+ import: pluginImport
267
+ },
268
+ settings: {
269
+ "import/parsers": {
270
+ espree: [".js", ".cjs", ".mjs", ".jsx"]
271
+ }
272
+ }
273
+ },
274
+ {
275
+ rules: {
276
+ ...cleanRules(
277
+ "import",
278
+ Object.keys(pluginImport.rules).reduce((pre, key) => {
279
+ pre[`import/${key}`] = 2;
280
+ return pre;
281
+ }, {}),
282
+ recommendedRules,
283
+ rules
284
+ ),
285
+ ...options.overrides
286
+ }
287
+ }
288
+ ];
289
+ };
290
+
291
+ const stylistic = async (options$) => {
292
+ const options = await pickOptions("stylistic", options$);
293
+ if (!options.enable) {
294
+ return [];
295
+ }
296
+ const config = pluginStylistic.configs.customize({
297
+ indent: "tab",
298
+ quotes: "single",
299
+ semi: true,
300
+ jsx: true
301
+ });
302
+ const allRules = config.rules;
303
+ const rules = {
304
+ ...allRules,
305
+ "@stylistic/comma-dangle": ["warn", {
306
+ arrays: "never",
307
+ objects: "ignore",
308
+ imports: "never",
309
+ exports: "never",
310
+ functions: "ignore"
311
+ }],
312
+ "@stylistic/brace-style": ["error", "1tbs", {
313
+ allowSingleLine: true
314
+ }],
315
+ "@stylistic/member-delimiter-style": 1,
316
+ "@stylistic/max-statements-per-line": ["off", { max: 1 }]
317
+ };
318
+ return [
319
+ // 单独安装plugins, 方便扩展
320
+ {
321
+ plugins: {
322
+ "@stylistic": pluginStylistic
323
+ }
324
+ },
325
+ {
326
+ rules: {
327
+ ...cleanRules("stylistic", allRules, allRules, rules),
328
+ ...options.overrides
329
+ }
330
+ }
331
+ ];
332
+ };
333
+
334
+ const configuire = async (options, ...userConfigs) => {
335
+ const configs = [
336
+ ...await ignores(options?.ignores),
337
+ ...await javascript(options),
338
+ ...await typescript(options),
339
+ ...await jsdoc(options),
340
+ ...await markdown(options),
341
+ ...await imports(options),
342
+ ...await stylistic(options)
343
+ ];
344
+ return configs.concat(userConfigs);
345
+ };
346
+
347
+ exports.configuire = configuire;
@@ -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 configuire: (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,343 @@
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
+ /* istanbul ignore next -- @preserve */
48
+ if (removed.length) {
49
+ console.error(key + ": " + removed.join(",") + " has removed!\n");
50
+ }
51
+ /* istanbul ignore next -- @preserve */
52
+ if (invaild.length) {
53
+ console.error(key + ": " + invaild.join(",") + " has off default!\n");
54
+ }
55
+ /* istanbul ignore next -- @preserve */
56
+ if (deprecated.length) {
57
+ console.error(key + ": " + deprecated.join(",") + " has deprecated!\n");
58
+ }
59
+ return current;
60
+ };
61
+
62
+ const typescript = async (options$) => {
63
+ const options = await pickOptions("typescript", options$);
64
+ if (!options.enable) {
65
+ return [];
66
+ }
67
+ const recommendedRules = pluginTs.configs["eslint-recommended"].overrides[0].rules;
68
+ const allRules = pluginTs.configs["all"].rules;
69
+ const rules = {
70
+ ...recommendedRules,
71
+ "@typescript-eslint/no-shadow": 2,
72
+ // https://github.com/typescript-eslint/typescript-eslint/issues/2483
73
+ "@typescript-eslint/no-unused-vars": 1,
74
+ "@typescript-eslint/member-delimiter-style": 1,
75
+ // ignore duplicate rules
76
+ "no-unused-vars": 0
77
+ };
78
+ return [
79
+ // 单独安装plugins, 方便扩展
80
+ {
81
+ plugins: {
82
+ "@typescript-eslint": pluginTs
83
+ }
84
+ },
85
+ {
86
+ files: ["*.ts", "*.tsx", "*.mts", "*.cts"].map((i) => "**/" + i),
87
+ languageOptions: {
88
+ parser: parserTs,
89
+ parserOptions: {
90
+ sourceType: "module"
91
+ }
92
+ },
93
+ rules: {
94
+ ...cleanRules(
95
+ "typescript",
96
+ { ...allRules, ...recommendedRules },
97
+ // all使用了extends, 但这里使用flat config
98
+ recommendedRules,
99
+ rules
100
+ ),
101
+ ...options.overrides
102
+ }
103
+ }
104
+ ];
105
+ };
106
+
107
+ const javascript = async (options$) => {
108
+ const options = await pickOptions("javascript", options$);
109
+ if (!options.enable) {
110
+ return [];
111
+ }
112
+ const allRules = js.configs.all.rules;
113
+ const recommendedRules = js.configs.recommended.rules;
114
+ const rules = {
115
+ ...recommendedRules,
116
+ "no-undef": 1,
117
+ "no-debugger": 1,
118
+ "no-unused-vars": 1,
119
+ "no-useless-escape": 0
120
+ };
121
+ return [
122
+ {
123
+ languageOptions: {
124
+ ecmaVersion: "latest",
125
+ globals: {
126
+ ...globals.browser,
127
+ ...globals.es2021,
128
+ ...globals.node
129
+ },
130
+ parserOptions: {
131
+ ecmaFeatures: {
132
+ jsx: true
133
+ },
134
+ ecmaVersion: 2022,
135
+ sourceType: "module"
136
+ },
137
+ sourceType: "module"
138
+ },
139
+ rules: {
140
+ ...cleanRules("javascript", allRules, recommendedRules, rules),
141
+ ...options.overrides
142
+ }
143
+ }
144
+ ];
145
+ };
146
+
147
+ const jsdoc = async (options$) => {
148
+ const options = await pickOptions("jsdoc", options$);
149
+ if (!options.enable) {
150
+ return [];
151
+ }
152
+ const recommendedRules = pluginJsdoc.configs["flat/recommended-typescript"].rules;
153
+ const rules = {
154
+ ...recommendedRules,
155
+ "jsdoc/check-tag-names": 0
156
+ };
157
+ return [
158
+ // 单独安装plugins,
159
+ {
160
+ plugins: {
161
+ jsdoc: pluginJsdoc
162
+ }
163
+ },
164
+ {
165
+ rules: {
166
+ ...cleanRules("jsdoc", recommendedRules, recommendedRules, rules),
167
+ ...options.overrides
168
+ }
169
+ }
170
+ ];
171
+ };
172
+
173
+ const markdown = async (options$) => {
174
+ const options = await pickOptions("markdown", options$);
175
+ if (!options.enable) {
176
+ return [];
177
+ }
178
+ const config = pluginMarkdown.configs.recommended.overrides[1];
179
+ return [
180
+ {
181
+ plugins: {
182
+ markdown: pluginMarkdown
183
+ }
184
+ },
185
+ {
186
+ files: ["**/*.md"],
187
+ processor: "markdown/markdown"
188
+ },
189
+ {
190
+ files: ["**/*.md/*.ts"],
191
+ rules: {
192
+ "@typescript-eslint/no-unused-vars": 0
193
+ }
194
+ },
195
+ {
196
+ files: ["**/*.md/**"],
197
+ languageOptions: {
198
+ parserOptions: {
199
+ ecmaFeatures: {
200
+ impliedStrict: true
201
+ }
202
+ }
203
+ },
204
+ rules: {
205
+ ...config.rules,
206
+ "no-console": 1,
207
+ ...options.overrides
208
+ }
209
+ }
210
+ ];
211
+ };
212
+
213
+ const ignores = async (ignores$ = []) => {
214
+ let defaults = [
215
+ "**/node_modules",
216
+ "**/dist",
217
+ "**/tmp",
218
+ "**/temp",
219
+ "**/coverage",
220
+ "**/package-lock.json",
221
+ "**/yarn.lock",
222
+ "**/pnpm-lock.yaml"
223
+ ];
224
+ if (ignores$ && ignores$.length) {
225
+ defaults = defaults.filter((i) => {
226
+ if (ignores$.includes(i)) {
227
+ return false;
228
+ }
229
+ const reverse = "!" + i;
230
+ if (ignores$.includes(reverse)) {
231
+ ignores$ = ignores$?.filter((j) => j !== reverse);
232
+ return false;
233
+ }
234
+ return true;
235
+ });
236
+ }
237
+ return [
238
+ {
239
+ ignores: [
240
+ ...defaults,
241
+ ...ignores$
242
+ ]
243
+ }
244
+ ];
245
+ };
246
+
247
+ const imports = async (options$) => {
248
+ const options = await pickOptions("import", options$);
249
+ if (!options.enable) {
250
+ return [];
251
+ }
252
+ const recommendedRules = pluginImport.configs.recommended.rules;
253
+ const rules = {
254
+ ...recommendedRules,
255
+ "import/newline-after-import": 1,
256
+ "import/no-unresolved": 0
257
+ };
258
+ return [
259
+ // 单独安装plugins,
260
+ {
261
+ plugins: {
262
+ import: pluginImport
263
+ },
264
+ settings: {
265
+ "import/parsers": {
266
+ espree: [".js", ".cjs", ".mjs", ".jsx"]
267
+ }
268
+ }
269
+ },
270
+ {
271
+ rules: {
272
+ ...cleanRules(
273
+ "import",
274
+ Object.keys(pluginImport.rules).reduce((pre, key) => {
275
+ pre[`import/${key}`] = 2;
276
+ return pre;
277
+ }, {}),
278
+ recommendedRules,
279
+ rules
280
+ ),
281
+ ...options.overrides
282
+ }
283
+ }
284
+ ];
285
+ };
286
+
287
+ const stylistic = async (options$) => {
288
+ const options = await pickOptions("stylistic", options$);
289
+ if (!options.enable) {
290
+ return [];
291
+ }
292
+ const config = pluginStylistic.configs.customize({
293
+ indent: "tab",
294
+ quotes: "single",
295
+ semi: true,
296
+ jsx: true
297
+ });
298
+ const allRules = config.rules;
299
+ const rules = {
300
+ ...allRules,
301
+ "@stylistic/comma-dangle": ["warn", {
302
+ arrays: "never",
303
+ objects: "ignore",
304
+ imports: "never",
305
+ exports: "never",
306
+ functions: "ignore"
307
+ }],
308
+ "@stylistic/brace-style": ["error", "1tbs", {
309
+ allowSingleLine: true
310
+ }],
311
+ "@stylistic/member-delimiter-style": 1,
312
+ "@stylistic/max-statements-per-line": ["off", { max: 1 }]
313
+ };
314
+ return [
315
+ // 单独安装plugins, 方便扩展
316
+ {
317
+ plugins: {
318
+ "@stylistic": pluginStylistic
319
+ }
320
+ },
321
+ {
322
+ rules: {
323
+ ...cleanRules("stylistic", allRules, allRules, rules),
324
+ ...options.overrides
325
+ }
326
+ }
327
+ ];
328
+ };
329
+
330
+ const configuire = async (options, ...userConfigs) => {
331
+ const configs = [
332
+ ...await ignores(options?.ignores),
333
+ ...await javascript(options),
334
+ ...await typescript(options),
335
+ ...await jsdoc(options),
336
+ ...await markdown(options),
337
+ ...await imports(options),
338
+ ...await stylistic(options)
339
+ ];
340
+ return configs.concat(userConfigs);
341
+ };
342
+
343
+ export { configuire };
package/package.json CHANGED
@@ -1,24 +1,34 @@
1
1
  {
2
2
  "name": "@deot/dev-eslint",
3
- "version": "2.6.3",
4
- "main": "index.js",
3
+ "version": "2.8.0",
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.22.10",
14
- "@typescript-eslint/eslint-plugin": "^5.61.0",
15
- "@typescript-eslint/parser": "^5.61.0",
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": {
22
- "eslint": "^8.53.0"
31
+ "@types/eslint": "^8.44.9",
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
- };