@dhzh/eslint-config 1.27.1 → 2.0.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 DELETED
@@ -1,1447 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_chunk = require("./chunk-CKQMccvm.cjs");
3
- let _eslint_react_eslint_plugin = require("@eslint-react/eslint-plugin");
4
- _eslint_react_eslint_plugin = require_chunk.__toESM(_eslint_react_eslint_plugin, 1);
5
- let eslint_plugin_react_hooks = require("eslint-plugin-react-hooks");
6
- eslint_plugin_react_hooks = require_chunk.__toESM(eslint_plugin_react_hooks, 1);
7
- let eslint_plugin_react_refresh = require("eslint-plugin-react-refresh");
8
- eslint_plugin_react_refresh = require_chunk.__toESM(eslint_plugin_react_refresh, 1);
9
- let eslint_plugin_react_compiler = require("eslint-plugin-react-compiler");
10
- eslint_plugin_react_compiler = require_chunk.__toESM(eslint_plugin_react_compiler, 1);
11
- let eslint_plugin_react_google_translate = require("eslint-plugin-react-google-translate");
12
- eslint_plugin_react_google_translate = require_chunk.__toESM(eslint_plugin_react_google_translate, 1);
13
- let local_pkg = require("local-pkg");
14
- let eslint_config = require("eslint/config");
15
- let _eslint_js = require("@eslint/js");
16
- _eslint_js = require_chunk.__toESM(_eslint_js, 1);
17
- let typescript_eslint = require("typescript-eslint");
18
- typescript_eslint = require_chunk.__toESM(typescript_eslint, 1);
19
- let eslint_plugin_vue = require("eslint-plugin-vue");
20
- eslint_plugin_vue = require_chunk.__toESM(eslint_plugin_vue, 1);
21
- let globals = require("globals");
22
- globals = require_chunk.__toESM(globals, 1);
23
- let eslint_merge_processors = require("eslint-merge-processors");
24
- let eslint_processor_vue_blocks = require("eslint-processor-vue-blocks");
25
- eslint_processor_vue_blocks = require_chunk.__toESM(eslint_processor_vue_blocks, 1);
26
- let _stylistic_eslint_plugin = require("@stylistic/eslint-plugin");
27
- _stylistic_eslint_plugin = require_chunk.__toESM(_stylistic_eslint_plugin, 1);
28
- let eslint_plugin_antfu = require("eslint-plugin-antfu");
29
- eslint_plugin_antfu = require_chunk.__toESM(eslint_plugin_antfu, 1);
30
- let node_process = require("node:process");
31
- node_process = require_chunk.__toESM(node_process, 1);
32
- let eslint_plugin_n = require("eslint-plugin-n");
33
- eslint_plugin_n = require_chunk.__toESM(eslint_plugin_n, 1);
34
- let eslint_plugin_jsonc = require("eslint-plugin-jsonc");
35
- eslint_plugin_jsonc = require_chunk.__toESM(eslint_plugin_jsonc, 1);
36
- let eslint_plugin_package_json = require("eslint-plugin-package-json");
37
- eslint_plugin_package_json = require_chunk.__toESM(eslint_plugin_package_json, 1);
38
- let eslint_plugin_unicorn = require("eslint-plugin-unicorn");
39
- eslint_plugin_unicorn = require_chunk.__toESM(eslint_plugin_unicorn, 1);
40
- let eslint_plugin_import_x = require("eslint-plugin-import-x");
41
- eslint_plugin_import_x = require_chunk.__toESM(eslint_plugin_import_x, 1);
42
- let eslint_plugin_unused_imports = require("eslint-plugin-unused-imports");
43
- eslint_plugin_unused_imports = require_chunk.__toESM(eslint_plugin_unused_imports, 1);
44
- let eslint_plugin_simple_import_sort = require("eslint-plugin-simple-import-sort");
45
- eslint_plugin_simple_import_sort = require_chunk.__toESM(eslint_plugin_simple_import_sort, 1);
46
- let eslint_plugin_format = require("eslint-plugin-format");
47
- eslint_plugin_format = require_chunk.__toESM(eslint_plugin_format, 1);
48
- let eslint_plugin_tailwindcss = require("eslint-plugin-tailwindcss");
49
- eslint_plugin_tailwindcss = require_chunk.__toESM(eslint_plugin_tailwindcss, 1);
50
- let _unocss_eslint_config_flat = require("@unocss/eslint-config/flat");
51
- _unocss_eslint_config_flat = require_chunk.__toESM(_unocss_eslint_config_flat, 1);
52
- let eslint_plugin_yml = require("eslint-plugin-yml");
53
- eslint_plugin_yml = require_chunk.__toESM(eslint_plugin_yml, 1);
54
- let eslint_plugin_toml = require("eslint-plugin-toml");
55
- eslint_plugin_toml = require_chunk.__toESM(eslint_plugin_toml, 1);
56
- let toml_eslint_parser = require("toml-eslint-parser");
57
- toml_eslint_parser = require_chunk.__toESM(toml_eslint_parser, 1);
58
- let eslint_plugin_regexp = require("eslint-plugin-regexp");
59
- eslint_plugin_regexp = require_chunk.__toESM(eslint_plugin_regexp, 1);
60
- let _eslint_community_eslint_plugin_eslint_comments_configs = require("@eslint-community/eslint-plugin-eslint-comments/configs");
61
- _eslint_community_eslint_plugin_eslint_comments_configs = require_chunk.__toESM(_eslint_community_eslint_plugin_eslint_comments_configs, 1);
62
- //#region src/consts.ts
63
- const RULE_PREFIX = "tinywaves";
64
- const GLOB_YML = "**/*.y?(a)ml";
65
- const GLOB_TOML = "**/*.toml";
66
- const GLOB_JSON = "**/*.json";
67
- const GLOB_JSON5 = "**/*.json5";
68
- const GLOB_JSONC = "**/*.jsonc";
69
- const GLOB_PACKAGE_JSON = "**/package.json";
70
- const GLOB_HTML = "**/*.htm?(l)";
71
- const GLOB_CSS = "**/*.css";
72
- const GLOB_POSTCSS = "**/*.{p,post}css";
73
- const GLOB_LESS = "**/*.less";
74
- const GLOB_SCSS = "**/*.scss";
75
- const GLOB_GRAPHQL = "**/*.{g,graph}ql";
76
- const GLOB_XML = "**/*.xml";
77
- const GLOB_SVG = "**/*.svg";
78
- const GLOB_VUE = "**/*.vue";
79
- const GLOB_JSON_SRC = [
80
- GLOB_JSON,
81
- GLOB_JSON5,
82
- GLOB_JSONC,
83
- GLOB_PACKAGE_JSON
84
- ];
85
- const GLOB_TS_SRC = [
86
- "**/*.cts",
87
- "**/*.mts",
88
- "**/*.ts",
89
- "**/*.tsx"
90
- ];
91
- const GLOB_JS_SRC = [
92
- "**/*.cjs",
93
- "**/*.mjs",
94
- "**/*.js",
95
- "**/*.jsx"
96
- ];
97
- const GLOB_JSX_SRC = ["**/*.jsx", "**/*.tsx"];
98
- const GLOB_SRC = [...GLOB_TS_SRC, ...GLOB_JS_SRC];
99
- const GLOB_SRC_EXT = GLOB_SRC.map((item) => item.replace("**/*.", ""));
100
- GLOB_SRC_EXT.flatMap((item) => [
101
- `**/__tests__/**/*.${item}`,
102
- `**/*.spec.${item}`,
103
- `**/*.test.${item}`,
104
- `**/*.bench.${item}`,
105
- `**/*.benchmark.${item}`
106
- ]);
107
- const GLOB_EXCLUDE = [
108
- "**/node_modules",
109
- "**/dist",
110
- "**/package-lock.json",
111
- "**/yarn.lock",
112
- "**/pnpm-lock.yaml",
113
- "**/bun.lockb",
114
- "**/output",
115
- "**/coverage",
116
- "**/temp",
117
- "**/.temp",
118
- "**/tmp",
119
- "**/.tmp",
120
- "**/.history",
121
- "**/.vitepress/cache",
122
- "**/.nuxt",
123
- "**/.next",
124
- "**/.svelte-kit",
125
- "**/.vercel",
126
- "**/.changeset",
127
- "**/.idea",
128
- "**/.cache",
129
- "**/.output",
130
- "**/.vite-inspect",
131
- "**/.yarn",
132
- "**/vite.config.*.timestamp-*",
133
- "**/CHANGELOG*.md",
134
- "**/*.min.*",
135
- "**/LICENSE*",
136
- "**/__snapshots__",
137
- "**/auto-import?(s).d.ts",
138
- "**/components.d.ts"
139
- ];
140
- //#endregion
141
- //#region src/utils.ts
142
- const parserPlain = {
143
- meta: { name: "parser-plain" },
144
- parseForESLint: (code) => ({
145
- ast: {
146
- body: [],
147
- comments: [],
148
- loc: {
149
- end: code.length,
150
- start: 0
151
- },
152
- range: [0, code.length],
153
- tokens: [],
154
- type: "Program"
155
- },
156
- scopeManager: null,
157
- services: { isPlain: true },
158
- visitorKeys: { Program: [] }
159
- })
160
- };
161
- const mergeRule = (...rules) => {
162
- let finalLevel;
163
- let finalOptions = {};
164
- for (const rule of rules) {
165
- if (!rule) continue;
166
- if (!Array.isArray(rule)) {
167
- finalLevel = rule;
168
- continue;
169
- }
170
- const [level, options] = rule;
171
- finalLevel = level;
172
- if (options && typeof options === "object") finalOptions = {
173
- ...finalOptions,
174
- ...options
175
- };
176
- }
177
- if (Object.keys(finalOptions).length === 0) return finalLevel;
178
- return [finalLevel, finalOptions];
179
- };
180
- //#endregion
181
- //#region src/configs/react.ts
182
- const ReactRefreshAllowConstantExportPackages = ["vite"];
183
- const RemixPackages = [
184
- "@remix-run/node",
185
- "@remix-run/react",
186
- "@remix-run/serve",
187
- "@remix-run/dev"
188
- ];
189
- const ReactRouterPackages = [
190
- "@react-router/node",
191
- "@react-router/react",
192
- "@react-router/serve",
193
- "@react-router/dev"
194
- ];
195
- const NextJsPackages = ["next"];
196
- const ExpoPackages = ["expo"];
197
- function react(options = {}) {
198
- const { language = "typescript", overrides = {
199
- compiler: {},
200
- core: {},
201
- hooks: {},
202
- refresh: {},
203
- googleTranslate: {}
204
- } } = options;
205
- const config = language === "typescript" ? _eslint_react_eslint_plugin.default.configs["recommended-type-checked"] : _eslint_react_eslint_plugin.default.configs.recommended;
206
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, local_pkg.isPackageExists)(i));
207
- const isUsingRemix = RemixPackages.some((i) => (0, local_pkg.isPackageExists)(i));
208
- const isUsingReactRouter = ReactRouterPackages.some((i) => (0, local_pkg.isPackageExists)(i));
209
- const isUsingNext = NextJsPackages.some((i) => (0, local_pkg.isPackageExists)(i));
210
- const isUsingExpo = ExpoPackages.some((i) => (0, local_pkg.isPackageExists)(i));
211
- return [
212
- {
213
- ...config,
214
- name: `${RULE_PREFIX}/react/core/shared`,
215
- files: GLOB_SRC
216
- },
217
- {
218
- name: `${RULE_PREFIX}/react/core/customize`,
219
- files: GLOB_SRC,
220
- rules: {
221
- "@eslint-react/no-missing-context-display-name": "warn",
222
- "@eslint-react/no-missing-component-display-name": "off",
223
- "@eslint-react/dom-no-hydrate": "error",
224
- "@eslint-react/jsx-no-useless-fragment": ["warn", {
225
- allowEmptyFragment: true,
226
- allowExpressions: true
227
- }],
228
- "@eslint-react/no-unnecessary-use-prefix": "warn",
229
- "@eslint-react/naming-convention-context-name": "warn",
230
- ...language === "typescript" ? { "@eslint-react/no-leaked-conditional-rendering": "warn" } : {},
231
- ...overrides.core
232
- }
233
- },
234
- ...(0, eslint_config.defineConfig)([eslint_plugin_react_hooks.default.configs.flat["recommended-latest"]]).map((item) => ({
235
- ...item,
236
- name: `${RULE_PREFIX}/react/hooks/shared`,
237
- files: GLOB_SRC
238
- })),
239
- {
240
- name: `${RULE_PREFIX}/react/hooks/customize`,
241
- files: GLOB_SRC,
242
- rules: overrides.hooks || {}
243
- },
244
- {
245
- ...eslint_plugin_react_refresh.default.configs.recommended,
246
- name: `${RULE_PREFIX}/react/refresh/shared`,
247
- files: GLOB_JSX_SRC
248
- },
249
- {
250
- name: `${RULE_PREFIX}/react/refresh/customize`,
251
- files: GLOB_JSX_SRC,
252
- rules: {
253
- "react-refresh/only-export-components": mergeRule(["warn", { allowConstantExport: isAllowConstantExport }], ["warn", { allowExportNames: [
254
- ...isUsingNext ? [
255
- "dynamic",
256
- "dynamicParams",
257
- "revalidate",
258
- "fetchCache",
259
- "runtime",
260
- "preferredRegion",
261
- "maxDuration",
262
- "config",
263
- "generateMetadata",
264
- "generateViewport",
265
- "experimental_ppr",
266
- "metadata",
267
- "viewport",
268
- "generateImageMetadata",
269
- "generateSitemaps",
270
- "generateStaticParams"
271
- ] : [],
272
- ...isUsingRemix || isUsingReactRouter ? [
273
- "meta",
274
- "links",
275
- "headers",
276
- "loader",
277
- "action"
278
- ] : [],
279
- ...isUsingExpo ? ["unstable_settings"] : []
280
- ] }]),
281
- ...overrides.refresh
282
- }
283
- },
284
- {
285
- ...eslint_plugin_react_compiler.default.configs.recommended,
286
- name: `${RULE_PREFIX}/react/compiler/shared`,
287
- files: GLOB_SRC
288
- },
289
- {
290
- name: `${RULE_PREFIX}/react/compiler/customize`,
291
- files: GLOB_SRC,
292
- rules: overrides.compiler || {}
293
- },
294
- {
295
- name: `${RULE_PREFIX}/react/google-translate`,
296
- files: GLOB_JSX_SRC,
297
- plugins: { "react-google-translate": eslint_plugin_react_google_translate.default },
298
- rules: {
299
- "react-google-translate/no-conditional-text-nodes-with-siblings": "warn",
300
- "react-google-translate/no-return-text-nodes": "warn",
301
- ...overrides.googleTranslate
302
- }
303
- }
304
- ];
305
- }
306
- //#endregion
307
- //#region src/configs/vue.ts
308
- function vue(options = {}) {
309
- const { overrides = {} } = options;
310
- return (0, eslint_config.defineConfig)({
311
- ..._eslint_js.default.configs.recommended,
312
- name: `${RULE_PREFIX}/vue/shared/javascript`,
313
- files: [GLOB_VUE]
314
- }, typescript_eslint.default.configs.recommended.map((item) => ({
315
- ...item,
316
- name: `${RULE_PREFIX}/vue/shared/typescript/${item.name?.replace("typescript-eslint/", "")}`,
317
- files: [GLOB_VUE]
318
- })), eslint_plugin_vue.default.configs["flat/recommended"].map((item) => ({
319
- ...item,
320
- name: `${RULE_PREFIX}/vue/shared/${item.name?.replace("vue/", "")}`,
321
- files: [GLOB_VUE]
322
- })), {
323
- name: `${RULE_PREFIX}/vue/customize`,
324
- files: [GLOB_VUE],
325
- languageOptions: {
326
- ecmaVersion: "latest",
327
- sourceType: "module",
328
- globals: globals.default.browser,
329
- parserOptions: { parser: typescript_eslint.default.parser }
330
- },
331
- processor: (0, eslint_merge_processors.mergeProcessors)([eslint_plugin_vue.default.processors[".vue"], (0, eslint_processor_vue_blocks.default)({ blocks: {
332
- styles: true,
333
- customBlocks: true,
334
- script: false,
335
- template: false
336
- } })]),
337
- rules: overrides
338
- });
339
- }
340
- //#endregion
341
- //#region src/configs/stylistic.ts
342
- function stylistic(options = {}) {
343
- const { overrides = {} } = options;
344
- const jsxIgnoreNodes = [
345
- "TemplateLiteral *",
346
- "TSUnionType",
347
- "TSIntersectionType",
348
- "TSTypeParameterInstantiation",
349
- "FunctionExpression > .params[decorators.length > 0]",
350
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))"
351
- ];
352
- const nonJsxIgnoreNodes = ["JSXOpeningElement", "JSXClosingElement"];
353
- const basicIndentRuleOptions = {
354
- ArrayExpression: 1,
355
- CallExpression: { arguments: 1 },
356
- flatTernaryExpressions: false,
357
- FunctionDeclaration: {
358
- body: 1,
359
- parameters: 1
360
- },
361
- FunctionExpression: {
362
- body: 1,
363
- parameters: 1
364
- },
365
- ignoreComments: false,
366
- ImportDeclaration: 1,
367
- MemberExpression: 1,
368
- ObjectExpression: 1,
369
- offsetTernaryExpressions: true,
370
- outerIIFEBody: 1,
371
- SwitchCase: 1,
372
- VariableDeclarator: 1
373
- };
374
- return [
375
- {
376
- ..._stylistic_eslint_plugin.default.configs.customize({
377
- arrowParens: true,
378
- semi: true,
379
- braceStyle: "1tbs"
380
- }),
381
- name: `${RULE_PREFIX}/stylistic/shared`,
382
- files: [
383
- ...GLOB_SRC,
384
- ...GLOB_JSON_SRC,
385
- GLOB_VUE
386
- ]
387
- },
388
- {
389
- name: `${RULE_PREFIX}/stylistic/customize`,
390
- files: [
391
- ...GLOB_SRC,
392
- ...GLOB_JSON_SRC,
393
- GLOB_VUE
394
- ],
395
- plugins: {
396
- stylistic: _stylistic_eslint_plugin.default,
397
- antfu: eslint_plugin_antfu.default
398
- },
399
- rules: {
400
- "curly": ["error", "all"],
401
- "object-shorthand": "error",
402
- "prefer-destructuring": [
403
- "error",
404
- {
405
- VariableDeclarator: {
406
- array: false,
407
- object: true
408
- },
409
- AssignmentExpression: {
410
- array: false,
411
- object: false
412
- }
413
- },
414
- { enforceForRenamedProperties: false }
415
- ],
416
- "prefer-template": "error",
417
- "stylistic/array-bracket-newline": ["error", { multiline: true }],
418
- "stylistic/array-element-newline": ["error", "consistent"],
419
- "stylistic/brace-style": [
420
- "error",
421
- "1tbs",
422
- { allowSingleLine: false }
423
- ],
424
- "stylistic/function-call-spacing": ["error", "never"],
425
- "stylistic/function-paren-newline": "off",
426
- "stylistic/indent": [
427
- "error",
428
- 2,
429
- {
430
- ...basicIndentRuleOptions,
431
- ignoredNodes: [...jsxIgnoreNodes, ...nonJsxIgnoreNodes]
432
- }
433
- ],
434
- "stylistic/key-spacing": ["error", {
435
- beforeColon: false,
436
- afterColon: true,
437
- mode: "strict"
438
- }],
439
- "stylistic/keyword-spacing": ["error", {
440
- before: true,
441
- after: true
442
- }],
443
- "stylistic/line-comment-position": "off",
444
- "stylistic/linebreak-style": ["error", "unix"],
445
- "stylistic/lines-around-comment": "off",
446
- "stylistic/new-parens": ["error", "always"],
447
- "stylistic/no-confusing-arrow": ["error", {
448
- allowParens: true,
449
- onlyOneSimpleParam: true
450
- }],
451
- "stylistic/no-extra-semi": "error",
452
- "stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
453
- "stylistic/space-before-function-paren": ["error", {
454
- named: "never",
455
- anonymous: "always",
456
- asyncArrow: "always",
457
- catch: "always"
458
- }],
459
- "stylistic/switch-colon-spacing": ["error", {
460
- after: true,
461
- before: false
462
- }],
463
- "stylistic/type-annotation-spacing": "error",
464
- "stylistic/wrap-regex": "error",
465
- "stylistic/quotes": [
466
- "error",
467
- "single",
468
- {
469
- allowTemplateLiterals: true,
470
- avoidEscape: true
471
- }
472
- ],
473
- "stylistic/no-tabs": "off",
474
- "antfu/consistent-chaining": "error",
475
- "antfu/consistent-list-newline": "error",
476
- "antfu/top-level-function": "off",
477
- "antfu/curly": "off",
478
- ...overrides
479
- }
480
- },
481
- {
482
- name: `${RULE_PREFIX}/stylistic/customize/jsx`,
483
- files: [...GLOB_JSX_SRC, GLOB_VUE],
484
- plugins: { stylistic: _stylistic_eslint_plugin.default },
485
- rules: {
486
- "stylistic/indent": [
487
- "error",
488
- 2,
489
- {
490
- ...basicIndentRuleOptions,
491
- ignoredNodes: jsxIgnoreNodes
492
- }
493
- ],
494
- "stylistic/jsx-closing-bracket-location": ["error", {
495
- nonEmpty: "tag-aligned",
496
- selfClosing: "tag-aligned"
497
- }],
498
- "stylistic/jsx-closing-tag-location": ["error", "tag-aligned"],
499
- "stylistic/jsx-curly-brace-presence": ["error", {
500
- props: "never",
501
- children: "never",
502
- propElementValues: "always"
503
- }],
504
- "stylistic/jsx-curly-newline": ["error", {
505
- singleline: "consistent",
506
- multiline: "consistent"
507
- }],
508
- "stylistic/jsx-curly-spacing": ["error", {
509
- when: "never",
510
- attributes: { when: "never" },
511
- children: { when: "never" }
512
- }],
513
- "stylistic/jsx-first-prop-new-line": ["error", "multiline"],
514
- "stylistic/jsx-one-expression-per-line": ["error", { allow: "non-jsx" }],
515
- "stylistic/jsx-pascal-case": ["error", {
516
- allowAllCaps: false,
517
- allowLeadingUnderscore: false,
518
- allowNamespace: true
519
- }],
520
- "stylistic/jsx-props-no-multi-spaces": "error",
521
- "stylistic/jsx-quotes": ["error", "prefer-double"],
522
- "stylistic/jsx-self-closing-comp": ["error", {
523
- component: true,
524
- html: true
525
- }],
526
- "stylistic/jsx-sort-props": "off",
527
- "stylistic/jsx-indent-props": "off",
528
- ...overrides
529
- }
530
- }
531
- ];
532
- }
533
- //#endregion
534
- //#region src/configs/typescript.ts
535
- function typescript(options = {}) {
536
- const { overrides = {}, typeSafe = false, strict = false } = options;
537
- return [...(0, eslint_config.defineConfig)(typescript_eslint.default.configs.base, typescript_eslint.default.configs.recommendedTypeChecked, typescript_eslint.default.configs.strictTypeChecked, typescript_eslint.default.configs.stylisticTypeChecked).map((item) => ({
538
- ...item,
539
- name: `${RULE_PREFIX}/typescript/shared/${item.name?.replace("typescript-eslint/", "")}`,
540
- files: GLOB_TS_SRC
541
- })), {
542
- name: `${RULE_PREFIX}/typescript/customize`,
543
- files: GLOB_TS_SRC,
544
- languageOptions: {
545
- parserOptions: {
546
- projectService: true,
547
- tsconfigRootDir: node_process.default.cwd()
548
- },
549
- sourceType: "module"
550
- },
551
- rules: {
552
- "@typescript-eslint/consistent-type-imports": ["error", { disallowTypeAnnotations: false }],
553
- "@typescript-eslint/no-import-type-side-effects": "error",
554
- "@typescript-eslint/method-signature-style": ["error", "property"],
555
- "no-unused-expressions": "off",
556
- "@typescript-eslint/no-unused-expressions": ["error", {
557
- allowShortCircuit: true,
558
- allowTernary: true
559
- }],
560
- "@typescript-eslint/no-dynamic-delete": "off",
561
- "@typescript-eslint/no-empty-object-type": ["error", {
562
- allowInterfaces: "with-single-extends",
563
- allowObjectTypes: "never",
564
- allowWithName: "Props$"
565
- }],
566
- "@typescript-eslint/no-non-null-assertion": "off",
567
- "@typescript-eslint/ban-ts-comment": "off",
568
- "@typescript-eslint/no-explicit-any": "off",
569
- "@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
570
- "@typescript-eslint/await-thenable": "error",
571
- "@typescript-eslint/no-floating-promises": "error",
572
- "@typescript-eslint/consistent-type-exports": "error",
573
- "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: {
574
- arguments: false,
575
- attributes: false
576
- } }],
577
- "@typescript-eslint/restrict-template-expressions": ["error", {}],
578
- "@typescript-eslint/no-deprecated": "warn",
579
- "@typescript-eslint/no-empty-function": "off",
580
- "@typescript-eslint/consistent-type-definitions": "off",
581
- "@typescript-eslint/array-type": ["error", { default: "array-simple" }],
582
- "@typescript-eslint/prefer-nullish-coalescing": "off",
583
- "@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }],
584
- ...typeSafe ? {} : {
585
- "@typescript-eslint/no-unsafe-assignment": "off",
586
- "@typescript-eslint/no-unsafe-member-access": "off",
587
- "@typescript-eslint/no-unsafe-call": "off",
588
- "@typescript-eslint/no-unsafe-return": "off",
589
- "@typescript-eslint/no-unsafe-argument": "off"
590
- },
591
- ...strict ? {} : { "@typescript-eslint/no-extraneous-class": "off" },
592
- ...overrides
593
- }
594
- }];
595
- }
596
- //#endregion
597
- //#region src/configs/javascript.ts
598
- function javascript(options = {}) {
599
- const { overrides = {} } = options;
600
- return [{
601
- name: `${RULE_PREFIX}/javascript/shared`,
602
- files: GLOB_SRC,
603
- languageOptions: {
604
- ecmaVersion: 2022,
605
- globals: {
606
- ...globals.default.browser,
607
- ...globals.default.es2021,
608
- ...globals.default.node,
609
- document: "readonly",
610
- navigator: "readonly",
611
- window: "readonly"
612
- },
613
- parserOptions: {
614
- ecmaFeatures: { jsx: true },
615
- ecmaVersion: 2022,
616
- sourceType: "module"
617
- },
618
- sourceType: "module"
619
- },
620
- linterOptions: { reportUnusedDisableDirectives: true },
621
- rules: _eslint_js.default.configs.recommended.rules
622
- }, {
623
- name: `${RULE_PREFIX}/javascript/customize`,
624
- files: GLOB_SRC,
625
- plugins: { antfu: eslint_plugin_antfu.default },
626
- rules: {
627
- "arrow-body-style": ["error", "as-needed"],
628
- "func-style": [
629
- "warn",
630
- "declaration",
631
- { allowArrowFunctions: true }
632
- ],
633
- "no-empty-function": "off",
634
- "prefer-destructuring": "off",
635
- "capitalized-comments": "off",
636
- "id-length": "off",
637
- "accessor-pairs": ["error", {
638
- enforceForClassMembers: true,
639
- setWithoutGet: true
640
- }],
641
- "antfu/no-top-level-await": "error",
642
- "array-callback-return": "error",
643
- "block-scoped-var": "error",
644
- "constructor-super": "error",
645
- "default-case-last": "error",
646
- "dot-notation": ["error", { allowKeywords: true }],
647
- "eqeqeq": ["error", "smart"],
648
- "new-cap": ["error", {
649
- capIsNew: false,
650
- newIsCap: true,
651
- properties: true
652
- }],
653
- "no-alert": "error",
654
- "no-array-constructor": "error",
655
- "no-async-promise-executor": "error",
656
- "no-caller": "error",
657
- "no-case-declarations": "error",
658
- "no-class-assign": "error",
659
- "no-compare-neg-zero": "error",
660
- "no-cond-assign": ["error", "always"],
661
- "no-console": ["error", { allow: [
662
- "warn",
663
- "error",
664
- "info"
665
- ] }],
666
- "no-const-assign": "error",
667
- "no-control-regex": "error",
668
- "no-debugger": "error",
669
- "no-delete-var": "error",
670
- "no-dupe-args": "error",
671
- "no-dupe-class-members": "error",
672
- "no-dupe-keys": "error",
673
- "no-duplicate-case": "error",
674
- "no-empty": ["error", { allowEmptyCatch: true }],
675
- "no-empty-character-class": "error",
676
- "no-empty-pattern": "error",
677
- "no-eval": "error",
678
- "no-ex-assign": "error",
679
- "no-extend-native": "error",
680
- "no-extra-bind": "error",
681
- "no-extra-boolean-cast": "error",
682
- "no-fallthrough": "error",
683
- "no-func-assign": "error",
684
- "no-global-assign": "error",
685
- "no-implied-eval": "error",
686
- "no-import-assign": "error",
687
- "no-invalid-regexp": "error",
688
- "no-irregular-whitespace": "error",
689
- "no-iterator": "error",
690
- "no-labels": ["error", {
691
- allowLoop: false,
692
- allowSwitch: false
693
- }],
694
- "no-lone-blocks": "error",
695
- "no-loss-of-precision": "error",
696
- "no-misleading-character-class": "error",
697
- "no-multi-str": "error",
698
- "no-new": "error",
699
- "no-new-func": "error",
700
- "no-new-native-nonconstructor": "error",
701
- "no-new-wrappers": "error",
702
- "no-obj-calls": "error",
703
- "no-octal": "error",
704
- "no-octal-escape": "error",
705
- "no-param-reassign": "warn",
706
- "no-proto": "error",
707
- "no-prototype-builtins": "error",
708
- "no-redeclare": ["error", { builtinGlobals: false }],
709
- "no-regex-spaces": "error",
710
- "no-restricted-globals": [
711
- "error",
712
- {
713
- message: "Use `globalThis` instead.",
714
- name: "global"
715
- },
716
- {
717
- message: "Use `globalThis` instead.",
718
- name: "self"
719
- }
720
- ],
721
- "no-restricted-properties": [
722
- "error",
723
- {
724
- message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
725
- property: "__proto__"
726
- },
727
- {
728
- message: "Use `Object.defineProperty` instead.",
729
- property: "__defineGetter__"
730
- },
731
- {
732
- message: "Use `Object.defineProperty` instead.",
733
- property: "__defineSetter__"
734
- },
735
- {
736
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
737
- property: "__lookupGetter__"
738
- },
739
- {
740
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
741
- property: "__lookupSetter__"
742
- }
743
- ],
744
- "no-restricted-syntax": [
745
- "error",
746
- "TSEnumDeclaration[const=true]",
747
- "TSExportAssignment"
748
- ],
749
- "no-self-assign": ["error", { props: true }],
750
- "no-self-compare": "error",
751
- "no-sequences": "error",
752
- "no-shadow-restricted-names": "error",
753
- "no-sparse-arrays": "error",
754
- "no-template-curly-in-string": "error",
755
- "no-this-before-super": "error",
756
- "no-throw-literal": "error",
757
- "no-undef": "error",
758
- "no-undef-init": "error",
759
- "no-unexpected-multiline": "error",
760
- "no-unmodified-loop-condition": "error",
761
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
762
- "no-unreachable": "error",
763
- "no-unreachable-loop": "error",
764
- "no-unsafe-finally": "error",
765
- "no-unsafe-negation": "error",
766
- "no-unused-expressions": ["error", {
767
- allowShortCircuit: true,
768
- allowTaggedTemplates: true,
769
- allowTernary: true
770
- }],
771
- "no-unused-vars": ["error", {
772
- args: "none",
773
- caughtErrors: "none",
774
- ignoreRestSiblings: true,
775
- vars: "all"
776
- }],
777
- "no-use-before-define": ["error", {
778
- classes: false,
779
- functions: false,
780
- variables: true
781
- }],
782
- "no-useless-backreference": "error",
783
- "no-useless-call": "error",
784
- "no-useless-catch": "error",
785
- "no-useless-computed-key": "error",
786
- "no-useless-constructor": "error",
787
- "no-useless-rename": "error",
788
- "no-useless-return": "error",
789
- "no-var": "error",
790
- "no-with": "error",
791
- "object-shorthand": [
792
- "error",
793
- "always",
794
- {
795
- avoidQuotes: true,
796
- ignoreConstructors: false
797
- }
798
- ],
799
- "one-var": ["error", { initialized: "never" }],
800
- "prefer-arrow-callback": ["error", {
801
- allowNamedFunctions: false,
802
- allowUnboundThis: true
803
- }],
804
- "prefer-const": ["error", {
805
- destructuring: "all",
806
- ignoreReadBeforeAssign: true
807
- }],
808
- "prefer-exponentiation-operator": "error",
809
- "prefer-promise-reject-errors": "error",
810
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
811
- "prefer-rest-params": "error",
812
- "prefer-spread": "error",
813
- "prefer-template": "error",
814
- "symbol-description": "error",
815
- "unicode-bom": ["error", "never"],
816
- "use-isnan": ["error", {
817
- enforceForIndexOf: true,
818
- enforceForSwitchCase: true
819
- }],
820
- "valid-typeof": ["error", { requireStringLiterals: true }],
821
- "vars-on-top": "error",
822
- "yoda": ["error", "never"],
823
- ...overrides
824
- }
825
- }];
826
- }
827
- //#endregion
828
- //#region src/configs/node.ts
829
- function node(options = {}) {
830
- const { overrides = {} } = options;
831
- return [{
832
- ...eslint_plugin_n.default.configs["flat/recommended"],
833
- name: `${RULE_PREFIX}/node/shared`,
834
- files: GLOB_SRC
835
- }, {
836
- name: `${RULE_PREFIX}/node/customize`,
837
- files: GLOB_SRC,
838
- rules: {
839
- "n/handle-callback-err": ["error", "^(err|error)$"],
840
- "n/no-new-require": "error",
841
- "n/no-path-concat": "error",
842
- "n/prefer-global/buffer": ["error", "never"],
843
- "n/prefer-global/process": ["error", "never"],
844
- "n/no-missing-import": "off",
845
- ...overrides
846
- }
847
- }];
848
- }
849
- //#endregion
850
- //#region src/configs/json.ts
851
- function json(options = {}) {
852
- const { overrides = {
853
- core: {},
854
- packageJson: {}
855
- }, indent = 2, packageJsonRequireType = true } = options;
856
- return [
857
- ...eslint_plugin_jsonc.default.configs["recommended-with-json"].map((item) => ({
858
- ...item,
859
- name: `${RULE_PREFIX}/json/shared/json`,
860
- files: [GLOB_JSON]
861
- })),
862
- ...eslint_plugin_jsonc.default.configs["recommended-with-jsonc"].map((item) => ({
863
- ...item,
864
- name: `${RULE_PREFIX}/json/shared/jsonc`,
865
- files: [GLOB_JSONC]
866
- })),
867
- ...eslint_plugin_jsonc.default.configs["recommended-with-json5"].map((item) => ({
868
- ...item,
869
- name: `${RULE_PREFIX}/json/shared/json5`,
870
- files: [GLOB_JSON5]
871
- })),
872
- {
873
- name: `${RULE_PREFIX}/json/customize`,
874
- files: [
875
- GLOB_JSON,
876
- GLOB_JSON5,
877
- GLOB_JSONC
878
- ],
879
- rules: {
880
- "jsonc/array-bracket-spacing": ["error", "never"],
881
- "jsonc/comma-dangle": ["error", "never"],
882
- "jsonc/comma-style": ["error", "last"],
883
- "jsonc/indent": ["error", indent],
884
- "jsonc/no-comments": "off",
885
- "jsonc/key-spacing": ["error", {
886
- afterColon: true,
887
- beforeColon: false
888
- }],
889
- "jsonc/object-curly-newline": ["error", {
890
- consistent: true,
891
- multiline: true
892
- }],
893
- "jsonc/object-curly-spacing": ["error", "always"],
894
- "jsonc/quote-props": "error",
895
- "jsonc/quotes": "error",
896
- "jsonc/no-bigint-literals": "error",
897
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
898
- "jsonc/no-binary-expression": "error",
899
- "jsonc/no-binary-numeric-literals": "error",
900
- "jsonc/no-dupe-keys": "error",
901
- "jsonc/no-escape-sequence-in-identifier": "error",
902
- "jsonc/no-floating-decimal": "error",
903
- "jsonc/no-hexadecimal-numeric-literals": "error",
904
- "jsonc/no-infinity": "error",
905
- "jsonc/no-multi-str": "error",
906
- "jsonc/no-nan": "error",
907
- "jsonc/no-number-props": "error",
908
- "jsonc/no-numeric-separators": "error",
909
- "jsonc/no-octal": "error",
910
- "jsonc/no-octal-escape": "error",
911
- "jsonc/no-octal-numeric-literals": "error",
912
- "jsonc/no-parenthesized": "error",
913
- "jsonc/no-plus-sign": "error",
914
- "jsonc/no-regexp-literals": "error",
915
- "jsonc/no-sparse-arrays": "error",
916
- "jsonc/no-template-literals": "error",
917
- "jsonc/no-undefined-value": "error",
918
- "jsonc/no-unicode-codepoint-escapes": "error",
919
- "jsonc/no-useless-escape": "error",
920
- "jsonc/space-unary-ops": "error",
921
- "jsonc/valid-json-number": "error",
922
- "jsonc/vue-custom-block/no-parsing-error": "error",
923
- ...overrides.core
924
- }
925
- },
926
- {
927
- ...eslint_plugin_package_json.default.configs.recommended,
928
- name: `${RULE_PREFIX}/json/shared/package.json`,
929
- files: [GLOB_PACKAGE_JSON]
930
- },
931
- {
932
- name: `${RULE_PREFIX}/json/customize/package.json`,
933
- files: [GLOB_PACKAGE_JSON],
934
- rules: {
935
- "package-json/order-properties": ["error", { order: [
936
- "publisher",
937
- "name",
938
- "displayName",
939
- "type",
940
- "version",
941
- "private",
942
- "packageManager",
943
- "description",
944
- "author",
945
- "contributors",
946
- "license",
947
- "funding",
948
- "homepage",
949
- "repository",
950
- "bugs",
951
- "keywords",
952
- "categories",
953
- "sideEffects",
954
- "exports",
955
- "main",
956
- "module",
957
- "unpkg",
958
- "jsdelivr",
959
- "types",
960
- "typesVersions",
961
- "bin",
962
- "icon",
963
- "files",
964
- "engines",
965
- "activationEvents",
966
- "contributes",
967
- "scripts",
968
- "release-it",
969
- "peerDependencies",
970
- "peerDependenciesMeta",
971
- "dependencies",
972
- "optionalDependencies",
973
- "devDependencies",
974
- "pnpm",
975
- "overrides",
976
- "resolutions",
977
- "husky",
978
- "simple-git-hooks",
979
- "lint-staged",
980
- "eslintConfig"
981
- ] }],
982
- "package-json/require-type": packageJsonRequireType ? "error" : "off",
983
- ...overrides.packageJson
984
- }
985
- }
986
- ];
987
- }
988
- //#endregion
989
- //#region src/configs/unicorn.ts
990
- function unicorn(options = {}) {
991
- const { overrides = {} } = options;
992
- return [{
993
- ...eslint_plugin_unicorn.default.configs.recommended,
994
- name: `${RULE_PREFIX}/unicorn/shared`,
995
- files: GLOB_SRC
996
- }, {
997
- name: `${RULE_PREFIX}/unicorn/customize`,
998
- files: GLOB_SRC,
999
- rules: {
1000
- "unicorn/consistent-destructuring": "off",
1001
- "unicorn/prevent-abbreviations": "off",
1002
- "unicorn/prefer-top-level-await": "off",
1003
- "unicorn/no-unreadable-array-destructuring": "off",
1004
- "unicorn/no-null": "off",
1005
- "unicorn/consistent-empty-array-spread": "error",
1006
- "unicorn/error-message": "error",
1007
- "unicorn/escape-case": "error",
1008
- "unicorn/no-hex-escape": "error",
1009
- "unicorn/new-for-builtins": "error",
1010
- "unicorn/no-instanceof-builtins": "error",
1011
- "unicorn/no-new-array": "error",
1012
- "unicorn/no-new-buffer": "error",
1013
- "unicorn/number-literal-case": "error",
1014
- "unicorn/prefer-dom-node-text-content": "error",
1015
- "unicorn/prefer-includes": "error",
1016
- "unicorn/prefer-node-protocol": "error",
1017
- "unicorn/prefer-query-selector": "off",
1018
- "unicorn/prefer-number-properties": "error",
1019
- "unicorn/prefer-string-starts-ends-with": "error",
1020
- "unicorn/prefer-type-error": "error",
1021
- "unicorn/throw-new-error": "error",
1022
- ...overrides
1023
- }
1024
- }];
1025
- }
1026
- //#endregion
1027
- //#region src/configs/imports.ts
1028
- function imports(options = {}) {
1029
- const { overrides = {}, closeOrder = true } = options;
1030
- return [{
1031
- name: `${RULE_PREFIX}/imports/customize`,
1032
- files: GLOB_SRC,
1033
- plugins: {
1034
- "antfu": eslint_plugin_antfu.default,
1035
- "import-x": eslint_plugin_import_x.default,
1036
- "unused-imports": eslint_plugin_unused_imports.default,
1037
- "simple-import-sort": eslint_plugin_simple_import_sort.default
1038
- },
1039
- rules: {
1040
- "sort-imports": "off",
1041
- "no-unused-vars": "off",
1042
- "no-duplicate-imports": "off",
1043
- "@typescript-eslint/no-unused-vars": "off",
1044
- "antfu/import-dedupe": "error",
1045
- "antfu/no-import-dist": "error",
1046
- "antfu/no-import-node-modules-by-path": "error",
1047
- "import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
1048
- "import-x/first": "error",
1049
- "import-x/no-duplicates": "error",
1050
- "import-x/no-mutable-exports": "error",
1051
- "import-x/no-named-default": "error",
1052
- "import-x/no-self-import": "error",
1053
- "import-x/no-webpack-loader-syntax": "error",
1054
- "import-x/order": "off",
1055
- "import-x/newline-after-import": ["error", { count: 1 }],
1056
- "unused-imports/no-unused-imports": "warn",
1057
- "unused-imports/no-unused-vars": ["error", {
1058
- args: "after-used",
1059
- argsIgnorePattern: "^_",
1060
- ignoreRestSiblings: true,
1061
- vars: "all",
1062
- varsIgnorePattern: "^_"
1063
- }],
1064
- "simple-import-sort/imports": closeOrder ? "off" : "error",
1065
- "simple-import-sort/exports": closeOrder ? "off" : "error",
1066
- ...overrides
1067
- }
1068
- }];
1069
- }
1070
- //#endregion
1071
- //#region src/configs/format.ts
1072
- const mergePrettierOptions = (options, overrides) => ({
1073
- ...options,
1074
- ...overrides,
1075
- plugins: [...overrides.plugins || []]
1076
- });
1077
- function format(options = {}) {
1078
- const { enable = {
1079
- html: true,
1080
- css: true,
1081
- graphql: true,
1082
- xml: true,
1083
- svg: true
1084
- }, customPrettierOptions = {} } = options;
1085
- const configs = [];
1086
- if (!enable) return configs;
1087
- const prettierOptions = Object.assign({
1088
- printWidth: 120,
1089
- tabWidth: 2,
1090
- semi: true,
1091
- singleQuote: true,
1092
- quoteProps: "consistent",
1093
- jsxSingleQuote: false,
1094
- trailingComma: "all",
1095
- bracketSpacing: true,
1096
- bracketSameLine: false,
1097
- arrowParens: "always",
1098
- useTabs: false,
1099
- endOfLine: "lf",
1100
- singleAttributePerLine: false
1101
- }, customPrettierOptions);
1102
- const prettierXmlOptions = {
1103
- xmlQuoteAttributes: "double",
1104
- xmlSelfClosingSpace: true,
1105
- xmlSortAttributesByKey: false,
1106
- xmlWhitespaceSensitivity: "ignore"
1107
- };
1108
- configs.push({
1109
- name: `${RULE_PREFIX}/format`,
1110
- plugins: { format: eslint_plugin_format.default }
1111
- });
1112
- if (enable.html) configs.push({
1113
- name: `${RULE_PREFIX}/format/html`,
1114
- files: [GLOB_HTML],
1115
- languageOptions: { parser: parserPlain },
1116
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
1117
- });
1118
- if (enable.css) configs.push({
1119
- name: `${RULE_PREFIX}/format/css`,
1120
- files: [GLOB_CSS, GLOB_POSTCSS],
1121
- languageOptions: { parser: parserPlain },
1122
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "css" })] }
1123
- }, {
1124
- name: `${RULE_PREFIX}/format/scss`,
1125
- files: [GLOB_SCSS],
1126
- languageOptions: { parser: parserPlain },
1127
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "scss" })] }
1128
- }, {
1129
- name: `${RULE_PREFIX}/format/less`,
1130
- files: [GLOB_LESS],
1131
- languageOptions: { parser: parserPlain },
1132
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
1133
- });
1134
- if (enable.graphql) configs.push({
1135
- name: `${RULE_PREFIX}/format/graphql`,
1136
- files: [GLOB_GRAPHQL],
1137
- languageOptions: { parser: parserPlain },
1138
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
1139
- });
1140
- if (enable.xml) configs.push({
1141
- name: `${RULE_PREFIX}/format/xml`,
1142
- files: [GLOB_XML],
1143
- languageOptions: { parser: parserPlain },
1144
- rules: { "format/prettier": ["error", mergePrettierOptions({
1145
- ...prettierXmlOptions,
1146
- ...prettierOptions
1147
- }, {
1148
- parser: "xml",
1149
- plugins: ["@prettier/plugin-xml"]
1150
- })] }
1151
- });
1152
- if (enable.svg) configs.push({
1153
- name: `${RULE_PREFIX}/format/svg`,
1154
- files: [GLOB_SVG],
1155
- languageOptions: { parser: parserPlain },
1156
- rules: { "format/prettier": ["error", mergePrettierOptions({
1157
- ...prettierXmlOptions,
1158
- ...prettierOptions
1159
- }, {
1160
- parser: "xml",
1161
- plugins: ["@prettier/plugin-xml"]
1162
- })] }
1163
- });
1164
- return configs;
1165
- }
1166
- //#endregion
1167
- //#region src/configs/tailwindcss.ts
1168
- function tailwindcss(options = {}) {
1169
- const { overrides = {} } = options;
1170
- return (0, local_pkg.isPackageExists)("tailwindcss") ? [...eslint_plugin_tailwindcss.default.configs["flat/recommended"].map((item) => ({
1171
- ...item,
1172
- name: `${RULE_PREFIX}/tailwindcss/shared/${item.name?.replace("tailwindcss:", "")}`,
1173
- files: GLOB_SRC
1174
- })), {
1175
- name: `${RULE_PREFIX}/tailwindcss/customize`,
1176
- files: GLOB_SRC,
1177
- rules: {
1178
- "tailwindcss/no-custom-classname": "off",
1179
- ...overrides
1180
- }
1181
- }] : [];
1182
- }
1183
- //#endregion
1184
- //#region src/configs/unocss.ts
1185
- function unocss(options = {}) {
1186
- const { overrides = {} } = options;
1187
- if (!(0, local_pkg.isPackageExists)("unocss")) return [];
1188
- return [{
1189
- ..._unocss_eslint_config_flat.default,
1190
- name: `${RULE_PREFIX}/unocss/shared`,
1191
- files: GLOB_SRC
1192
- }, {
1193
- name: `${RULE_PREFIX}/unocss/customize`,
1194
- files: GLOB_SRC,
1195
- rules: overrides
1196
- }];
1197
- }
1198
- //#endregion
1199
- //#region src/configs/yml.ts
1200
- function yml(options = {}) {
1201
- const { overrides = {}, indent = 2, quotes = "single" } = options;
1202
- return [
1203
- ...eslint_plugin_yml.default.configs.recommended.map((item) => ({
1204
- ...item,
1205
- name: `${RULE_PREFIX}/yml/shared`,
1206
- files: [GLOB_YML]
1207
- })),
1208
- {
1209
- name: `${RULE_PREFIX}/yml/customize`,
1210
- files: [GLOB_YML],
1211
- rules: {
1212
- "yml/block-mapping": "error",
1213
- "yml/block-sequence": "error",
1214
- "yml/no-empty-key": "error",
1215
- "yml/no-empty-sequence-entry": "error",
1216
- "yml/no-irregular-whitespace": "error",
1217
- "yml/plain-scalar": "error",
1218
- "yml/block-mapping-question-indicator-newline": "error",
1219
- "yml/block-sequence-hyphen-indicator-newline": "error",
1220
- "yml/flow-mapping-curly-newline": "error",
1221
- "yml/flow-mapping-curly-spacing": "error",
1222
- "yml/flow-sequence-bracket-newline": "error",
1223
- "yml/flow-sequence-bracket-spacing": "error",
1224
- "yml/indent": ["error", indent],
1225
- "yml/key-spacing": "error",
1226
- "yml/no-tab-indent": "error",
1227
- "yml/quotes": ["error", {
1228
- avoidEscape: true,
1229
- prefer: quotes
1230
- }],
1231
- "yml/spaced-comment": "error",
1232
- ...overrides
1233
- }
1234
- },
1235
- {
1236
- name: `${RULE_PREFIX}/yml/customize/pnpm-workspace.yaml`,
1237
- files: ["pnpm-workspace.yaml"],
1238
- rules: { "yml/sort-keys": [
1239
- "error",
1240
- {
1241
- order: [
1242
- "packages",
1243
- "overrides",
1244
- "patchedDependencies",
1245
- "hoistPattern",
1246
- "catalog",
1247
- "catalogs",
1248
- "allowedDeprecatedVersions",
1249
- "allowNonAppliedPatches",
1250
- "configDependencies",
1251
- "ignoredBuiltDependencies",
1252
- "ignoredOptionalDependencies",
1253
- "neverBuiltDependencies",
1254
- "onlyBuiltDependencies",
1255
- "onlyBuiltDependenciesFile",
1256
- "packageExtensions",
1257
- "peerDependencyRules",
1258
- "supportedArchitectures"
1259
- ],
1260
- pathPattern: "^$"
1261
- },
1262
- {
1263
- order: { type: "asc" },
1264
- pathPattern: ".*"
1265
- }
1266
- ] }
1267
- }
1268
- ];
1269
- }
1270
- //#endregion
1271
- //#region src/configs/toml.ts
1272
- function toml(options = {}) {
1273
- const { overrides = {}, indent = 2 } = options;
1274
- return [...eslint_plugin_toml.default.configs.recommended.map((item) => ({
1275
- ...item,
1276
- name: `${RULE_PREFIX}/toml/shared`,
1277
- files: [GLOB_TOML]
1278
- })), {
1279
- name: `${RULE_PREFIX}/toml/customize`,
1280
- files: [GLOB_TOML],
1281
- languageOptions: { parser: toml_eslint_parser },
1282
- rules: {
1283
- "toml/comma-style": "error",
1284
- "toml/keys-order": "error",
1285
- "toml/no-space-dots": "error",
1286
- "toml/no-unreadable-number-separator": "error",
1287
- "toml/precision-of-fractional-seconds": "error",
1288
- "toml/precision-of-integer": "error",
1289
- "toml/tables-order": "error",
1290
- "toml/array-bracket-newline": "error",
1291
- "toml/array-bracket-spacing": "error",
1292
- "toml/array-element-newline": "error",
1293
- "toml/indent": ["error", indent],
1294
- "toml/inline-table-curly-spacing": "error",
1295
- "toml/key-spacing": "error",
1296
- "toml/padding-line-between-pairs": "error",
1297
- "toml/padding-line-between-tables": "error",
1298
- "toml/quoted-keys": "error",
1299
- "toml/spaced-comment": "error",
1300
- "toml/table-bracket-spacing": "error",
1301
- ...overrides
1302
- }
1303
- }];
1304
- }
1305
- //#endregion
1306
- //#region src/configs/regexp.ts
1307
- function regexp(options = {}) {
1308
- const { overrides = {} } = options;
1309
- return [{
1310
- ...eslint_plugin_regexp.configs.recommended,
1311
- name: `${RULE_PREFIX}/regexp/shared`,
1312
- files: GLOB_SRC
1313
- }, {
1314
- name: `${RULE_PREFIX}/regexp/customize`,
1315
- files: GLOB_SRC,
1316
- rules: overrides
1317
- }];
1318
- }
1319
- //#endregion
1320
- //#region src/configs/ignores.ts
1321
- function ignores(ignorePatterns) {
1322
- return [{
1323
- name: `${RULE_PREFIX}/ignores`,
1324
- ignores: [...GLOB_EXCLUDE, ...ignorePatterns]
1325
- }];
1326
- }
1327
- //#endregion
1328
- //#region src/configs/eslint-comments.ts
1329
- function eslintComments(options = {}) {
1330
- const { overrides = {} } = options;
1331
- return [{
1332
- ..._eslint_community_eslint_plugin_eslint_comments_configs.default.recommended,
1333
- name: `${RULE_PREFIX}/eslint-comments/shared`
1334
- }, {
1335
- name: `${RULE_PREFIX}/eslint-comments/customize`,
1336
- rules: overrides
1337
- }];
1338
- }
1339
- //#endregion
1340
- //#region src/configs/disables.ts
1341
- function disables(options = {}) {
1342
- const { overrides = {
1343
- scripts: {},
1344
- cli: {},
1345
- bin: {},
1346
- dts: {},
1347
- cjs: {},
1348
- config: {}
1349
- } } = options;
1350
- return [
1351
- {
1352
- name: `${RULE_PREFIX}/disables/scripts`,
1353
- files: GLOB_SRC.map((item) => `**/scripts/${item}`),
1354
- rules: {
1355
- "antfu/no-top-level-await": "off",
1356
- "no-console": "off",
1357
- "@typescript-eslint/explicit-function-return-type": "off",
1358
- ...overrides.scripts
1359
- }
1360
- },
1361
- {
1362
- name: `${RULE_PREFIX}/disables/cli`,
1363
- files: [...GLOB_SRC.map((item) => `**/cli/${item}`), ...GLOB_SRC_EXT.map((item) => `**/cli.${item}`)],
1364
- rules: {
1365
- "antfu/no-top-level-await": "off",
1366
- "no-console": "off",
1367
- ...overrides.cli
1368
- }
1369
- },
1370
- {
1371
- name: `${RULE_PREFIX}/disables/bin`,
1372
- files: ["**/bin/**/*", ...GLOB_SRC_EXT.map((item) => `**/bin.${item}`)],
1373
- rules: {
1374
- "antfu/no-import-dist": "off",
1375
- "antfu/no-import-node-modules-by-path": "off",
1376
- ...overrides.bin
1377
- }
1378
- },
1379
- {
1380
- name: `${RULE_PREFIX}/disables/dts`,
1381
- files: ["**/*.d.?([cm])ts"],
1382
- rules: {
1383
- "eslint-comments/no-unlimited-disable": "off",
1384
- "import/no-duplicates": "off",
1385
- "no-restricted-syntax": "off",
1386
- "unused-imports/no-unused-vars": "off",
1387
- ...overrides.dts
1388
- }
1389
- },
1390
- {
1391
- name: `${RULE_PREFIX}/disables/cjs`,
1392
- files: ["**/*.js", "**/*.cjs"],
1393
- rules: {
1394
- "ts/no-require-imports": "off",
1395
- ...overrides.cjs
1396
- }
1397
- },
1398
- {
1399
- name: `${RULE_PREFIX}/disables/config`,
1400
- files: [...GLOB_SRC_EXT.map((item) => `**/*.config.${item}`), ...GLOB_SRC_EXT.map((item) => `**/*.config.*.${item}`)],
1401
- rules: {
1402
- "antfu/no-top-level-await": "off",
1403
- "no-console": "off",
1404
- "ts/explicit-function-return-type": "off",
1405
- ...overrides.config
1406
- }
1407
- }
1408
- ];
1409
- }
1410
- //#endregion
1411
- //#region src/configs/language-options.ts
1412
- function languageOptions(options = {}) {
1413
- const { sourceType = "module" } = options;
1414
- return [{
1415
- name: `${RULE_PREFIX}/language-options`,
1416
- files: GLOB_SRC,
1417
- languageOptions: { sourceType }
1418
- }];
1419
- }
1420
- //#endregion
1421
- //#region src/index.ts
1422
- function defineConfig(options = {}) {
1423
- const { configs = {}, ignorePatterns = [], sourceType = "module" } = options;
1424
- return [
1425
- ...react(configs.react),
1426
- ...vue(configs.vue),
1427
- ...stylistic(configs.stylistic),
1428
- ...typescript(configs.typescript),
1429
- ...javascript(configs.javascript),
1430
- ...node(configs.node),
1431
- ...json(configs.json),
1432
- ...unicorn(configs.unicorn),
1433
- ...imports(configs.imports),
1434
- ...format(configs.format),
1435
- ...tailwindcss(configs.tailwindcss),
1436
- ...unocss(configs.unocss),
1437
- ...yml(configs.yml),
1438
- ...toml(configs.toml),
1439
- ...regexp(configs.regexp),
1440
- ...ignores(ignorePatterns),
1441
- ...eslintComments(configs.eslintComments),
1442
- ...disables(configs.disables),
1443
- ...languageOptions({ sourceType })
1444
- ];
1445
- }
1446
- //#endregion
1447
- exports.defineConfig = defineConfig;