@hexadrop/eslint-config 0.1.18 → 0.1.19

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