@hexadrop/eslint-config 0.1.18 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.mts +14007 -0
  2. package/dist/index.mjs +1689 -0
  3. package/package.json +37 -38
package/dist/index.mjs ADDED
@@ -0,0 +1,1689 @@
1
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
2
+ import globals from "globals";
3
+ import "eslint";
4
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
5
+ import { meta, parseForESLint } from "eslint-parser-plain";
6
+ import fs, { existsSync } from "node:fs";
7
+ import process, { cwd } from "node:process";
8
+ import { isPackageExists } from "local-pkg";
9
+ import path from "node:path";
10
+ //#region src/utils/combine.ts
11
+ /**
12
+ * Combine array and non-array configs into a single array.
13
+ */
14
+ async function combine(...configs) {
15
+ return (await Promise.all(configs.map((config) => Promise.resolve(config)))).flat();
16
+ }
17
+ //#endregion
18
+ //#region src/utils/extract-typed-flat-config-item.ts
19
+ const flatConfigProperties = [
20
+ "name",
21
+ "files",
22
+ "ignores",
23
+ "languageOptions",
24
+ "linterOptions",
25
+ "processor",
26
+ "plugins",
27
+ "rules",
28
+ "settings"
29
+ ];
30
+ function extractTypedFlatConfigItem(config) {
31
+ if (!config) return;
32
+ const result = {};
33
+ for (const key of flatConfigProperties) if (Object.hasOwn(config, key)) result[key] = config[key];
34
+ if (Object.keys(result).length === 0) return;
35
+ return result;
36
+ }
37
+ //#endregion
38
+ //#region src/utils/interop-default.ts
39
+ async function interopDefault(m) {
40
+ const resolved = await m;
41
+ return resolved.default ?? resolved;
42
+ }
43
+ //#endregion
44
+ //#region src/utils/rename-rules.ts
45
+ /**
46
+ * Rename plugin prefixes in a rule object.
47
+ * Accepts a map of prefixes to rename.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * import { renameRules } from '@hexadrop/eslint-config'
52
+ *
53
+ * export default [{
54
+ * rules: renameRules(
55
+ * {
56
+ * '@typescript-eslint/indent': 'error'
57
+ * },
58
+ * { '@typescript-eslint': 'ts' }
59
+ * )
60
+ * }]
61
+ * ```
62
+ */
63
+ function renameRules(rules, map) {
64
+ if (Object.keys(map).length === 0) return rules;
65
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
66
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
67
+ return [key, value];
68
+ }));
69
+ }
70
+ //#endregion
71
+ //#region src/utils/plugin-config-override-rules.ts
72
+ function pluginConfigOverrideRules(plugin, configName, indexOrMap, map2) {
73
+ let index = 0;
74
+ let map = {};
75
+ if (typeof indexOrMap === "number") index = indexOrMap;
76
+ if (typeof indexOrMap === "object") map = indexOrMap;
77
+ else if (typeof map2 === "object") map = map2;
78
+ let rules = {};
79
+ if (plugin.configs && Object.hasOwn(plugin.configs, configName)) {
80
+ const config = plugin.configs[configName];
81
+ if (config && "overrides" in config) {
82
+ const overrides = config.overrides;
83
+ const indexOverride = overrides ? overrides[index] : void 0;
84
+ if (indexOverride?.rules) rules = indexOverride.rules;
85
+ }
86
+ }
87
+ return renameRules(rules, map);
88
+ }
89
+ //#endregion
90
+ //#region src/utils/plugin-config-rules.ts
91
+ function pluginConfigRules(plugin, configName, map = {}) {
92
+ let rules = {};
93
+ if (plugin.configs && Object.hasOwn(plugin.configs, configName)) {
94
+ const config = plugin.configs[configName];
95
+ if (config && "rules" in config && config.rules) rules = config.rules;
96
+ }
97
+ return renameRules(rules, map);
98
+ }
99
+ //#endregion
100
+ //#region src/utils/to-array.ts
101
+ function toArray(value) {
102
+ return Array.isArray(value) ? value : [value];
103
+ }
104
+ //#endregion
105
+ //#region src/const/plugin-prefix.ts
106
+ const PLUGIN_PREFIX = "hexadrop";
107
+ //#endregion
108
+ //#region src/const/plugin-rename-typescript.ts
109
+ const PLUGIN_RENAME_TYPESCRIPT = { "@typescript-eslint": "typescript" };
110
+ //#endregion
111
+ //#region src/const/plugin-rename.ts
112
+ const PLUGIN_RENAME = {
113
+ ...PLUGIN_RENAME_TYPESCRIPT,
114
+ "@stylistic": "style",
115
+ "import-x": "import",
116
+ jsonc: "json",
117
+ n: "node",
118
+ "simple-import-sort": "import-sort",
119
+ "unused-imports": "import-unused",
120
+ vitest: "test",
121
+ yml: "yaml"
122
+ };
123
+ //#endregion
124
+ //#region src/config/astro/astro.config-name.ts
125
+ const ASTRO_CONFIG_NAME = `${PLUGIN_PREFIX}/astro`;
126
+ const ASTRO_CONFIG_NAME_SETUP = `${ASTRO_CONFIG_NAME}/setup`;
127
+ const ASTRO_CONFIG_NAME_SETUP_PARSER = `${ASTRO_CONFIG_NAME_SETUP}/parser`;
128
+ const ASTRO_CONFIG_NAME_SETUP_PARSER_JAVASCRIPT = `${ASTRO_CONFIG_NAME_SETUP_PARSER}/javascript`;
129
+ `${ASTRO_CONFIG_NAME_SETUP_PARSER}`;
130
+ const ASTRO_CONFIG_NAME_RULES = `${ASTRO_CONFIG_NAME}/rules`;
131
+ //#endregion
132
+ //#region src/config/astro/astro.globs.ts
133
+ const GLOB_ASTRO = ["*.astro", "**/*.astro"];
134
+ const GLOB_ASTRO_JAVASCRIPT = ["**/*.astro/*.js", "*.astro/*.js"];
135
+ const GLOB_ASTRO_TYPESCRIPT = ["**/*.astro/*.ts", "*.astro/*.ts"];
136
+ //#endregion
137
+ //#region src/config/astro/astro.config.ts
138
+ async function astro(options) {
139
+ const { astro, typescript } = options;
140
+ if (!astro) return [];
141
+ const [plugin, parser, parserTypescript] = await Promise.all([
142
+ interopDefault(import("eslint-plugin-astro")),
143
+ interopDefault(import("astro-eslint-parser")),
144
+ interopDefault(import("@typescript-eslint/parser"))
145
+ ]);
146
+ const configs = [
147
+ {
148
+ name: ASTRO_CONFIG_NAME_SETUP,
149
+ plugins: { astro: plugin }
150
+ },
151
+ {
152
+ files: GLOB_ASTRO,
153
+ languageOptions: {
154
+ globals: {
155
+ ...globals.node,
156
+ Astro: false,
157
+ Fragment: false
158
+ },
159
+ parser,
160
+ parserOptions: {
161
+ extraFileExtensions: [".astro"],
162
+ parser: typescript ? parserTypescript : void 0
163
+ },
164
+ sourceType: "module"
165
+ },
166
+ name: ASTRO_CONFIG_NAME_SETUP_PARSER,
167
+ processor: typescript ? "astro/client-side-ts" : "astro/astro"
168
+ },
169
+ {
170
+ files: GLOB_ASTRO_JAVASCRIPT,
171
+ languageOptions: {
172
+ globals: { ...globals.browser },
173
+ sourceType: "module"
174
+ },
175
+ name: ASTRO_CONFIG_NAME_SETUP_PARSER_JAVASCRIPT
176
+ }
177
+ ];
178
+ if (typescript) configs.push({
179
+ files: GLOB_ASTRO_TYPESCRIPT,
180
+ languageOptions: {
181
+ globals: { ...globals.browser },
182
+ parser: parserTypescript,
183
+ parserOptions: { project: typescript === true ? void 0 : toArray(typescript) },
184
+ sourceType: "module"
185
+ },
186
+ name: ASTRO_CONFIG_NAME_SETUP_PARSER_JAVASCRIPT
187
+ });
188
+ configs.push({
189
+ files: GLOB_ASTRO,
190
+ name: ASTRO_CONFIG_NAME_RULES,
191
+ rules: {
192
+ "astro/missing-client-only-directive-value": "error",
193
+ "astro/no-conflict-set-directives": "error",
194
+ "astro/no-deprecated-astro-canonicalurl": "error",
195
+ "astro/no-deprecated-astro-fetchcontent": "error",
196
+ "astro/no-deprecated-astro-resolve": "error",
197
+ "astro/no-deprecated-getentrybyslug": "error",
198
+ "astro/no-unused-define-vars-in-style": "error",
199
+ "astro/valid-compile": "error",
200
+ "no-useless-assignment": "off"
201
+ }
202
+ });
203
+ return configs;
204
+ }
205
+ //#endregion
206
+ //#region src/config/markdown/markdown.config-name.ts
207
+ const MARKDOWN_CONFIG_NAME_SETUP = `${`${PLUGIN_PREFIX}/markdown`}/setup`;
208
+ const MARKDOWN_CONFIG_NAME_SETUP_PROCESSOR = `${MARKDOWN_CONFIG_NAME_SETUP}/processor`;
209
+ const MARKDOWN_CONFIG_NAME_SETUP_PARSER = `${MARKDOWN_CONFIG_NAME_SETUP}/parser`;
210
+ //#endregion
211
+ //#region src/config/core/core.globs.ts
212
+ const SOURCE_GLOBS = ["**/*.?([cm])[jt]s?(x)"];
213
+ const JAVASCRIPT_GLOBS = ["**/*.?([cm])js?(x)"];
214
+ const ESLINT_CONFIG_GLOBS = ["**/eslint.config.js"];
215
+ //#endregion
216
+ //#region src/config/json/json.config-name.ts
217
+ const JSON_CONFIG_NAME = `${PLUGIN_PREFIX}/json`;
218
+ const JSON_CONFIG_NAME_SETUP = `${JSON_CONFIG_NAME}/setup`;
219
+ const JSON_CONFIG_NAME_SETUP_PARSER = `${JSON_CONFIG_NAME_SETUP}/parser`;
220
+ const JSON_CONFIG_NAME_RULES = `${JSON_CONFIG_NAME}/rules`;
221
+ //#endregion
222
+ //#region src/config/json/json.globs.ts
223
+ const GLOB_JSON = [
224
+ "**/*.json",
225
+ "**/*.json5",
226
+ "**/*.jsonc"
227
+ ];
228
+ const GLOB_JSON_PACKAGE = ["**/package.json"];
229
+ const GLOB_JSON_TSCONFIG = ["**/tsconfig.json", "**/tsconfig.*.json"];
230
+ //#endregion
231
+ //#region src/config/json/json.config.ts
232
+ async function json(options) {
233
+ const { json } = options;
234
+ if (!json) return [];
235
+ const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
236
+ const jsonPluginRename = PLUGIN_RENAME.jsonc;
237
+ return [
238
+ {
239
+ name: JSON_CONFIG_NAME_SETUP,
240
+ plugins: { [jsonPluginRename]: pluginJsonc }
241
+ },
242
+ {
243
+ files: GLOB_JSON,
244
+ languageOptions: { parser: parserJsonc },
245
+ name: JSON_CONFIG_NAME_SETUP_PARSER
246
+ },
247
+ {
248
+ files: GLOB_JSON,
249
+ name: JSON_CONFIG_NAME_RULES,
250
+ rules: {
251
+ [`${jsonPluginRename}/no-bigint-literals`]: "error",
252
+ [`${jsonPluginRename}/no-binary-expression`]: "error",
253
+ [`${jsonPluginRename}/no-binary-numeric-literals`]: "error",
254
+ [`${jsonPluginRename}/no-dupe-keys`]: "error",
255
+ [`${jsonPluginRename}/no-escape-sequence-in-identifier`]: "error",
256
+ [`${jsonPluginRename}/no-floating-decimal`]: "error",
257
+ [`${jsonPluginRename}/no-hexadecimal-numeric-literals`]: "error",
258
+ [`${jsonPluginRename}/no-infinity`]: "error",
259
+ [`${jsonPluginRename}/no-multi-str`]: "error",
260
+ [`${jsonPluginRename}/no-nan`]: "error",
261
+ [`${jsonPluginRename}/no-number-props`]: "error",
262
+ [`${jsonPluginRename}/no-numeric-separators`]: "error",
263
+ [`${jsonPluginRename}/no-octal-escape`]: "error",
264
+ [`${jsonPluginRename}/no-octal-numeric-literals`]: "error",
265
+ [`${jsonPluginRename}/no-octal`]: "error",
266
+ [`${jsonPluginRename}/no-parenthesized`]: "error",
267
+ [`${jsonPluginRename}/no-plus-sign`]: "error",
268
+ [`${jsonPluginRename}/no-regexp-literals`]: "error",
269
+ [`${jsonPluginRename}/no-sparse-arrays`]: "error",
270
+ [`${jsonPluginRename}/no-template-literals`]: "error",
271
+ [`${jsonPluginRename}/no-undefined-value`]: "error",
272
+ [`${jsonPluginRename}/no-unicode-codepoint-escapes`]: "error",
273
+ [`${jsonPluginRename}/no-useless-escape`]: "error",
274
+ [`${jsonPluginRename}/space-unary-ops`]: "error",
275
+ [`${jsonPluginRename}/valid-json-number`]: "error",
276
+ [`${jsonPluginRename}/vue-custom-block/no-parsing-error`]: "error"
277
+ }
278
+ }
279
+ ];
280
+ }
281
+ //#endregion
282
+ //#region src/config/markdown/markdown.globs.ts
283
+ const GLOB_MARKDOWN = ["**/*.md"];
284
+ const GLOB_MARKDOWN_IN_MARKDOWN = ["**/*.md/*.md"];
285
+ const GLOB_MARKDOWN_SOURCE = SOURCE_GLOBS.flatMap((source) => GLOB_MARKDOWN.map((markdown) => `${markdown}/${source}`));
286
+ const GLOB_MARKDOWN_JSON = GLOB_JSON.flatMap((json) => GLOB_MARKDOWN.map((markdown) => `${markdown}/${json}`));
287
+ const GLOB_MARKDOWN_ASTRO = GLOB_ASTRO.flatMap((json) => GLOB_MARKDOWN.map((markdown) => `${markdown}/${json}`));
288
+ //#endregion
289
+ //#region src/config/markdown/markdown.config.ts
290
+ async function markdown(options) {
291
+ const { markdown } = options;
292
+ if (!markdown) return [];
293
+ const pluginMarkdown = await interopDefault(import("@eslint/markdown"));
294
+ const processor = pluginMarkdown.processors?.["markdown"];
295
+ return [
296
+ {
297
+ name: MARKDOWN_CONFIG_NAME_SETUP,
298
+ plugins: { markdown: pluginMarkdown }
299
+ },
300
+ {
301
+ files: GLOB_MARKDOWN,
302
+ ignores: GLOB_MARKDOWN_IN_MARKDOWN,
303
+ name: MARKDOWN_CONFIG_NAME_SETUP_PROCESSOR,
304
+ processor: mergeProcessors([processor, processorPassThrough])
305
+ },
306
+ {
307
+ files: GLOB_MARKDOWN,
308
+ languageOptions: { parser: {
309
+ meta,
310
+ parseForESLint
311
+ } },
312
+ name: MARKDOWN_CONFIG_NAME_SETUP_PARSER
313
+ }
314
+ ];
315
+ }
316
+ //#endregion
317
+ //#region src/config/core/core.config-name.ts
318
+ const CORE_CONFIG_NAME = `${PLUGIN_PREFIX}/core`;
319
+ const CORE_CONFIG_NAME_SETUP = `${CORE_CONFIG_NAME}/setup`;
320
+ const CORE_CONFIG_NAME_RULES = `${CORE_CONFIG_NAME}/rules`;
321
+ const CORE_CONFIG_NAME_RULES_MARKDOWN_SOURCE = `${CORE_CONFIG_NAME_RULES}/markdown/source`;
322
+ const CORE_CONFIG_NAME_RULES_NODE = `${CORE_CONFIG_NAME_RULES}/node`;
323
+ //#endregion
324
+ //#region src/config/core/core.config.ts
325
+ async function core(options) {
326
+ const { markdown, module: { node: useNodeModules }, node } = options;
327
+ const nodePluginName = PLUGIN_RENAME.n;
328
+ const configs = [{
329
+ languageOptions: {
330
+ ecmaVersion: "latest",
331
+ globals: {
332
+ ...globals.browser,
333
+ ...globals.es2021,
334
+ ...globals.node,
335
+ document: "readonly",
336
+ navigator: "readonly",
337
+ window: "readonly"
338
+ },
339
+ parserOptions: {
340
+ ecmaFeatures: { jsx: true },
341
+ ecmaVersion: "latest",
342
+ sourceType: "module"
343
+ },
344
+ sourceType: "module"
345
+ },
346
+ linterOptions: { reportUnusedDisableDirectives: true },
347
+ name: CORE_CONFIG_NAME_SETUP,
348
+ plugins: { ...node && { [nodePluginName]: await interopDefault(import("eslint-plugin-n")) } }
349
+ }, {
350
+ name: CORE_CONFIG_NAME_RULES,
351
+ rules: {
352
+ "accessor-pairs": ["error", {
353
+ enforceForClassMembers: true,
354
+ setWithoutGet: true
355
+ }],
356
+ "array-callback-return": ["error", { checkForEach: true }],
357
+ "block-scoped-var": "error",
358
+ camelcase: ["error", { properties: "never" }],
359
+ "consistent-this": ["error", "self"],
360
+ "constructor-super": "error",
361
+ "default-case-last": "error",
362
+ "dot-notation": "error",
363
+ eqeqeq: "error",
364
+ "for-direction": "error",
365
+ "func-name-matching": "error",
366
+ "func-names": ["error", "as-needed"],
367
+ "getter-return": "error",
368
+ "grouped-accessor-pairs": "error",
369
+ "guard-for-in": "error",
370
+ "max-depth": ["error", 4],
371
+ "max-params": "off",
372
+ "new-cap": ["error", { capIsNew: false }],
373
+ "no-alert": "error",
374
+ "no-array-constructor": "error",
375
+ "no-async-promise-executor": "error",
376
+ "no-await-in-loop": "error",
377
+ "no-bitwise": "error",
378
+ "no-caller": "error",
379
+ "no-case-declarations": "error",
380
+ "no-class-assign": "error",
381
+ "no-compare-neg-zero": "error",
382
+ "no-cond-assign": ["error", "always"],
383
+ "no-console": ["error", { allow: ["error"] }],
384
+ "no-const-assign": "error",
385
+ "no-constant-binary-expression": "error",
386
+ "no-constant-condition": "error",
387
+ "no-constructor-return": "error",
388
+ "no-control-regex": "error",
389
+ "no-debugger": "error",
390
+ "no-delete-var": "error",
391
+ "no-dupe-args": "error",
392
+ "no-dupe-class-members": "error",
393
+ "no-dupe-else-if": "error",
394
+ "no-dupe-keys": "error",
395
+ "no-duplicate-case": "error",
396
+ "no-duplicate-imports": "off",
397
+ "no-else-return": ["error", { allowElseIf: false }],
398
+ "no-empty": "error",
399
+ "no-empty-character-class": "error",
400
+ "no-empty-pattern": "error",
401
+ "no-empty-static-block": "error",
402
+ "no-eq-null": "error",
403
+ "no-eval": "error",
404
+ "no-ex-assign": "error",
405
+ "no-extend-native": "error",
406
+ "no-extra-bind": "error",
407
+ "no-extra-boolean-cast": "error",
408
+ "no-extra-label": "error",
409
+ "no-fallthrough": "error",
410
+ "no-func-assign": "error",
411
+ "no-global-assign": "error",
412
+ "no-implicit-coercion": "error",
413
+ "no-implicit-globals": "error",
414
+ "no-implied-eval": "error",
415
+ "no-import-assign": "error",
416
+ "no-inline-comments": "error",
417
+ "no-inner-declarations": "error",
418
+ "no-invalid-regexp": "error",
419
+ "no-invalid-this": "error",
420
+ "no-irregular-whitespace": "error",
421
+ "no-iterator": "error",
422
+ "no-label-var": "error",
423
+ "no-labels": ["error", {
424
+ allowLoop: false,
425
+ allowSwitch: false
426
+ }],
427
+ "no-lone-blocks": "error",
428
+ "no-lonely-if": "error",
429
+ "no-loop-func": "error",
430
+ "no-loss-of-precision": "error",
431
+ "no-misleading-character-class": "error",
432
+ "no-multi-assign": "error",
433
+ "no-multi-str": "error",
434
+ "no-negated-condition": "error",
435
+ "no-new": "error",
436
+ "no-new-func": "error",
437
+ "no-new-native-nonconstructor": "error",
438
+ "no-new-wrappers": "error",
439
+ "no-nonoctal-decimal-escape": "error",
440
+ "no-obj-calls": "error",
441
+ "no-octal": "error",
442
+ "no-octal-escape": "error",
443
+ "no-param-reassign": "error",
444
+ "no-promise-executor-return": "error",
445
+ "no-proto": "error",
446
+ "no-prototype-builtins": "error",
447
+ "no-redeclare": "error",
448
+ "no-regex-spaces": "error",
449
+ "no-restricted-globals": [
450
+ "error",
451
+ {
452
+ message: "Use `globalThis` instead.",
453
+ name: "global"
454
+ },
455
+ {
456
+ message: "Use `globalThis` instead.",
457
+ name: "self"
458
+ }
459
+ ],
460
+ "no-restricted-properties": [
461
+ "error",
462
+ {
463
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
464
+ property: "__proto__"
465
+ },
466
+ {
467
+ message: "Use `Object.defineProperty` instead.",
468
+ property: "__defineGetter__"
469
+ },
470
+ {
471
+ message: "Use `Object.defineProperty` instead.",
472
+ property: "__defineSetter__"
473
+ },
474
+ {
475
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
476
+ property: "__lookupGetter__"
477
+ },
478
+ {
479
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
480
+ property: "__lookupSetter__"
481
+ }
482
+ ],
483
+ "no-restricted-syntax": [
484
+ "error",
485
+ "DebuggerStatement",
486
+ "LabeledStatement",
487
+ "WithStatement",
488
+ "TSEnumDeclaration[const=true]",
489
+ "TSExportAssignment"
490
+ ],
491
+ "no-return-assign": "error",
492
+ "no-self-assign": "error",
493
+ "no-self-compare": "error",
494
+ "no-sequences": "error",
495
+ "no-setter-return": "error",
496
+ "no-shadow-restricted-names": "error",
497
+ "no-sparse-arrays": "error",
498
+ "no-template-curly-in-string": "error",
499
+ "no-this-before-super": "error",
500
+ "no-throw-literal": "error",
501
+ "no-undef": "error",
502
+ "no-undef-init": "error",
503
+ "no-underscore-dangle": "error",
504
+ "no-unexpected-multiline": "error",
505
+ "no-unmodified-loop-condition": "error",
506
+ "no-unneeded-ternary": "error",
507
+ "no-unreachable": "error",
508
+ "no-unreachable-loop": "error",
509
+ "no-unsafe-finally": "error",
510
+ "no-unsafe-negation": "error",
511
+ "no-unsafe-optional-chaining": "error",
512
+ "no-unused-expressions": "error",
513
+ "no-unused-labels": "error",
514
+ "no-unused-private-class-members": "error",
515
+ "no-use-before-define": ["error", {
516
+ allowNamedExports: false,
517
+ classes: true,
518
+ functions: false,
519
+ variables: true
520
+ }],
521
+ "no-useless-assignment": "error",
522
+ "no-useless-backreference": "error",
523
+ "no-useless-call": "error",
524
+ "no-useless-catch": "error",
525
+ "no-useless-computed-key": "error",
526
+ "no-useless-constructor": "error",
527
+ "no-useless-escape": "error",
528
+ "no-useless-rename": "error",
529
+ "no-useless-return": "error",
530
+ "no-var": "error",
531
+ "no-with": "error",
532
+ "object-shorthand": "error",
533
+ "one-var": "off",
534
+ "operator-assignment": ["error", "always"],
535
+ "prefer-arrow-callback": ["error", {
536
+ allowNamedFunctions: false,
537
+ allowUnboundThis: true
538
+ }],
539
+ "prefer-const": "error",
540
+ "prefer-exponentiation-operator": "error",
541
+ "prefer-named-capture-group": "error",
542
+ "prefer-numeric-literals": "error",
543
+ "prefer-object-has-own": "error",
544
+ "prefer-promise-reject-errors": "error",
545
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
546
+ "prefer-rest-params": "error",
547
+ "prefer-spread": "error",
548
+ "prefer-template": "error",
549
+ radix: "error",
550
+ "require-atomic-updates": "error",
551
+ "require-await": "error",
552
+ "require-yield": "error",
553
+ "symbol-description": "error",
554
+ "unicode-bom": ["error", "never"],
555
+ "use-isnan": ["error", {
556
+ enforceForIndexOf: true,
557
+ enforceForSwitchCase: true
558
+ }],
559
+ "valid-typeof": ["error", { requireStringLiterals: true }],
560
+ "vars-on-top": "error",
561
+ yoda: "error"
562
+ }
563
+ }];
564
+ if (node) configs.push({
565
+ name: CORE_CONFIG_NAME_RULES_NODE,
566
+ rules: {
567
+ [`${nodePluginName}/handle-callback-err`]: ["error", "^(err|error)$"],
568
+ [`${nodePluginName}/no-exports-assign`]: "error",
569
+ [`${nodePluginName}/no-new-require`]: "error",
570
+ ...useNodeModules && {
571
+ [`${nodePluginName}/no-deprecated-api`]: "error",
572
+ [`${nodePluginName}/no-path-concat`]: "error",
573
+ [`${nodePluginName}/prefer-global/buffer`]: ["error", "never"],
574
+ [`${nodePluginName}/prefer-global/process`]: ["error", "never"],
575
+ [`${nodePluginName}/process-exit-as-throw`]: "error"
576
+ }
577
+ }
578
+ });
579
+ if (markdown) configs.push({
580
+ files: GLOB_MARKDOWN_SOURCE,
581
+ name: CORE_CONFIG_NAME_RULES_MARKDOWN_SOURCE,
582
+ rules: {
583
+ "no-console": "off",
584
+ "no-inline-comments": "off"
585
+ }
586
+ });
587
+ return configs;
588
+ }
589
+ //#endregion
590
+ //#region src/config/ignore/ignore.config-name.ts
591
+ const IGNORE_CONFIG_NAME = `${PLUGIN_PREFIX}/ignore`;
592
+ const IGNORE_CONFIG_NAME_DEFAULT = IGNORE_CONFIG_NAME;
593
+ const IGNORE_CONFIG_NAME_ADDITIONAL = `${IGNORE_CONFIG_NAME}/additional`;
594
+ const IGNORE_CONFIG_NAME_GITIGNORE = `${IGNORE_CONFIG_NAME}/gitignore`;
595
+ //#endregion
596
+ //#region src/config/ignore/ignore.globs.ts
597
+ const IGNORE_GLOB = [
598
+ "**/node_modules",
599
+ "**/dist",
600
+ "**/package-lock.json",
601
+ "**/yarn.lock",
602
+ "**/pnpm-lock.yaml",
603
+ "**/bun.lockb",
604
+ "**/output",
605
+ "**/coverage",
606
+ "**/temp",
607
+ "**/.temp",
608
+ "**/tmp",
609
+ "**/.tmp",
610
+ "**/.history",
611
+ "**/.vitepress/cache",
612
+ "**/.nuxt",
613
+ "**/.next",
614
+ "**/.vercel",
615
+ "**/.changeset",
616
+ "**/.idea",
617
+ "**/.cache",
618
+ "**/.output",
619
+ "**/.vite-inspect",
620
+ "**/.yarn",
621
+ "**/CHANGELOG*.md",
622
+ "**/*.min.*",
623
+ "**/LICENSE*",
624
+ "**/__snapshots__"
625
+ ];
626
+ //#endregion
627
+ //#region src/config/ignore/ignore.config.ts
628
+ async function ignore({ ignore }) {
629
+ if (ignore === false) return [];
630
+ const config = [{
631
+ ignores: IGNORE_GLOB,
632
+ name: IGNORE_CONFIG_NAME_DEFAULT
633
+ }];
634
+ if (typeof ignore === "object" && ignore.globs) config.push({
635
+ ignores: ignore.globs,
636
+ name: IGNORE_CONFIG_NAME_ADDITIONAL
637
+ });
638
+ if (typeof ignore === "boolean") {
639
+ if (fs.existsSync(".gitignore")) {
640
+ const gitignore = await interopDefault(import("eslint-config-flat-gitignore"));
641
+ return [...config, {
642
+ ...gitignore(),
643
+ name: IGNORE_CONFIG_NAME_GITIGNORE
644
+ }];
645
+ }
646
+ return [];
647
+ }
648
+ const gitignore = await interopDefault(import("eslint-config-flat-gitignore"));
649
+ return [...config, {
650
+ ...gitignore(ignore),
651
+ name: IGNORE_CONFIG_NAME_GITIGNORE
652
+ }];
653
+ }
654
+ //#endregion
655
+ //#region src/config/typescript/typescript.config-name.ts
656
+ const TYPESCRIPT_CONFIG_NAME = `${PLUGIN_PREFIX}/typescript`;
657
+ const TYPESCRIPT_CONFIG_NAME_SETUP = `${TYPESCRIPT_CONFIG_NAME}/setup`;
658
+ const TYPESCRIPT_CONFIG_NAME_SETUP_PARSER = `${TYPESCRIPT_CONFIG_NAME_SETUP}/parser`;
659
+ const TYPESCRIPT_CONFIG_NAME_SETUP_PARSER_TYPEAWARE = `${TYPESCRIPT_CONFIG_NAME_SETUP_PARSER}/type-aware`;
660
+ const TYPESCRIPT_CONFIG_NAME_RULES = `${TYPESCRIPT_CONFIG_NAME}/rules`;
661
+ const TYPESCRIPT_CONFIG_NAME_RULES_DTS = `${TYPESCRIPT_CONFIG_NAME_RULES}/dts`;
662
+ const TYPESCRIPT_CONFIG_NAME_RULES_TEST = `${TYPESCRIPT_CONFIG_NAME_RULES}/test`;
663
+ const TYPESCRIPT_CONFIG_NAME_RULES_TYPEAWARE = `${TYPESCRIPT_CONFIG_NAME_RULES}/type-aware`;
664
+ //#endregion
665
+ //#region src/config/typescript/typescript.globs.ts
666
+ const TYPESCRIPT_GLOBS = ["**/*.?([cm])ts?(x)"];
667
+ const DTS_GLOBS = ["**/*.d.ts"];
668
+ const TEST_GLOBS = ["**/*.spec.[jt]s?(x)", "**/*.test.[jt]s?(x)"];
669
+ //#endregion
670
+ //#region src/config/typescript/typescript.parser.ts
671
+ function typescriptParser({ files, ignores, parser, parserOptions, tsconfigPath }) {
672
+ const config = {
673
+ files,
674
+ languageOptions: {
675
+ parser,
676
+ parserOptions: {
677
+ sourceType: "module",
678
+ ...tsconfigPath && {
679
+ project: tsconfigPath,
680
+ tsconfigRootDir: cwd()
681
+ },
682
+ ...parserOptions
683
+ }
684
+ },
685
+ name: tsconfigPath ? TYPESCRIPT_CONFIG_NAME_SETUP_PARSER_TYPEAWARE : TYPESCRIPT_CONFIG_NAME_SETUP_PARSER
686
+ };
687
+ if (ignores) config.ignores = ignores;
688
+ return config;
689
+ }
690
+ //#endregion
691
+ //#region src/config/typescript/typescript.config.ts
692
+ async function typescript(options) {
693
+ const { typescript } = options;
694
+ if (typescript === false) return [];
695
+ const [plugin, parser] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
696
+ const typescriptPluginRename = PLUGIN_RENAME["@typescript-eslint"];
697
+ const config = [];
698
+ const isTypeAware = typeof typescript !== "boolean";
699
+ config.push({
700
+ name: TYPESCRIPT_CONFIG_NAME_SETUP,
701
+ plugins: { typescript: plugin }
702
+ });
703
+ if (typescript === true) config.push(typescriptParser({
704
+ files: SOURCE_GLOBS,
705
+ parser
706
+ }));
707
+ else config.push(typescriptParser({
708
+ files: [...JAVASCRIPT_GLOBS, ...GLOB_MARKDOWN_SOURCE],
709
+ parser
710
+ }), typescriptParser({
711
+ files: TYPESCRIPT_GLOBS,
712
+ ignores: GLOB_MARKDOWN_SOURCE,
713
+ parser,
714
+ tsconfigPath: toArray(typescript)
715
+ }));
716
+ config.push({
717
+ files: SOURCE_GLOBS,
718
+ name: TYPESCRIPT_CONFIG_NAME_RULES,
719
+ rules: {
720
+ ...pluginConfigOverrideRules(plugin, "eslint-recommended", PLUGIN_RENAME_TYPESCRIPT),
721
+ ...pluginConfigRules(plugin, "strict", PLUGIN_RENAME_TYPESCRIPT),
722
+ [`${typescriptPluginRename}/explicit-module-boundary-types`]: ["error"],
723
+ [`${typescriptPluginRename}/no-extraneous-class`]: "off",
724
+ [`${typescriptPluginRename}/no-unused-vars`]: "off"
725
+ }
726
+ }, {
727
+ files: DTS_GLOBS,
728
+ name: TYPESCRIPT_CONFIG_NAME_RULES_DTS,
729
+ rules: { [`${typescriptPluginRename}/triple-slash-reference`]: "off" }
730
+ });
731
+ if (isTypeAware) config.push({
732
+ files: TYPESCRIPT_GLOBS,
733
+ ignores: GLOB_MARKDOWN_SOURCE,
734
+ name: TYPESCRIPT_CONFIG_NAME_RULES_TYPEAWARE,
735
+ rules: {
736
+ ...pluginConfigRules(plugin, "strict-type-checked-only", PLUGIN_RENAME_TYPESCRIPT),
737
+ [`${typescriptPluginRename}/no-confusing-void-expression`]: ["error", { ignoreArrowShorthand: true }],
738
+ [`${typescriptPluginRename}/no-deprecated`]: "warn",
739
+ [`${typescriptPluginRename}/no-unused-vars`]: "off",
740
+ [`${typescriptPluginRename}/prefer-readonly`]: ["error"],
741
+ [`${typescriptPluginRename}/promise-function-async`]: ["error", { checkArrowFunctions: false }],
742
+ [`${typescriptPluginRename}/switch-exhaustiveness-check`]: ["error"]
743
+ }
744
+ });
745
+ config.push({
746
+ files: TEST_GLOBS,
747
+ name: TYPESCRIPT_CONFIG_NAME_RULES_TEST,
748
+ rules: { [`${typescriptPluginRename}/no-confusing-void-expression`]: "off" }
749
+ });
750
+ return config;
751
+ }
752
+ //#endregion
753
+ //#region src/config/imports/imports.config-name.ts
754
+ const IMPORTS_CONFIG_NAME = `${PLUGIN_PREFIX}/imports`;
755
+ const IMPORTS_CONFIG_NAME_SETUP = `${IMPORTS_CONFIG_NAME}/setup`;
756
+ const IMPORTS_CONFIG_NAME_SETUP_TYPESCRIPT = `${IMPORTS_CONFIG_NAME_SETUP}/typescript`;
757
+ const IMPORTS_CONFIG_NAME_RULES = `${IMPORTS_CONFIG_NAME}/rules`;
758
+ const IMPORTS_CONFIG_NAME_RULES_WARNINGS = `${IMPORTS_CONFIG_NAME_RULES}/warnings`;
759
+ const IMPORTS_CONFIG_NAME_RULES_WARNINGS_ESLINT_CONFIG = `${IMPORTS_CONFIG_NAME_RULES_WARNINGS}/eslint-config`;
760
+ const IMPORTS_CONFIG_NAME_RULES_ASTRO = `${IMPORTS_CONFIG_NAME_RULES}/astro`;
761
+ const IMPORTS_CONFIG_NAME_RULES_TYPESCRIPT = `${IMPORTS_CONFIG_NAME_RULES}/typescript`;
762
+ const IMPORTS_CONFIG_NAME_RULES_STATIC = `${IMPORTS_CONFIG_NAME_RULES}/static`;
763
+ const IMPORTS_CONFIG_NAME_RULES_STATIC_MARKDOWN_SOURCE = `${IMPORTS_CONFIG_NAME_RULES_STATIC}/markdown/source`;
764
+ const IMPORTS_CONFIG_NAME_RULES_STYLISTIC = `${IMPORTS_CONFIG_NAME_RULES}/stylistic`;
765
+ const IMPORTS_CONFIG_NAME_RULES_STYLISTIC_ASTRO = `${IMPORTS_CONFIG_NAME_RULES_STYLISTIC}/astro`;
766
+ const IMPORTS_CONFIG_NAME_RULES_STYLISTIC_TYPESCRIPT_DTS = `${IMPORTS_CONFIG_NAME_RULES_STYLISTIC}/typescript/dts`;
767
+ const IMPORTS_CONFIG_NAME_RULES_STYLISTIC_MARKDOWN_SOURCE = `${IMPORTS_CONFIG_NAME_RULES_STYLISTIC}/markdown/source`;
768
+ //#endregion
769
+ //#region src/config/imports/imports.config.ts
770
+ async function imports(options) {
771
+ const { astro, imports, json, markdown, module: { amd, commonjs, ignore: ignoreModules, node: useNodeModules, webpack }, stylistic, typescript } = options;
772
+ if (!imports) return [];
773
+ const importXPlugin = "import-x";
774
+ const importXPluginRename = PLUGIN_RENAME[importXPlugin];
775
+ const unusedImportsPrefix = PLUGIN_RENAME["unused-imports"];
776
+ const importSortPrefix = PLUGIN_RENAME["simple-import-sort"];
777
+ const { createNodeResolver, importX } = await import("eslint-plugin-import-x");
778
+ const { createTypeScriptImportResolver } = await import("eslint-import-resolver-typescript");
779
+ const configs = [{
780
+ name: IMPORTS_CONFIG_NAME_SETUP,
781
+ plugins: {
782
+ [importXPluginRename]: importX,
783
+ ...stylistic && {
784
+ [importSortPrefix]: await interopDefault(import("eslint-plugin-simple-import-sort")),
785
+ [unusedImportsPrefix]: await interopDefault(import("eslint-plugin-unused-imports"))
786
+ }
787
+ },
788
+ settings: { [`${importXPlugin}/resolver-next`]: [createNodeResolver({})] }
789
+ }];
790
+ if (typescript) {
791
+ const typeScriptExtensions = [".ts", ".tsx"];
792
+ configs.push({
793
+ files: TYPESCRIPT_GLOBS,
794
+ name: IMPORTS_CONFIG_NAME_SETUP_TYPESCRIPT,
795
+ settings: {
796
+ [`${importXPlugin}/extensions`]: typeScriptExtensions,
797
+ [`${importXPlugin}/external-module-folders`]: ["node_modules", "node_modules/@types"],
798
+ [`${importXPlugin}/parsers`]: { "@typescript-eslint/parser": [
799
+ ...typeScriptExtensions,
800
+ ".cts",
801
+ ".mts"
802
+ ] },
803
+ [`${importXPlugin}/resolver-next`]: [createNodeResolver(), createTypeScriptImportResolver()]
804
+ }
805
+ });
806
+ }
807
+ configs.push({
808
+ name: IMPORTS_CONFIG_NAME_RULES_WARNINGS,
809
+ rules: {
810
+ [`${importXPluginRename}/export`]: "error",
811
+ [`${importXPluginRename}/no-deprecated`]: "off",
812
+ [`${importXPluginRename}/no-empty-named-blocks`]: "error",
813
+ [`${importXPluginRename}/no-extraneous-dependencies`]: "error",
814
+ [`${importXPluginRename}/no-mutable-exports`]: "error",
815
+ [`${importXPluginRename}/no-named-as-default-member`]: "warn",
816
+ [`${importXPluginRename}/no-named-as-default`]: "warn",
817
+ ...!amd && { [`${importXPluginRename}/no-amd`]: "error" },
818
+ ...!commonjs && { [`${importXPluginRename}/no-commonjs`]: "error" },
819
+ ...!useNodeModules && { [`${importXPluginRename}/no-nodejs-modules`]: "error" },
820
+ [`${importXPluginRename}/default`]: "error"
821
+ }
822
+ }, {
823
+ name: IMPORTS_CONFIG_NAME_RULES_STATIC,
824
+ rules: {
825
+ [`${importXPluginRename}/named`]: "error",
826
+ [`${importXPluginRename}/no-absolute-path`]: "error",
827
+ [`${importXPluginRename}/no-cycle`]: ["error", { ignoreExternal: true }],
828
+ [`${importXPluginRename}/no-import-module-exports`]: "error",
829
+ [`${importXPluginRename}/no-relative-packages`]: "error",
830
+ [`${importXPluginRename}/no-restricted-paths`]: "off",
831
+ [`${importXPluginRename}/no-self-import`]: "error",
832
+ [`${importXPluginRename}/no-unresolved`]: ["error", {
833
+ amd,
834
+ commonjs,
835
+ ignore: ignoreModules
836
+ }],
837
+ [`${importXPluginRename}/no-useless-path-segments`]: ["error", {
838
+ commonjs,
839
+ noUselessIndex: true
840
+ }],
841
+ ...!webpack && { [`${importXPluginRename}/no-webpack-loader-syntax`]: "error" },
842
+ ...commonjs && { [`${importXPluginRename}/no-dynamic-require`]: "error" }
843
+ }
844
+ }, {
845
+ files: ESLINT_CONFIG_GLOBS,
846
+ name: IMPORTS_CONFIG_NAME_RULES_WARNINGS_ESLINT_CONFIG,
847
+ rules: {
848
+ [`${importXPluginRename}/default`]: "off",
849
+ [`${importXPluginRename}/no-deprecated`]: "off",
850
+ [`${importXPluginRename}/no-named-as-default-member`]: "off",
851
+ [`${importXPluginRename}/no-named-as-default`]: "off"
852
+ }
853
+ });
854
+ if (markdown) configs.push({
855
+ files: [
856
+ ...GLOB_MARKDOWN_SOURCE,
857
+ ...json ? GLOB_MARKDOWN_JSON : [],
858
+ ...astro ? GLOB_MARKDOWN_ASTRO : []
859
+ ],
860
+ name: IMPORTS_CONFIG_NAME_RULES_STATIC_MARKDOWN_SOURCE,
861
+ rules: { [`${importXPluginRename}/no-unresolved`]: "off" }
862
+ });
863
+ if (typescript) configs.push({
864
+ files: TYPESCRIPT_GLOBS,
865
+ name: IMPORTS_CONFIG_NAME_RULES_TYPESCRIPT,
866
+ rules: { [`${importXPluginRename}/named`]: "off" }
867
+ });
868
+ if (astro) configs.push({
869
+ files: GLOB_ASTRO,
870
+ name: IMPORTS_CONFIG_NAME_RULES_ASTRO,
871
+ rules: { [`${importXPluginRename}/named`]: "off" }
872
+ });
873
+ if (stylistic) {
874
+ configs.push({
875
+ name: IMPORTS_CONFIG_NAME_RULES_STYLISTIC,
876
+ rules: {
877
+ [`${importXPluginRename}/consistent-type-specifier-style`]: ["error", "prefer-top-level"],
878
+ [`${importXPluginRename}/exports-last`]: "error",
879
+ [`${importXPluginRename}/first`]: "error",
880
+ [`${importXPluginRename}/group-exports`]: "error",
881
+ [`${importXPluginRename}/newline-after-import`]: ["error", { count: 1 }],
882
+ [`${importXPluginRename}/no-anonymous-default-export`]: "error",
883
+ [`${importXPluginRename}/no-duplicates`]: "error",
884
+ [`${importXPluginRename}/no-namespace`]: "error",
885
+ [`${importXPluginRename}/prefer-default-export`]: "error",
886
+ ...webpack && { [`${importXPluginRename}/dynamic-import-chunkname`]: "error" },
887
+ [`${importSortPrefix}/exports`]: "error",
888
+ [`${importSortPrefix}/imports`]: "error",
889
+ [`${unusedImportsPrefix}/no-unused-imports`]: "error",
890
+ [`${unusedImportsPrefix}/no-unused-vars`]: ["warn", {
891
+ args: "after-used",
892
+ argsIgnorePattern: "^_",
893
+ ignoreRestSiblings: true,
894
+ vars: "all",
895
+ varsIgnorePattern: "^_"
896
+ }],
897
+ "sort-imports": ["error", {
898
+ allowSeparatedGroups: false,
899
+ ignoreCase: false,
900
+ ignoreDeclarationSort: true,
901
+ ignoreMemberSort: true,
902
+ memberSyntaxSortOrder: [
903
+ "none",
904
+ "all",
905
+ "multiple",
906
+ "single"
907
+ ]
908
+ }]
909
+ }
910
+ });
911
+ if (typescript) configs.push({
912
+ files: DTS_GLOBS,
913
+ name: IMPORTS_CONFIG_NAME_RULES_STYLISTIC_TYPESCRIPT_DTS,
914
+ rules: { [`${importXPluginRename}/prefer-default-export`]: "off" }
915
+ });
916
+ if (markdown) configs.push({
917
+ files: GLOB_MARKDOWN_SOURCE,
918
+ name: IMPORTS_CONFIG_NAME_RULES_STYLISTIC_MARKDOWN_SOURCE,
919
+ rules: { [`${unusedImportsPrefix}/no-unused-vars`]: ["off"] }
920
+ });
921
+ if (astro) configs.push({
922
+ files: GLOB_ASTRO,
923
+ name: IMPORTS_CONFIG_NAME_RULES_STYLISTIC_ASTRO,
924
+ rules: {
925
+ [`${importXPluginRename}/exports-last`]: ["off"],
926
+ [`${importXPluginRename}/prefer-default-export`]: ["off"]
927
+ }
928
+ });
929
+ }
930
+ return configs;
931
+ }
932
+ //#endregion
933
+ //#region src/config/react/react.config-name.ts
934
+ const REACT_CONFIG_NAME = `${PLUGIN_PREFIX}/react`;
935
+ const REACT_CONFIG_NAME_SETUP = `${REACT_CONFIG_NAME}/setup`;
936
+ const REACT_CONFIG_NAME_RULES = `${REACT_CONFIG_NAME}/rules`;
937
+ const REACT_CONFIG_NAME_RULES_HOOKS = `${REACT_CONFIG_NAME_RULES}/hooks`;
938
+ const REACT_CONFIG_NAME_RULES_REFRESH = `${REACT_CONFIG_NAME_RULES}/refresh`;
939
+ //#endregion
940
+ //#region src/config/react/react.globs.ts
941
+ const GLOB_REACT_JSX = ["**/*.?([cm])jsx"];
942
+ const GLOB_REACT_TSX = ["**/*.?([cm])tsx"];
943
+ //#endregion
944
+ //#region src/config/react/react.config.ts
945
+ const REACT_REFRESH_ALLOW_CONSTANT_EXPORT_PACKAGES = ["vite"];
946
+ async function react(options) {
947
+ const { react, typescript } = options;
948
+ if (!react) return [];
949
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
950
+ interopDefault(import("eslint-plugin-react")),
951
+ interopDefault(import("eslint-plugin-react-hooks")),
952
+ interopDefault(import("eslint-plugin-react-refresh"))
953
+ ]);
954
+ const isAllowConstantExport = REACT_REFRESH_ALLOW_CONSTANT_EXPORT_PACKAGES.some((index) => isPackageExists(index));
955
+ const files = [...GLOB_REACT_JSX, ...typescript ? GLOB_REACT_TSX : []];
956
+ return [
957
+ {
958
+ name: REACT_CONFIG_NAME_SETUP,
959
+ plugins: {
960
+ react: pluginReact,
961
+ "react-hooks": pluginReactHooks,
962
+ "react-refresh": pluginReactRefresh
963
+ },
964
+ settings: { react: { version: "detect" } }
965
+ },
966
+ {
967
+ files,
968
+ name: REACT_CONFIG_NAME_RULES,
969
+ rules: {
970
+ "react/display-name": "error",
971
+ "react/jsx-key": "error",
972
+ "react/jsx-no-comment-textnodes": "error",
973
+ "react/jsx-no-duplicate-props": "error",
974
+ "react/jsx-no-target-blank": "error",
975
+ "react/jsx-uses-react": "error",
976
+ "react/jsx-uses-vars": "error",
977
+ "react/no-children-prop": "error",
978
+ "react/no-danger-with-children": "error",
979
+ "react/no-deprecated": "error",
980
+ "react/no-direct-mutation-state": "error",
981
+ "react/no-find-dom-node": "error",
982
+ "react/no-is-mounted": "error",
983
+ "react/no-render-return-value": "error",
984
+ "react/no-string-refs": "error",
985
+ "react/no-unescaped-entities": "error",
986
+ "react/no-unknown-property": "error",
987
+ "react/no-unsafe": "off",
988
+ "react/react-in-jsx-scope": "off",
989
+ "react/require-render-return": "error",
990
+ ...!typescript && {
991
+ "react/jsx-no-undef": "error",
992
+ "react/prop-types": "error"
993
+ }
994
+ }
995
+ },
996
+ {
997
+ files,
998
+ name: REACT_CONFIG_NAME_RULES_HOOKS,
999
+ rules: {
1000
+ "react-hooks/exhaustive-deps": "error",
1001
+ "react-hooks/rules-of-hooks": "error"
1002
+ }
1003
+ },
1004
+ {
1005
+ files,
1006
+ name: REACT_CONFIG_NAME_RULES_REFRESH,
1007
+ rules: { "react-refresh/only-export-components": ["warn", { allowConstantExport: isAllowConstantExport }] }
1008
+ }
1009
+ ];
1010
+ }
1011
+ //#endregion
1012
+ //#region src/config/stylistic/stylistic.config-name.ts
1013
+ const STYLISTIC_CONFIG_NAME = `${PLUGIN_PREFIX}/stylistic`;
1014
+ const STYLISTIC_CONFIG_NAME_SETUP = `${STYLISTIC_CONFIG_NAME}/setup`;
1015
+ const STYLISTIC_CONFIG_NAME_RULES = `${STYLISTIC_CONFIG_NAME}/rules`;
1016
+ const STYLISTIC_CONFIG_NAME_RULES_UNICORN = `${STYLISTIC_CONFIG_NAME_RULES}/unicorn`;
1017
+ const STYLISTIC_CONFIG_NAME_RULES_UNICORN_MARKDOWN = `${STYLISTIC_CONFIG_NAME_RULES_UNICORN}/markdown`;
1018
+ const STYLISTIC_CONFIG_NAME_RULES_UNICORN_MARKDOWN_SOURCE = `${STYLISTIC_CONFIG_NAME_RULES_UNICORN_MARKDOWN}/source`;
1019
+ const STYLISTIC_CONFIG_NAME_RULES_PERFECTIONIST = `${STYLISTIC_CONFIG_NAME_RULES}/perfectionist`;
1020
+ const STYLISTIC_CONFIG_NAME_RULES_MARKDOWN_SOURCE = `${`${STYLISTIC_CONFIG_NAME_RULES}/markdown`}/source`;
1021
+ const STYLISTIC_CONFIG_NAME_RULES_ASTRO = `${STYLISTIC_CONFIG_NAME_RULES}/astro`;
1022
+ const STYLISTIC_CONFIG_NAME_RULES_MARKDOWN_ASRTO = `${STYLISTIC_CONFIG_NAME_RULES}/astro`;
1023
+ const STYLISTIC_CONFIG_NAME_RULES_MARKDOWN_JSON = `${STYLISTIC_CONFIG_NAME_RULES}/json`;
1024
+ const STYLISTIC_CONFIG_NAME_RULES_JSON = `${STYLISTIC_CONFIG_NAME_RULES}/json`;
1025
+ const STYLISTIC_CONFIG_NAME_RULES_JSON_PACKAGE = `${STYLISTIC_CONFIG_NAME_RULES_JSON}/package.json`;
1026
+ const STYLISTIC_CONFIG_NAME_RULES_JSON_TSCONFIG = `${STYLISTIC_CONFIG_NAME_RULES_JSON}/tsconfig.json`;
1027
+ const STYLISTIC_CONFIG_NAME_RULES_TYPESCRIPT = `${STYLISTIC_CONFIG_NAME_RULES}/typescript`;
1028
+ const STYLISTIC_CONFIG_NAME_RULES_TYPESCRIPT_DTS = `${STYLISTIC_CONFIG_NAME_RULES_TYPESCRIPT}/dts`;
1029
+ const STYLISTIC_CONFIG_NAME_RULES_TYPESCRIPT_TYPE_AWARE = `${STYLISTIC_CONFIG_NAME_RULES_TYPESCRIPT}/type-aware`;
1030
+ const STYLISTIC_CONFIG_NAME_RULES_PRETTIER = `${STYLISTIC_CONFIG_NAME_RULES}/prettier`;
1031
+ const STYLISTIC_CONFIG_NAME_RULES_PRETTIER_ASTRO = `${STYLISTIC_CONFIG_NAME_RULES_PRETTIER}/astro`;
1032
+ const STYLISTIC_CONFIG_NAME_RULES_PRETTIER_MARKDOWN = `${STYLISTIC_CONFIG_NAME_RULES_PRETTIER}/markdown`;
1033
+ const STYLISTIC_CONFIG_NAME_RULES_PRETTIER_MARKDOWN_SOURCE = `${STYLISTIC_CONFIG_NAME_RULES_PRETTIER_MARKDOWN}/source`;
1034
+ const STYLISTIC_CONFIG_NAME_RULES_PRETTIER_MARKDOWN_ASTRO = `${STYLISTIC_CONFIG_NAME_RULES_PRETTIER_MARKDOWN}/astro`;
1035
+ //#endregion
1036
+ //#region src/config/stylistic/stylistic.options-prettier.ts
1037
+ function prettierOptions(options) {
1038
+ const { arrowParens, bracketSameLine, bracketSpacing, endOfLine, indent, indentSize, printWidth, quoteProps, quotes, semicolons, singleAttributePerLine, trailingComma } = options;
1039
+ return {
1040
+ arrowParens,
1041
+ bracketSameLine,
1042
+ bracketSpacing,
1043
+ endOfLine,
1044
+ jsxSingleQuote: quotes === "single",
1045
+ printWidth,
1046
+ quoteProps,
1047
+ semi: semicolons,
1048
+ singleAttributePerLine,
1049
+ singleQuote: quotes === "single",
1050
+ tabWidth: indentSize,
1051
+ trailingComma,
1052
+ useTabs: indent === "tab"
1053
+ };
1054
+ }
1055
+ //#endregion
1056
+ //#region src/config/stylistic/stylistic.options-stylistic.ts
1057
+ function stylisticOptions(options) {
1058
+ const { arrowParens, braceStyle, bracketSpacing, indent, indentSize, quoteProps, quotes, semicolons, trailingComma } = options;
1059
+ return {
1060
+ arrowParens: arrowParens === "always",
1061
+ blockSpacing: bracketSpacing,
1062
+ braceStyle,
1063
+ commaDangle: trailingComma === "es5" ? "only-multiline" : trailingComma === "none" ? "never" : "always",
1064
+ indent: indent === "tab" ? "tab" : indentSize,
1065
+ jsx: true,
1066
+ quoteProps: quoteProps === "preserve" ? "as-needed" : quoteProps,
1067
+ quotes,
1068
+ semi: semicolons
1069
+ };
1070
+ }
1071
+ //#endregion
1072
+ //#region src/config/stylistic/stylistic.config.ts
1073
+ async function stylistic(options) {
1074
+ const { astro, json, markdown, stylistic, typescript } = options;
1075
+ if (stylistic === false) return [];
1076
+ const { format, indent, indentSize, perfectionist, unicorn } = stylistic;
1077
+ const isTypeAware = typeof typescript !== "boolean";
1078
+ const typescriptPluginRename = PLUGIN_RENAME["@typescript-eslint"];
1079
+ const stylisticPluginRename = PLUGIN_RENAME["@stylistic"];
1080
+ const jsonPluginRename = PLUGIN_RENAME.jsonc;
1081
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
1082
+ const pluginStylisticOptions = stylisticOptions(stylistic);
1083
+ const pluginStylisticRules = pluginStylistic.configs.customize(pluginStylisticOptions).rules;
1084
+ const pluginUnicorn = await interopDefault(import("eslint-plugin-unicorn"));
1085
+ const pluginPerfectionist = (await interopDefault(import("eslint-plugin-perfectionist"))).configs["recommended-natural"];
1086
+ const config = [{
1087
+ name: STYLISTIC_CONFIG_NAME_SETUP,
1088
+ plugins: {
1089
+ style: pluginStylistic,
1090
+ ...unicorn && { unicorn: pluginUnicorn },
1091
+ ...perfectionist && { ...pluginPerfectionist.plugins },
1092
+ ...format && { format: await interopDefault(import("eslint-plugin-format")) }
1093
+ }
1094
+ }, {
1095
+ name: STYLISTIC_CONFIG_NAME_RULES,
1096
+ rules: {
1097
+ ...renameRules(pluginStylisticRules, PLUGIN_RENAME),
1098
+ [`${stylisticPluginRename}/arrow-parens`]: ["error", "as-needed"],
1099
+ [`${stylisticPluginRename}/brace-style`]: "off",
1100
+ [`${stylisticPluginRename}/implicit-arrow-linebreak`]: "off",
1101
+ [`${stylisticPluginRename}/indent-binary-ops`]: "off",
1102
+ [`${stylisticPluginRename}/indent`]: "off",
1103
+ [`${stylisticPluginRename}/jsx-closing-bracket-location`]: ["error", {
1104
+ nonEmpty: "after-props",
1105
+ selfClosing: "tag-aligned"
1106
+ }],
1107
+ [`${stylisticPluginRename}/jsx-curly-newline`]: "off",
1108
+ [`${stylisticPluginRename}/jsx-indent`]: "off",
1109
+ [`${stylisticPluginRename}/jsx-one-expression-per-line`]: "off",
1110
+ [`${stylisticPluginRename}/jsx-quotes`]: ["error", "prefer-single"],
1111
+ [`${stylisticPluginRename}/line-comment-position`]: ["error", { position: "above" }],
1112
+ [`${stylisticPluginRename}/max-len`]: "off",
1113
+ [`${stylisticPluginRename}/multiline-comment-style`]: ["error", "starred-block"],
1114
+ [`${stylisticPluginRename}/multiline-ternary`]: "off",
1115
+ [`${stylisticPluginRename}/no-extra-semi`]: "error",
1116
+ [`${stylisticPluginRename}/padding-line-between-statements`]: ["error", {
1117
+ blankLine: "always",
1118
+ next: "return",
1119
+ prev: "*"
1120
+ }],
1121
+ curly: ["error", "all"],
1122
+ ...format && { [`${stylisticPluginRename}/operator-linebreak`]: "off" }
1123
+ }
1124
+ }];
1125
+ if (markdown) config.push({
1126
+ files: [
1127
+ ...GLOB_MARKDOWN_SOURCE,
1128
+ ...json ? GLOB_MARKDOWN_JSON : [],
1129
+ ...astro ? GLOB_MARKDOWN_ASTRO : []
1130
+ ],
1131
+ name: STYLISTIC_CONFIG_NAME_RULES_MARKDOWN_SOURCE,
1132
+ rules: {
1133
+ [`${stylisticPluginRename}/indent`]: ["error", 2],
1134
+ [`${stylisticPluginRename}/line-comment-position`]: "off",
1135
+ [`${stylisticPluginRename}/multiline-comment-style`]: "off"
1136
+ }
1137
+ });
1138
+ if (typescript) {
1139
+ const plugin = await interopDefault(import("@typescript-eslint/eslint-plugin"));
1140
+ config.push({
1141
+ files: SOURCE_GLOBS,
1142
+ name: STYLISTIC_CONFIG_NAME_RULES_TYPESCRIPT,
1143
+ rules: {
1144
+ ...pluginConfigRules(plugin, "stylistic", PLUGIN_RENAME_TYPESCRIPT),
1145
+ [`${typescriptPluginRename}/consistent-type-assertions`]: "off",
1146
+ [`${typescriptPluginRename}/member-ordering`]: ["error", { default: {
1147
+ memberTypes: [
1148
+ "signature",
1149
+ "call-signature",
1150
+ "public-static-field",
1151
+ "protected-static-field",
1152
+ "private-static-field",
1153
+ "#private-static-field",
1154
+ "public-decorated-field",
1155
+ "protected-decorated-field",
1156
+ "private-decorated-field",
1157
+ "public-instance-field",
1158
+ "protected-instance-field",
1159
+ "private-instance-field",
1160
+ "#private-instance-field",
1161
+ "public-abstract-field",
1162
+ "protected-abstract-field",
1163
+ "public-field",
1164
+ "protected-field",
1165
+ "private-field",
1166
+ "#private-field",
1167
+ "static-field",
1168
+ "instance-field",
1169
+ "abstract-field",
1170
+ "decorated-field",
1171
+ "field",
1172
+ "static-initialization",
1173
+ "public-constructor",
1174
+ "protected-constructor",
1175
+ "private-constructor",
1176
+ "constructor",
1177
+ "public-static-get",
1178
+ "protected-static-get",
1179
+ "private-static-get",
1180
+ "#private-static-get",
1181
+ "public-decorated-get",
1182
+ "protected-decorated-get",
1183
+ "private-decorated-get",
1184
+ "public-instance-get",
1185
+ "protected-instance-get",
1186
+ "private-instance-get",
1187
+ "#private-instance-get",
1188
+ "public-abstract-get",
1189
+ "protected-abstract-get",
1190
+ "public-get",
1191
+ "protected-get",
1192
+ "private-get",
1193
+ "#private-get",
1194
+ "static-get",
1195
+ "instance-get",
1196
+ "abstract-get",
1197
+ "decorated-get",
1198
+ "get",
1199
+ "public-static-set",
1200
+ "protected-static-set",
1201
+ "private-static-set",
1202
+ "#private-static-set",
1203
+ "public-decorated-set",
1204
+ "protected-decorated-set",
1205
+ "private-decorated-set",
1206
+ "public-instance-set",
1207
+ "protected-instance-set",
1208
+ "private-instance-set",
1209
+ "#private-instance-set",
1210
+ "public-abstract-set",
1211
+ "protected-abstract-set",
1212
+ "public-set",
1213
+ "protected-set",
1214
+ "private-set",
1215
+ "#private-set",
1216
+ "static-set",
1217
+ "instance-set",
1218
+ "abstract-set",
1219
+ "decorated-set",
1220
+ "set",
1221
+ "public-static-method",
1222
+ "protected-static-method",
1223
+ "private-static-method",
1224
+ "#private-static-method",
1225
+ "public-decorated-method",
1226
+ "protected-decorated-method",
1227
+ "private-decorated-method",
1228
+ "public-instance-method",
1229
+ "protected-instance-method",
1230
+ "private-instance-method",
1231
+ "#private-instance-method",
1232
+ "public-abstract-method",
1233
+ "protected-abstract-method",
1234
+ "public-method",
1235
+ "protected-method",
1236
+ "private-method",
1237
+ "#private-method",
1238
+ "static-method",
1239
+ "instance-method",
1240
+ "abstract-method",
1241
+ "decorated-method",
1242
+ "method"
1243
+ ],
1244
+ order: "natural"
1245
+ } }]
1246
+ }
1247
+ });
1248
+ if (isTypeAware) config.push({
1249
+ files: TYPESCRIPT_GLOBS,
1250
+ ignores: GLOB_MARKDOWN_SOURCE,
1251
+ name: STYLISTIC_CONFIG_NAME_RULES_TYPESCRIPT_TYPE_AWARE,
1252
+ rules: {
1253
+ ...pluginConfigRules(plugin, "stylistic-type-checked-only", PLUGIN_RENAME_TYPESCRIPT),
1254
+ [`${typescriptPluginRename}/consistent-type-assertions`]: "error"
1255
+ }
1256
+ });
1257
+ config.push({
1258
+ files: DTS_GLOBS,
1259
+ name: STYLISTIC_CONFIG_NAME_RULES_TYPESCRIPT_DTS,
1260
+ rules: {
1261
+ [`${stylisticPluginRename}/multiline-comment-style`]: "off",
1262
+ [`${stylisticPluginRename}/spaced-comment`]: "off"
1263
+ }
1264
+ });
1265
+ }
1266
+ if (json) config.push({
1267
+ files: GLOB_JSON,
1268
+ name: STYLISTIC_CONFIG_NAME_RULES_JSON,
1269
+ rules: {
1270
+ [`${jsonPluginRename}/array-bracket-spacing`]: ["error", "never"],
1271
+ [`${jsonPluginRename}/comma-dangle`]: ["error", "never"],
1272
+ [`${jsonPluginRename}/comma-style`]: ["error", "last"],
1273
+ [`${jsonPluginRename}/indent`]: ["error", indent === "space" ? indentSize : indent],
1274
+ [`${jsonPluginRename}/key-spacing`]: ["error", {
1275
+ afterColon: true,
1276
+ beforeColon: false
1277
+ }],
1278
+ [`${jsonPluginRename}/object-curly-newline`]: ["error", {
1279
+ consistent: true,
1280
+ multiline: true
1281
+ }],
1282
+ [`${jsonPluginRename}/object-curly-spacing`]: ["error", "always"],
1283
+ [`${jsonPluginRename}/object-property-newline`]: ["error", { allowMultiplePropertiesPerLine: true }],
1284
+ [`${jsonPluginRename}/quote-props`]: "error",
1285
+ [`${jsonPluginRename}/quotes`]: "error"
1286
+ }
1287
+ }, {
1288
+ files: GLOB_JSON_PACKAGE,
1289
+ name: STYLISTIC_CONFIG_NAME_RULES_JSON_PACKAGE,
1290
+ rules: {
1291
+ "jsonc/sort-array-values": ["error", {
1292
+ order: { type: "asc" },
1293
+ pathPattern: "^files$"
1294
+ }],
1295
+ "jsonc/sort-keys": [
1296
+ "error",
1297
+ {
1298
+ order: [
1299
+ "name",
1300
+ "displayName",
1301
+ "version",
1302
+ "author",
1303
+ "publisher",
1304
+ "description",
1305
+ "keywords",
1306
+ "categories",
1307
+ "repository",
1308
+ "homepage",
1309
+ "bugs",
1310
+ "funding",
1311
+ "license",
1312
+ "private",
1313
+ "publishConfig",
1314
+ "type",
1315
+ "sideEffects",
1316
+ "bin",
1317
+ "icon",
1318
+ "files",
1319
+ "main",
1320
+ "module",
1321
+ "unpkg",
1322
+ "jsdelivr",
1323
+ "types",
1324
+ "exports",
1325
+ "typesVersions",
1326
+ "scripts",
1327
+ "peerDependencies",
1328
+ "peerDependenciesMeta",
1329
+ "dependencies",
1330
+ "optionalDependencies",
1331
+ "devDependencies",
1332
+ "overrides",
1333
+ "resolutions",
1334
+ "engines",
1335
+ "packageManager",
1336
+ "pnpm",
1337
+ "activationEvents",
1338
+ "contributes",
1339
+ "husky",
1340
+ "simple-git-hooks",
1341
+ "lint-staged",
1342
+ "eslintConfig"
1343
+ ],
1344
+ pathPattern: "^$"
1345
+ },
1346
+ {
1347
+ order: { type: "asc" },
1348
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1349
+ },
1350
+ {
1351
+ order: { type: "asc" },
1352
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1353
+ },
1354
+ {
1355
+ order: { type: "asc" },
1356
+ pathPattern: "^(?:scripts)$"
1357
+ },
1358
+ {
1359
+ order: [
1360
+ "types",
1361
+ "import",
1362
+ "require",
1363
+ "default"
1364
+ ],
1365
+ pathPattern: "^exports.*$"
1366
+ },
1367
+ {
1368
+ order: [
1369
+ "pre-commit",
1370
+ "prepare-commit-msg",
1371
+ "commit-msg",
1372
+ "post-commit",
1373
+ "pre-rebase",
1374
+ "post-rewrite",
1375
+ "post-checkout",
1376
+ "post-merge",
1377
+ "pre-push",
1378
+ "pre-auto-gc"
1379
+ ],
1380
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1381
+ }
1382
+ ]
1383
+ }
1384
+ }, {
1385
+ files: GLOB_JSON_TSCONFIG,
1386
+ name: STYLISTIC_CONFIG_NAME_RULES_JSON_TSCONFIG,
1387
+ rules: { "jsonc/sort-keys": [
1388
+ "error",
1389
+ {
1390
+ order: [
1391
+ "extends",
1392
+ "compilerOptions",
1393
+ "references",
1394
+ "files",
1395
+ "include",
1396
+ "exclude"
1397
+ ],
1398
+ pathPattern: "^$"
1399
+ },
1400
+ {
1401
+ order: [
1402
+ "incremental",
1403
+ "composite",
1404
+ "tsBuildInfoFile",
1405
+ "disableSourceOfProjectReferenceRedirect",
1406
+ "disableSolutionSearching",
1407
+ "disableReferencedProjectLoad",
1408
+ "target",
1409
+ "jsx",
1410
+ "jsxFactory",
1411
+ "jsxFragmentFactory",
1412
+ "jsxImportSource",
1413
+ "lib",
1414
+ "moduleDetection",
1415
+ "noLib",
1416
+ "reactNamespace",
1417
+ "useDefineForClassFields",
1418
+ "emitDecoratorMetadata",
1419
+ "experimentalDecorators",
1420
+ "baseUrl",
1421
+ "rootDir",
1422
+ "rootDirs",
1423
+ "customConditions",
1424
+ "module",
1425
+ "moduleResolution",
1426
+ "moduleSuffixes",
1427
+ "noResolve",
1428
+ "paths",
1429
+ "resolveJsonModule",
1430
+ "resolvePackageJsonExports",
1431
+ "resolvePackageJsonImports",
1432
+ "typeRoots",
1433
+ "types",
1434
+ "allowArbitraryExtensions",
1435
+ "allowImportingTsExtensions",
1436
+ "allowUmdGlobalAccess",
1437
+ "allowJs",
1438
+ "checkJs",
1439
+ "maxNodeModuleJsDepth",
1440
+ "strict",
1441
+ "strictBindCallApply",
1442
+ "strictFunctionTypes",
1443
+ "strictNullChecks",
1444
+ "strictPropertyInitialization",
1445
+ "allowUnreachableCode",
1446
+ "allowUnusedLabels",
1447
+ "alwaysStrict",
1448
+ "exactOptionalPropertyTypes",
1449
+ "noFallthroughCasesInSwitch",
1450
+ "noImplicitAny",
1451
+ "noImplicitOverride",
1452
+ "noImplicitReturns",
1453
+ "noImplicitThis",
1454
+ "noPropertyAccessFromIndexSignature",
1455
+ "noUncheckedIndexedAccess",
1456
+ "noUnusedLocals",
1457
+ "noUnusedParameters",
1458
+ "useUnknownInCatchVariables",
1459
+ "declaration",
1460
+ "declarationDir",
1461
+ "declarationMap",
1462
+ "downlevelIteration",
1463
+ "emitBOM",
1464
+ "emitDeclarationOnly",
1465
+ "importHelpers",
1466
+ "importsNotUsedAsValues",
1467
+ "inlineSourceMap",
1468
+ "inlineSources",
1469
+ "mapRoot",
1470
+ "newLine",
1471
+ "noEmit",
1472
+ "noEmitHelpers",
1473
+ "noEmitOnError",
1474
+ "outDir",
1475
+ "outFile",
1476
+ "preserveConstEnums",
1477
+ "preserveValueImports",
1478
+ "removeComments",
1479
+ "sourceMap",
1480
+ "sourceRoot",
1481
+ "stripInternal",
1482
+ "allowSyntheticDefaultImports",
1483
+ "esModuleInterop",
1484
+ "forceConsistentCasingInFileNames",
1485
+ "isolatedModules",
1486
+ "preserveSymlinks",
1487
+ "verbatimModuleSyntax",
1488
+ "skipDefaultLibCheck",
1489
+ "skipLibCheck"
1490
+ ],
1491
+ pathPattern: "^compilerOptions$"
1492
+ }
1493
+ ] }
1494
+ });
1495
+ if (astro) config.push({
1496
+ files: GLOB_ASTRO,
1497
+ name: STYLISTIC_CONFIG_NAME_RULES_ASTRO,
1498
+ rules: {
1499
+ "astro/prefer-class-list-directive": "error",
1500
+ "astro/prefer-object-class-list": "error",
1501
+ "astro/prefer-split-class-list": "error",
1502
+ "astro/semi": "error"
1503
+ }
1504
+ });
1505
+ if (unicorn) {
1506
+ const unicornRules = (pluginUnicorn.configs ? pluginUnicorn.configs["flat/recommended"] : void 0)?.rules;
1507
+ config.push({
1508
+ name: STYLISTIC_CONFIG_NAME_RULES_UNICORN,
1509
+ rules: {
1510
+ ...unicornRules,
1511
+ "unicorn/consistent-function-scoping": "off",
1512
+ "unicorn/dom-node-dataset": "off",
1513
+ "unicorn/name-replacements": ["error", { allowList: {
1514
+ env: true,
1515
+ props: true
1516
+ } }],
1517
+ "unicorn/no-array-reduce": "off",
1518
+ "unicorn/no-nested-ternary": "off",
1519
+ "unicorn/no-static-only-class": "off"
1520
+ }
1521
+ });
1522
+ if (markdown) config.push({
1523
+ files: GLOB_MARKDOWN,
1524
+ name: STYLISTIC_CONFIG_NAME_RULES_UNICORN_MARKDOWN,
1525
+ rules: { "unicorn/filename-case": "off" }
1526
+ }, {
1527
+ files: [
1528
+ ...GLOB_MARKDOWN_SOURCE,
1529
+ ...json ? GLOB_MARKDOWN_JSON : [],
1530
+ ...astro ? GLOB_MARKDOWN_ASTRO : []
1531
+ ],
1532
+ name: STYLISTIC_CONFIG_NAME_RULES_UNICORN_MARKDOWN_SOURCE,
1533
+ rules: { "unicorn/filename-case": "off" }
1534
+ });
1535
+ }
1536
+ if (perfectionist) config.push({
1537
+ name: STYLISTIC_CONFIG_NAME_RULES_PERFECTIONIST,
1538
+ rules: {
1539
+ ...pluginPerfectionist.rules,
1540
+ "perfectionist/sort-classes": "off",
1541
+ "perfectionist/sort-exports": "off",
1542
+ "perfectionist/sort-imports": "off",
1543
+ "perfectionist/sort-interfaces": "off",
1544
+ "perfectionist/sort-jsx-props": "error",
1545
+ "perfectionist/sort-modules": "off",
1546
+ "perfectionist/sort-named-exports": "off",
1547
+ "perfectionist/sort-named-imports": "off",
1548
+ "perfectionist/sort-object": ["off", { specialCharacters: "trim" }],
1549
+ "perfectionist/sort-object-types": "off"
1550
+ }
1551
+ });
1552
+ if (format) {
1553
+ const prettierConfig = prettierOptions(stylistic);
1554
+ config.push({
1555
+ files: typescript ? SOURCE_GLOBS : JAVASCRIPT_GLOBS,
1556
+ ignores: [
1557
+ ...GLOB_MARKDOWN_SOURCE,
1558
+ ...json ? GLOB_MARKDOWN_JSON : [],
1559
+ ...astro ? GLOB_MARKDOWN_ASTRO : []
1560
+ ],
1561
+ name: STYLISTIC_CONFIG_NAME_RULES_PRETTIER,
1562
+ rules: { "format/prettier": ["error", {
1563
+ ...prettierConfig,
1564
+ parser: "typescript"
1565
+ }] }
1566
+ });
1567
+ if (astro) config.push({
1568
+ files: GLOB_ASTRO,
1569
+ name: STYLISTIC_CONFIG_NAME_RULES_PRETTIER_ASTRO,
1570
+ rules: { "format/prettier": ["error", {
1571
+ ...prettierConfig,
1572
+ parser: "astro",
1573
+ plugins: ["prettier-plugin-astro"]
1574
+ }] }
1575
+ });
1576
+ if (markdown) {
1577
+ config.push({
1578
+ files: GLOB_MARKDOWN_SOURCE,
1579
+ name: STYLISTIC_CONFIG_NAME_RULES_PRETTIER_MARKDOWN_SOURCE,
1580
+ rules: { "format/prettier": ["error", {
1581
+ ...prettierConfig,
1582
+ parser: "typescript",
1583
+ tabWidth: 2,
1584
+ useTabs: false
1585
+ }] }
1586
+ });
1587
+ if (astro) config.push({
1588
+ files: GLOB_MARKDOWN_ASTRO,
1589
+ name: STYLISTIC_CONFIG_NAME_RULES_PRETTIER_MARKDOWN_ASTRO,
1590
+ rules: { "format/prettier": ["error", {
1591
+ ...prettierConfig,
1592
+ parser: "astro",
1593
+ plugins: ["prettier-plugin-astro"],
1594
+ tabWidth: 2,
1595
+ useTabs: false
1596
+ }] }
1597
+ });
1598
+ }
1599
+ }
1600
+ if (json) config.push({
1601
+ files: GLOB_MARKDOWN_JSON,
1602
+ name: STYLISTIC_CONFIG_NAME_RULES_MARKDOWN_JSON,
1603
+ rules: { "json/indent": ["error", 2] }
1604
+ });
1605
+ if (astro) config.push({
1606
+ files: GLOB_MARKDOWN_ASTRO,
1607
+ name: STYLISTIC_CONFIG_NAME_RULES_MARKDOWN_ASRTO,
1608
+ rules: { [`${stylisticPluginRename}/indent`]: ["error", 2] }
1609
+ });
1610
+ return config;
1611
+ }
1612
+ //#endregion
1613
+ //#region src/options/hexadrop-eslint.options.ts
1614
+ function getCwdTsconfigPath() {
1615
+ const root = process.cwd();
1616
+ if (existsSync(path.resolve(root, "tsconfig.json"))) return "tsconfig.json";
1617
+ }
1618
+ function defaultOptions(options = {}) {
1619
+ let typescript = false;
1620
+ const isInstalledTypescript = isPackageExists("typescript");
1621
+ const isInstalledReact = isPackageExists("react");
1622
+ const isInstalledAstro = isPackageExists("astro");
1623
+ if (options.typescript === true) typescript = true;
1624
+ else if (isInstalledTypescript) {
1625
+ if (options.typescript === void 0) typescript = getCwdTsconfigPath() ?? true;
1626
+ else if (options.typescript === "string") typescript = options.typescript.length > 0 ? options.typescript : true;
1627
+ else if (Array.isArray(options.typescript)) typescript = options.typescript.length > 0 ? options.typescript.filter(Boolean) : true;
1628
+ }
1629
+ return {
1630
+ astro: options.astro ?? isInstalledAstro,
1631
+ ignore: typeof options.ignore === "object" ? {
1632
+ ...options.ignore,
1633
+ files: typeof options.ignore.files === "string" ? options.ignore.files : options.ignore.files?.filter(Boolean) ?? [],
1634
+ filesGitModules: typeof options.ignore.filesGitModules === "string" ? options.ignore.filesGitModules : options.ignore.filesGitModules?.filter(Boolean) ?? [],
1635
+ globs: options.ignore.globs?.filter(Boolean) ?? [],
1636
+ recursive: typeof options.ignore.recursive === "boolean" ? options.ignore.recursive : typeof options.ignore.recursive === "object" && options.ignore.recursive.skipDirs ? { skipDirs: options.ignore.recursive.skipDirs.filter(Boolean) } : false
1637
+ } : options.ignore ?? true,
1638
+ imports: options.imports ?? true,
1639
+ json: options.json ?? true,
1640
+ markdown: options.markdown ?? true,
1641
+ module: {
1642
+ amd: false,
1643
+ commonjs: false,
1644
+ node: true,
1645
+ webpack: false,
1646
+ ...options.module,
1647
+ ignore: [
1648
+ String.raw`bun\:.*`,
1649
+ String.raw`astro\:.*`,
1650
+ ...options.module?.ignore?.filter(Boolean) ?? []
1651
+ ]
1652
+ },
1653
+ node: options.node ?? true,
1654
+ react: options.react ?? isInstalledReact,
1655
+ stylistic: options.stylistic === false ? false : {
1656
+ arrowParens: "avoid",
1657
+ braceStyle: "1tbs",
1658
+ bracketSameLine: true,
1659
+ bracketSpacing: true,
1660
+ endOfLine: "lf",
1661
+ format: true,
1662
+ imports: true,
1663
+ indent: "tab",
1664
+ indentSize: 4,
1665
+ perfectionist: true,
1666
+ printWidth: 120,
1667
+ quoteProps: "as-needed",
1668
+ quotes: "single",
1669
+ semicolons: true,
1670
+ singleAttributePerLine: true,
1671
+ trailingComma: "es5",
1672
+ unicorn: true,
1673
+ ...options.stylistic
1674
+ },
1675
+ typescript
1676
+ };
1677
+ }
1678
+ //#endregion
1679
+ //#region src/factory.ts
1680
+ function hexadrop(optionsOrFlatConfigItem, ...configs) {
1681
+ const options = defaultOptions(optionsOrFlatConfigItem);
1682
+ let pipeline = new FlatConfigComposer(ignore(options), core(options), astro(options), typescript(options), react(options), json(options), markdown(options), imports(options), stylistic(options)).renamePlugins(PLUGIN_RENAME);
1683
+ const flatConfig = extractTypedFlatConfigItem(optionsOrFlatConfigItem);
1684
+ if (flatConfig) pipeline = pipeline.append(flatConfig);
1685
+ pipeline = pipeline.append(...configs);
1686
+ return pipeline;
1687
+ }
1688
+ //#endregion
1689
+ export { combine, hexadrop as default };