@brnshkr/config 0.0.1-alpha.10

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.
@@ -0,0 +1,2571 @@
1
+ import { S as version, _ as isModuleEnabled, a as isModuleEnabledByDefault, b as packageOrganization, c as objectFreeze, g as MODULES, i as GLOB_IGNORES, l as objectFromEntries, n as MAX_LEN, o as objectAssign, r as QUOTES, s as objectEntries, t as INDENT, u as objectKeys, v as resolvePackages, x as packageOrganizationUpper, y as setModuleEnabled } from "../shared.mjs";
2
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
3
+ import jsEslint from "@eslint/js";
4
+ import confusingBrowserGlobals from "confusing-browser-globals";
5
+ import globals from "globals";
6
+ import fs from "node:fs/promises";
7
+ import path from "node:path";
8
+
9
+ //#region src/js/eslint/types/scopes.ts
10
+ const MAIN_SCOPES = {
11
+ [packageOrganizationUpper]: "builtin",
12
+ COMMENTS: "comments",
13
+ CSS: "css",
14
+ IGNORES: "ignores",
15
+ IMPORT: "import",
16
+ JAVASCRIPT: "javascript",
17
+ JSDOC: "jsdoc",
18
+ JSON: "json",
19
+ MARKDOWN: "markdown",
20
+ NODE: "node",
21
+ OVERRIDES: "overrides",
22
+ PERFECTIONIST: "perfectionist",
23
+ REGEXP: "regexp",
24
+ STYLE: "style",
25
+ SVELTE: "svelte",
26
+ TEST: "test",
27
+ TOML: "toml",
28
+ TYPESCRIPT: "typescript",
29
+ UNICORN: "unicorn",
30
+ USERLAND: "userland",
31
+ YAML: "yaml"
32
+ };
33
+ const SUB_SCOPES = {
34
+ BASE: "base",
35
+ DEVELOPMENT: "development",
36
+ EXAMPLES: "examples",
37
+ GIT: "git",
38
+ GLOBAL: "global",
39
+ PARSER: "parser",
40
+ PROCESSOR: "processor",
41
+ RULES: "rules",
42
+ SETUP: "setup",
43
+ UNNAMED: "unnamed"
44
+ };
45
+
46
+ //#endregion
47
+ //#region src/js/eslint/utils/config.ts
48
+ const buildConfigName = (mainScope, subScope) => [
49
+ packageOrganization,
50
+ mainScope,
51
+ subScope
52
+ ].filter(Boolean).join("/");
53
+ const renameRules = (rules, map) => Object.fromEntries(Object.entries(rules ?? {}).map(([key, value]) => {
54
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
55
+ return [key, value];
56
+ }));
57
+ const isValidGlobalAdditionalConfigKey = (key) => [
58
+ "name",
59
+ "languageOptions",
60
+ "linterOptions",
61
+ "processor",
62
+ "plugins",
63
+ "rules",
64
+ "settings"
65
+ ].includes(key);
66
+ const getGlobalAdditionalConfig = (options) => {
67
+ const config = {};
68
+ for (const [key, value] of objectEntries(options)) if (isValidGlobalAdditionalConfigKey(key)) config[key] = value;
69
+ if (Object.keys(config).length === 0) return;
70
+ config.name ??= buildConfigName(MAIN_SCOPES.USERLAND, SUB_SCOPES.GLOBAL);
71
+ return config;
72
+ };
73
+ const ensureNamesForSyncAdditionalConfigs = (additionalConfigs) => {
74
+ const validConfigs = [];
75
+ let currentIndex = 1;
76
+ for (const config of additionalConfigs) {
77
+ if (config instanceof Promise || typeof config.name === "string" && config.name.trim().length > 0) {
78
+ validConfigs.push(config);
79
+ continue;
80
+ }
81
+ validConfigs.push(Object.keys(config).length > 0 ? config : void 0);
82
+ config.name = buildConfigName(MAIN_SCOPES.USERLAND, `${SUB_SCOPES.UNNAMED}-${String(currentIndex)}`);
83
+ currentIndex += 1;
84
+ }
85
+ return validConfigs;
86
+ };
87
+ const getUserConfigs = (resolvedOptions, additionalConfigs) => [getGlobalAdditionalConfig(resolvedOptions), ...ensureNamesForSyncAdditionalConfigs(additionalConfigs)];
88
+
89
+ //#endregion
90
+ //#region src/js/eslint/utils/globs.ts
91
+ const GLOB_CJS = "**/*.cjs";
92
+ const GLOB_TS = "**/*.?(c|m)ts?(x)";
93
+ const GLOB_DTS = "**/*.d.?(c|m)ts";
94
+ const GLOB_SVELTE = "**/*.svelte";
95
+ const GLOB_SVELTE_SCRIPT = "**/*.svelte.[jt]s";
96
+ const GLOB_JSON = "**/*.json";
97
+ const GLOB_JSONC = "**/*.jsonc";
98
+ const GLOB_JSON5 = "**/*.json5";
99
+ const GLOB_YAML = "**/*.y?(a)ml";
100
+ const GLOB_TOML = "**/*.toml";
101
+ const GLOB_CSS = "**/*.css";
102
+ const GLOB_MD = "**/*.md";
103
+ const GLOB_EXAMPLES = "**/*.md/*.js";
104
+ const GLOB_SCRIPT_FILES = [
105
+ "**/*.?(c|m)[jt]s?(x)",
106
+ GLOB_DTS,
107
+ GLOB_SVELTE,
108
+ GLOB_SVELTE_SCRIPT
109
+ ];
110
+ const GLOB_SCRIPT_FILES_WITHOUT_TS = ["**/*.?(c|m)js?(x)", GLOB_DTS];
111
+ const GLOB_DEVELOPMENT_FILES = [
112
+ "**/*.config.?(c|m)[jt]s",
113
+ "**/{conf,tests}/**",
114
+ "**/types/declarations/reset.d.ts"
115
+ ];
116
+ const GLOB_TEST_FILES = [
117
+ "**/__tests__/**/*.?(c|m)[jt]s",
118
+ "**/*.spec.?(c|m)[jt]s",
119
+ "**/*.test.?(c|m)[jt]s",
120
+ "**/*.bench.?(c|m)[jt]s",
121
+ "**/*.benchmark.?(c|m)[jt]s"
122
+ ];
123
+
124
+ //#endregion
125
+ //#region src/js/eslint/configs/builtin.ts
126
+ const FILE_TYPE_MAP = {
127
+ ".json": "json",
128
+ ".css": "css",
129
+ ".svg": "svg",
130
+ ".png": "image",
131
+ ".jpg": "image",
132
+ ".jpeg": "image",
133
+ ".txt": "text",
134
+ ".oct": "bytes",
135
+ ".wasm": "webassembly"
136
+ };
137
+ const MESSAGE_ID_MISSING_WITH_KEYWORD = "missingWithKeyword";
138
+ const MESSAGE_ID_MISSING_TYPE_PROPERTY = "missingTypeProperty";
139
+ const MESSAGE_ID_WRONG_TYPE_VALUE = "wrongTypeValue";
140
+ const requireImportAttributesRule = {
141
+ meta: {
142
+ type: "problem",
143
+ docs: { description: "Require non-JavaScript imports (e.g. .json and .css) to include import attributes." },
144
+ messages: {
145
+ [MESSAGE_ID_MISSING_WITH_KEYWORD]: "Non-JavaScript import ('{{ extension }}') requires an import attributes object with the 'type' property set to '{{ expectedValue }}'.",
146
+ [MESSAGE_ID_MISSING_TYPE_PROPERTY]: "Import attributes for non-JavaScript imports must include the 'type' property.",
147
+ [MESSAGE_ID_WRONG_TYPE_VALUE]: "Import attribute 'type' for '{{ file }}' must be '{{ expectedValue }}'."
148
+ }
149
+ },
150
+ create: (context) => ({ ImportDeclaration: (node$1) => {
151
+ const sourceValue = node$1.source.value;
152
+ const extensionIndex = sourceValue.lastIndexOf(".");
153
+ if (extensionIndex === -1) return;
154
+ const extension = sourceValue.slice(extensionIndex).toLowerCase();
155
+ const expectedValue = FILE_TYPE_MAP[extension];
156
+ if (expectedValue === void 0) return;
157
+ const { attributes } = node$1;
158
+ if (attributes.length === 0) {
159
+ context.report({
160
+ node: node$1,
161
+ messageId: MESSAGE_ID_MISSING_WITH_KEYWORD,
162
+ data: {
163
+ extension,
164
+ expectedValue
165
+ }
166
+ });
167
+ return;
168
+ }
169
+ const typeProperty = attributes.find((attribute) => attribute.key.type === "Identifier" && "name" in attribute.key && attribute.key.name === "type" || attribute.key.type === "Literal" && "value" in attribute.key && attribute.key.value === "type");
170
+ if (!typeProperty) {
171
+ context.report({
172
+ node: node$1,
173
+ messageId: MESSAGE_ID_MISSING_TYPE_PROPERTY
174
+ });
175
+ return;
176
+ }
177
+ if (typeProperty.value.value !== expectedValue) context.report({
178
+ node: node$1,
179
+ messageId: MESSAGE_ID_WRONG_TYPE_VALUE,
180
+ data: {
181
+ expectedValue,
182
+ file: sourceValue
183
+ }
184
+ });
185
+ } })
186
+ };
187
+ const RULE_DEFINITIONS = { "require-import-attributes": requireImportAttributesRule };
188
+ const RULES = objectFreeze(objectFromEntries(objectKeys(RULE_DEFINITIONS).map((ruleName) => [`${packageOrganization}/${ruleName}`, "error"])));
189
+ const builtin = () => [{
190
+ name: buildConfigName(MAIN_SCOPES[packageOrganizationUpper], SUB_SCOPES.SETUP),
191
+ plugins: { [packageOrganization]: {
192
+ meta: {
193
+ name: packageOrganization,
194
+ version
195
+ },
196
+ rules: RULE_DEFINITIONS
197
+ } }
198
+ }, {
199
+ name: buildConfigName(MAIN_SCOPES[packageOrganizationUpper], SUB_SCOPES.RULES),
200
+ files: GLOB_SCRIPT_FILES,
201
+ rules: RULES
202
+ }];
203
+ const builtinConfig = { [packageOrganization]: builtin };
204
+
205
+ //#endregion
206
+ //#region src/js/eslint/configs/comments.ts
207
+ const comments = async () => {
208
+ const { requiredAll: [pluginComments] } = await resolvePackages(MODULES.comments);
209
+ if (!pluginComments) return [];
210
+ const recommendedConfig = pluginComments.configs.recommended;
211
+ const recommendedRules = "rules" in recommendedConfig ? recommendedConfig.rules : void 0;
212
+ return [{
213
+ name: buildConfigName(MAIN_SCOPES.COMMENTS, SUB_SCOPES.SETUP),
214
+ plugins: { comments: pluginComments }
215
+ }, {
216
+ name: buildConfigName(MAIN_SCOPES.COMMENTS, SUB_SCOPES.RULES),
217
+ files: GLOB_SCRIPT_FILES,
218
+ rules: {
219
+ ...renameRules(recommendedRules, { "@eslint-community/eslint-comments": "comments" }),
220
+ "comments/no-unused-disable": "error",
221
+ "comments/require-description": "error"
222
+ }
223
+ }];
224
+ };
225
+
226
+ //#endregion
227
+ //#region src/js/eslint/configs/css.ts
228
+ const css = async () => {
229
+ const { requiredAll: [pluginCss] } = await resolvePackages(MODULES.css);
230
+ if (!pluginCss) return [];
231
+ return [{
232
+ name: buildConfigName(MAIN_SCOPES.CSS, SUB_SCOPES.SETUP),
233
+ plugins: { css: pluginCss }
234
+ }, {
235
+ name: buildConfigName(MAIN_SCOPES.CSS, SUB_SCOPES.RULES),
236
+ files: [GLOB_CSS],
237
+ language: "css/css",
238
+ rules: {
239
+ ...pluginCss.configs.recommended.rules,
240
+ "css/prefer-logical-properties": "error",
241
+ "css/relative-font-units": ["error", { allowUnits: ["em", "rem"] }],
242
+ "css/use-baseline": "error"
243
+ }
244
+ }];
245
+ };
246
+
247
+ //#endregion
248
+ //#region src/js/eslint/configs/gitignore.ts
249
+ const gitignore = async (options) => {
250
+ const { requiredAll: [pluginGitignore] } = await resolvePackages(MODULES.gitignore);
251
+ if (!pluginGitignore) return [];
252
+ return [pluginGitignore({
253
+ name: buildConfigName(MAIN_SCOPES.IGNORES, SUB_SCOPES.GIT),
254
+ ...options
255
+ })];
256
+ };
257
+
258
+ //#endregion
259
+ //#region src/js/eslint/configs/ignores.ts
260
+ const ignores = (customIgnores = []) => [{
261
+ name: buildConfigName(MAIN_SCOPES.IGNORES, SUB_SCOPES.BASE),
262
+ ignores: [...GLOB_IGNORES, ...customIgnores]
263
+ }];
264
+
265
+ //#endregion
266
+ //#region src/js/eslint/configs/import.ts
267
+ const imports = async () => {
268
+ const { requiredAny: [pluginImport, pluginAntfu], optional: [importResovlerTypescript] } = await resolvePackages(MODULES.import);
269
+ const plugins = {};
270
+ const settings = {};
271
+ let pluginImportRules = {};
272
+ let pluginAntfuRules = {};
273
+ if (pluginImport) {
274
+ plugins["import"] = pluginImport;
275
+ settings["import-x/resolver-next"] = [pluginImport.createNodeResolver(), importResovlerTypescript === void 0 ? void 0 : importResovlerTypescript.createTypeScriptImportResolver({ bun: true })].filter(Boolean);
276
+ const pluginImportTsRules = isModuleEnabled(MODULES.typescript) ? renameRules(pluginImport.flatConfigs.typescript.rules, { "import-x": "import" }) : {};
277
+ pluginImportRules = {
278
+ ...renameRules(pluginImport.flatConfigs.recommended.rules, { "import-x": "import" }),
279
+ ...pluginImportTsRules,
280
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
281
+ "import/extensions": [
282
+ "error",
283
+ "ignorePackages",
284
+ {
285
+ js: "never",
286
+ ts: "never",
287
+ cts: "never",
288
+ mts: "never"
289
+ }
290
+ ],
291
+ "import/first": "error",
292
+ "import/max-dependencies": ["error", { max: 15 }],
293
+ "import/newline-after-import": "error",
294
+ "import/no-absolute-path": "error",
295
+ "import/no-amd": "error",
296
+ "import/no-cycle": ["error", { maxDepth: 3 }],
297
+ "import/no-default-export": "error",
298
+ "import/no-deprecated": "error",
299
+ "import/no-duplicates": "error",
300
+ "import/no-dynamic-require": "error",
301
+ "import/no-empty-named-blocks": "error",
302
+ "import/no-extraneous-dependencies": ["error", { devDependencies: GLOB_DEVELOPMENT_FILES }],
303
+ "import/no-import-module-exports": "error",
304
+ "import/no-mutable-exports": "error",
305
+ "import/no-named-as-default-member": "error",
306
+ "import/no-named-as-default": "error",
307
+ "import/no-named-default": "error",
308
+ "import/no-namespace": "error",
309
+ "import/no-relative-packages": "error",
310
+ "import/no-rename-default": "error",
311
+ "import/no-self-import": "error",
312
+ "import/no-unassigned-import": ["error", { allow: ["**/*.{css,scss}"] }],
313
+ "import/no-useless-path-segments": ["error", { noUselessIndex: true }],
314
+ "import/no-unresolved": ["error", {
315
+ commonjs: true,
316
+ caseSensitive: true
317
+ }],
318
+ "import/no-webpack-loader-syntax": "error",
319
+ "import/order": ["error", {
320
+ warnOnUnassignedImports: true,
321
+ sortTypesGroup: true,
322
+ consolidateIslands: "inside-groups",
323
+ "newlines-between": "always-and-inside-groups",
324
+ "newlines-between-types": "never",
325
+ named: {
326
+ enabled: true,
327
+ types: "types-last"
328
+ },
329
+ alphabetize: {
330
+ order: "asc",
331
+ caseInsensitive: true
332
+ },
333
+ groups: [
334
+ "builtin",
335
+ "external",
336
+ "unknown",
337
+ "internal",
338
+ "parent",
339
+ "sibling",
340
+ "index",
341
+ "object",
342
+ "type"
343
+ ],
344
+ pathGroups: [{
345
+ pattern: "**/*.{css,scss}",
346
+ group: "object"
347
+ }]
348
+ }],
349
+ "import/unambiguous": "error"
350
+ };
351
+ }
352
+ if (pluginAntfu) {
353
+ plugins["antfu"] = pluginAntfu;
354
+ pluginAntfuRules = {
355
+ "antfu/import-dedupe": "error",
356
+ "antfu/no-import-dist": "error",
357
+ "antfu/no-import-node-modules-by-path": "error"
358
+ };
359
+ }
360
+ if (Object.keys(plugins).length === 0) return [];
361
+ const setupConfig = {
362
+ name: buildConfigName(MAIN_SCOPES.IMPORT, SUB_SCOPES.SETUP),
363
+ plugins
364
+ };
365
+ if (Object.keys(settings).length > 0) setupConfig.settings = settings;
366
+ return [setupConfig, {
367
+ name: buildConfigName(MAIN_SCOPES.IMPORT, SUB_SCOPES.RULES),
368
+ files: GLOB_SCRIPT_FILES,
369
+ rules: {
370
+ ...pluginImportRules,
371
+ ...pluginAntfuRules
372
+ }
373
+ }];
374
+ };
375
+
376
+ //#endregion
377
+ //#region src/js/eslint/configs/javascript.ts
378
+ const javascript = async () => {
379
+ const { optional: [pluginAntfu, pluginUnusedImports] } = await resolvePackages(MODULES.javascript);
380
+ const plugins = {};
381
+ const pluginRules = {};
382
+ if (pluginAntfu) {
383
+ plugins["antfu"] = pluginAntfu;
384
+ pluginRules["antfu/consistent-chaining"] = "error";
385
+ pluginRules["antfu/no-ts-export-equal"] = "error";
386
+ }
387
+ if (pluginUnusedImports) {
388
+ plugins["unused"] = pluginUnusedImports;
389
+ pluginRules["unused/no-unused-imports"] = "error";
390
+ pluginRules["unused/no-unused-vars"] = isModuleEnabled(MODULES.typescript) ? "off" : "error";
391
+ }
392
+ return [{
393
+ name: buildConfigName(MAIN_SCOPES.JAVASCRIPT, SUB_SCOPES.SETUP),
394
+ plugins,
395
+ languageOptions: {
396
+ ecmaVersion: "latest",
397
+ globals: {
398
+ ...globals.browser,
399
+ ...globals.es2025,
400
+ ...globals.node
401
+ },
402
+ sourceType: "module",
403
+ parserOptions: {
404
+ sourceType: "module",
405
+ ecmaVersion: "latest",
406
+ ecmaFeatures: { jsx: true }
407
+ }
408
+ },
409
+ linterOptions: { reportUnusedDisableDirectives: "error" }
410
+ }, {
411
+ name: buildConfigName(MAIN_SCOPES.JAVASCRIPT, SUB_SCOPES.RULES),
412
+ files: GLOB_SCRIPT_FILES,
413
+ rules: {
414
+ ...jsEslint.configs.recommended.rules,
415
+ ...pluginUnusedImports ? { "no-unused-vars": "off" } : void 0,
416
+ "accessor-pairs": "error",
417
+ "array-callback-return": ["error", { checkForEach: true }],
418
+ "arrow-body-style": ["error", "as-needed"],
419
+ "block-scoped-var": "error",
420
+ "capitalized-comments": [
421
+ "error",
422
+ "always",
423
+ {
424
+ block: { ignoreInlineComments: true },
425
+ line: { ignorePattern: ".*" }
426
+ }
427
+ ],
428
+ "class-methods-use-this": ["error", { ignoreOverrideMethods: true }],
429
+ complexity: ["error", {
430
+ max: 10,
431
+ variant: "modified"
432
+ }],
433
+ "consistent-return": "error",
434
+ "consistent-this": "error",
435
+ curly: "error",
436
+ "default-case": "error",
437
+ "default-case-last": "error",
438
+ "default-param-last": "error",
439
+ "dot-notation": "error",
440
+ eqeqeq: "error",
441
+ "func-name-matching": ["error", {
442
+ considerPropertyDescriptor: true,
443
+ includeCommonJSModuleExports: true
444
+ }],
445
+ "func-names": "error",
446
+ "func-style": ["error", "expression"],
447
+ "grouped-accessor-pairs": "error",
448
+ "guard-for-in": "error",
449
+ "init-declarations": "error",
450
+ "logical-assignment-operators": "error",
451
+ "max-classes-per-file": "error",
452
+ "max-depth": "error",
453
+ "max-lines": ["error", {
454
+ max: 300,
455
+ skipBlankLines: true,
456
+ skipComments: true
457
+ }],
458
+ "max-lines-per-function": ["error", {
459
+ IIFEs: true,
460
+ max: 50,
461
+ skipBlankLines: true,
462
+ skipComments: true
463
+ }],
464
+ "max-nested-callbacks": ["error", { max: 3 }],
465
+ "max-params": ["error", { max: 4 }],
466
+ "max-statements": ["error", { max: 30 }],
467
+ "new-cap": "error",
468
+ "no-alert": "error",
469
+ "no-array-constructor": "error",
470
+ "no-await-in-loop": "error",
471
+ "no-bitwise": "error",
472
+ "no-caller": "error",
473
+ "no-cond-assign": ["error", "always"],
474
+ "no-console": "error",
475
+ "no-constructor-return": "error",
476
+ "no-div-regex": "error",
477
+ "no-duplicate-imports": isModuleEnabled(MODULES.import) ? "off" : ["error", { allowSeparateTypeImports: true }],
478
+ "no-else-return": ["error", { allowElseIf: false }],
479
+ "no-empty-function": "error",
480
+ "no-eq-null": "error",
481
+ "no-eval": "error",
482
+ "no-extend-native": "error",
483
+ "no-extra-bind": "error",
484
+ "no-extra-label": "error",
485
+ "no-implicit-coercion": ["error", { boolean: false }],
486
+ "no-implicit-globals": "error",
487
+ "no-implied-eval": "error",
488
+ "no-inline-comments": "error",
489
+ "no-inner-declarations": "error",
490
+ "no-invalid-this": "error",
491
+ "no-iterator": "error",
492
+ "no-label-var": "error",
493
+ "no-labels": "error",
494
+ "no-lone-blocks": "error",
495
+ "no-lonely-if": "error",
496
+ "no-loop-func": "error",
497
+ "no-magic-numbers": ["error", { ignore: [
498
+ -1,
499
+ 0,
500
+ 1,
501
+ 100,
502
+ 42069
503
+ ] }],
504
+ "no-multi-assign": "error",
505
+ "no-multi-str": "error",
506
+ "no-negated-condition": "error",
507
+ "no-nested-ternary": "error",
508
+ "no-new": "error",
509
+ "no-new-func": "error",
510
+ "no-new-wrappers": "error",
511
+ "no-object-constructor": "error",
512
+ "no-octal-escape": "error",
513
+ "no-param-reassign": ["error", { props: false }],
514
+ "no-plusplus": "error",
515
+ "no-promise-executor-return": "error",
516
+ "no-proto": "error",
517
+ "no-restricted-exports": ["error", { restrictedNamedExports: ["default"] }],
518
+ "no-restricted-globals": [
519
+ "error",
520
+ "global",
521
+ ...confusingBrowserGlobals
522
+ ],
523
+ "no-restricted-properties": [
524
+ "error",
525
+ {
526
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
527
+ property: "__proto__"
528
+ },
529
+ {
530
+ message: "Use the `get` syntax or `Object.defineProperty` instead.",
531
+ property: "__defineGetter__"
532
+ },
533
+ {
534
+ message: "Use the `set` syntax or `Object.defineProperty` instead.",
535
+ property: "__defineSetter__"
536
+ },
537
+ {
538
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
539
+ property: "__lookupGetter__"
540
+ },
541
+ {
542
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
543
+ property: "__lookupSetter__"
544
+ }
545
+ ],
546
+ "no-restricted-syntax": [
547
+ "error",
548
+ {
549
+ selector: "ForInStatement",
550
+ message: "`for..in` loops include inherited properties, leading to unexpected behavior. Use Object.{keys, values, entries} for safe iteration or explicitly disable this rule to make the intent clear."
551
+ },
552
+ {
553
+ selector: "TSEnumDeclaration",
554
+ message: "TypeScript enums can lead to less predictable type behavior. Use a constant object literal (`const MY_ENUM = <const>{ VALUE1: 1, VALUE2: 2 };`) and add a type for it (`type MyEnum = typeof MY_ENUM[keyof typeof MY_ENUM];`) instead to ensure stricter typing control and better code clarity."
555
+ },
556
+ {
557
+ selector: "TSExportAssignment",
558
+ message: "TypeScript export assignments should be avoided for consistency and maintainability. Use a default export instead to align with modern module standards and to avoid potential import/export issues."
559
+ }
560
+ ],
561
+ "no-return-assign": ["error", "always"],
562
+ "no-script-url": "error",
563
+ "no-self-compare": "error",
564
+ "no-sequences": "error",
565
+ "no-shadow": "error",
566
+ "no-template-curly-in-string": "error",
567
+ "no-throw-literal": "error",
568
+ "no-unassigned-vars": "error",
569
+ "no-underscore-dangle": "error",
570
+ "no-unmodified-loop-condition": "error",
571
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
572
+ "no-unreachable-loop": "error",
573
+ "no-unused-expressions": "error",
574
+ "no-use-before-define": "error",
575
+ "no-useless-assignment": "error",
576
+ "no-useless-call": "error",
577
+ "no-useless-computed-key": "error",
578
+ "no-useless-concat": "error",
579
+ "no-useless-constructor": "error",
580
+ "no-useless-rename": "error",
581
+ "no-useless-return": "error",
582
+ "no-var": "error",
583
+ "no-void": "error",
584
+ "no-warning-comments": "error",
585
+ "object-shorthand": [
586
+ "error",
587
+ "always",
588
+ {
589
+ avoidQuotes: true,
590
+ ignoreConstructors: false
591
+ }
592
+ ],
593
+ "operator-assignment": "error",
594
+ "prefer-arrow-callback": "error",
595
+ "prefer-const": ["error", { ignoreReadBeforeAssign: true }],
596
+ "prefer-destructuring": "error",
597
+ "prefer-exponentiation-operator": "error",
598
+ "prefer-named-capture-group": "error",
599
+ "prefer-numeric-literals": "error",
600
+ "prefer-object-has-own": "error",
601
+ "prefer-object-spread": "error",
602
+ "prefer-promise-reject-errors": "error",
603
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
604
+ "prefer-rest-params": "error",
605
+ "prefer-spread": "error",
606
+ "prefer-template": "error",
607
+ "preserve-caught-error": "error",
608
+ radix: "error",
609
+ "require-atomic-updates": "error",
610
+ "require-await": "error",
611
+ strict: "error",
612
+ "symbol-description": "error",
613
+ "unicode-bom": "error",
614
+ "use-isnan": ["error", { enforceForIndexOf: true }],
615
+ "valid-typeof": ["error", { requireStringLiterals: true }],
616
+ "vars-on-top": "error",
617
+ yoda: "error",
618
+ ...pluginRules
619
+ }
620
+ }];
621
+ };
622
+
623
+ //#endregion
624
+ //#region src/js/eslint/configs/typescript.ts
625
+ const DEFAULT_TYPE_AWARE_IGNORES = [`${GLOB_MD}/**`];
626
+ const getTsEslintParserIfExists = async () => {
627
+ const isTypescriptModuleEnabled = isModuleEnabled(MODULES.typescript);
628
+ let parser = void 0;
629
+ if (isTypescriptModuleEnabled) {
630
+ const { requiredAll: [, tsEslint] } = await resolvePackages(MODULES.typescript);
631
+ if (tsEslint) ({parser} = tsEslint);
632
+ }
633
+ return parser;
634
+ };
635
+ const resolveTypeAwareOptions = (resolvedOptions, files, ignores$1) => {
636
+ const typeAwareOptions = typeof resolvedOptions.typeAware === "object" ? resolvedOptions.typeAware : {
637
+ ignores: DEFAULT_TYPE_AWARE_IGNORES,
638
+ tsconfig: typeof resolvedOptions.typeAware === "string" ? resolvedOptions.typeAware : void 0
639
+ };
640
+ typeAwareOptions.files = [...new Set([...typeAwareOptions.files ?? [], ...files])];
641
+ typeAwareOptions.ignores = [...new Set([...typeAwareOptions.ignores ?? [], ...ignores$1])];
642
+ return typeAwareOptions;
643
+ };
644
+ const extractRelevantRules = (configs$1, key) => {
645
+ for (const config of configs$1) if (config.name === `typescript-eslint/${key}` && config.rules) return renameRules(config.rules, { "@typescript-eslint": "ts" });
646
+ throw new Error(`Expected key "${key}" to be contained in given config.`);
647
+ };
648
+ const getNamingConvention = (isTypeAware) => {
649
+ const ruleOptions = [
650
+ "error",
651
+ {
652
+ selector: "default",
653
+ format: [
654
+ "strictCamelCase",
655
+ "StrictPascalCase",
656
+ "UPPER_CASE"
657
+ ],
658
+ leadingUnderscore: "forbid",
659
+ trailingUnderscore: "forbid"
660
+ },
661
+ {
662
+ selector: ["objectLiteralProperty", "variable"],
663
+ format: ["strictCamelCase", "UPPER_CASE"]
664
+ },
665
+ {
666
+ selector: "variable",
667
+ format: null,
668
+ modifiers: ["destructured"]
669
+ },
670
+ {
671
+ selector: "typeLike",
672
+ format: ["StrictPascalCase"]
673
+ },
674
+ {
675
+ selector: "parameter",
676
+ format: null,
677
+ filter: {
678
+ regex: "^_+$",
679
+ match: false
680
+ }
681
+ },
682
+ {
683
+ selector: [
684
+ "classProperty",
685
+ "objectLiteralProperty",
686
+ "typeProperty",
687
+ "classMethod",
688
+ "objectLiteralMethod",
689
+ "typeMethod",
690
+ "accessor",
691
+ "enumMember"
692
+ ],
693
+ format: null,
694
+ modifiers: ["requiresQuotes"]
695
+ },
696
+ {
697
+ selector: "typeParameter",
698
+ format: ["StrictPascalCase"],
699
+ prefix: ["T"],
700
+ custom: {
701
+ regex: "^[A-Z]",
702
+ match: true
703
+ }
704
+ },
705
+ {
706
+ selector: "interface",
707
+ format: ["StrictPascalCase"],
708
+ custom: {
709
+ regex: "^I[A-Z]",
710
+ match: false
711
+ }
712
+ }
713
+ ];
714
+ if (isTypeAware) ruleOptions.push({
715
+ selector: "variable",
716
+ types: ["boolean"],
717
+ format: ["StrictPascalCase"],
718
+ prefix: [
719
+ "is",
720
+ "does",
721
+ "do",
722
+ "did",
723
+ "has",
724
+ "was",
725
+ "can"
726
+ ]
727
+ });
728
+ return ruleOptions;
729
+ };
730
+ const typescript = async (options) => {
731
+ const { requiredAll: [isTypescriptInstalled, tsEslint] } = await resolvePackages(MODULES.typescript);
732
+ if (!isTypescriptInstalled || !tsEslint) return [];
733
+ const cwd = process.cwd();
734
+ let hasTsConfig = false;
735
+ try {
736
+ await fs.access(path.resolve(cwd, "tsconfig.json"), fs.constants.R_OK);
737
+ hasTsConfig = true;
738
+ } catch {}
739
+ const resolvedOptions = {
740
+ extraFileExtensions: [],
741
+ parserOptions: {},
742
+ typeAware: hasTsConfig,
743
+ ...options
744
+ };
745
+ const ignores$1 = resolvedOptions.ignores ?? [];
746
+ const files = [...new Set([...resolvedOptions.extraFileExtensions.map((extension) => `**/*.${extension}`), ...resolvedOptions.files ?? GLOB_SCRIPT_FILES])];
747
+ const hasEnabledTypeAwareness = resolvedOptions.typeAware !== false;
748
+ const typeAwareOptions = hasEnabledTypeAwareness ? resolveTypeAwareOptions(resolvedOptions, files, ignores$1) : {};
749
+ const createParserConfig = (isTypeAware) => ({
750
+ name: buildConfigName(MAIN_SCOPES.TYPESCRIPT, `${SUB_SCOPES.PARSER}${isTypeAware ? "-type-aware" : ""}`),
751
+ files: isTypeAware ? typeAwareOptions.files : files,
752
+ ignores: isTypeAware ? typeAwareOptions.ignores : ignores$1,
753
+ languageOptions: {
754
+ parser: tsEslint.parser,
755
+ parserOptions: {
756
+ extraFileExtensions: resolvedOptions.extraFileExtensions.map((extension) => `.${extension}`),
757
+ ...isTypeAware ? {
758
+ tsconfigRootDir: cwd,
759
+ projectService: { defaultProject: typeAwareOptions.tsconfig }
760
+ } : {},
761
+ ...resolvedOptions.parserOptions
762
+ }
763
+ }
764
+ });
765
+ const createRulesConfig = (isTypeAware) => ({
766
+ name: buildConfigName(MAIN_SCOPES.TYPESCRIPT, `${SUB_SCOPES.RULES}${isTypeAware ? "-type-aware" : ""}`),
767
+ files: isTypeAware ? typeAwareOptions.files : files,
768
+ ignores: isTypeAware ? typeAwareOptions.ignores : ignores$1,
769
+ rules: {
770
+ "ts/naming-convention": getNamingConvention(isTypeAware),
771
+ ...isTypeAware ? {
772
+ ...extractRelevantRules(tsEslint.configs.recommendedTypeCheckedOnly, "recommended-type-checked-only"),
773
+ ...extractRelevantRules(tsEslint.configs.strictTypeCheckedOnly, "strict-type-checked-only"),
774
+ ...extractRelevantRules(tsEslint.configs.stylisticTypeCheckedOnly, "stylistic-type-checked-only"),
775
+ "consistent-return": "off",
776
+ "ts/consistent-return": "error",
777
+ "ts/consistent-type-exports": "error",
778
+ "ts/no-unnecessary-qualifier": "error",
779
+ "prefer-destructuring": "off",
780
+ "ts/prefer-destructuring": "error",
781
+ "ts/no-unnecessary-type-conversion": "error",
782
+ "ts/promise-function-async": "error",
783
+ "ts/prefer-readonly": "error",
784
+ "ts/require-array-sort-compare": "error",
785
+ "ts/strict-boolean-expressions": "error",
786
+ "ts/strict-void-return": "error",
787
+ "ts/switch-exhaustiveness-check": ["error", { requireDefaultForNonUnion: true }]
788
+ } : {
789
+ ...extractRelevantRules(tsEslint.configs.recommended, "recommended"),
790
+ ...extractRelevantRules(tsEslint.configs.strict, "strict"),
791
+ ...extractRelevantRules(tsEslint.configs.stylistic, "stylistic"),
792
+ "ts/consistent-type-assertions": ["error", { assertionStyle: "angle-bracket" }],
793
+ "ts/consistent-type-imports": "error",
794
+ "ts/member-ordering": "error",
795
+ "ts/method-signature-style": "error",
796
+ "ts/no-import-type-side-effects": "error",
797
+ "no-redeclare": "off",
798
+ "ts/no-redeclare": "error",
799
+ "ts/no-unnecessary-parameter-property-assignment": "error",
800
+ "no-unused-private-class-members": "off",
801
+ "ts/no-unused-private-class-members": "error",
802
+ "ts/no-useless-empty-export": "error",
803
+ "ts/prefer-enum-initializers": "error"
804
+ }
805
+ }
806
+ });
807
+ return [
808
+ {
809
+ name: buildConfigName(MAIN_SCOPES.TYPESCRIPT, SUB_SCOPES.SETUP),
810
+ plugins: { ts: tsEslint.plugin }
811
+ },
812
+ createParserConfig(false),
813
+ hasEnabledTypeAwareness ? createParserConfig(true) : void 0,
814
+ createRulesConfig(false),
815
+ hasEnabledTypeAwareness ? createRulesConfig(true) : void 0,
816
+ {
817
+ name: buildConfigName(MAIN_SCOPES.TYPESCRIPT, `${SUB_SCOPES.RULES}-typescript`),
818
+ files: [GLOB_TS],
819
+ ignores: typeAwareOptions.ignores ?? ignores$1,
820
+ rules: {
821
+ "ts/explicit-function-return-type": "error",
822
+ "ts/explicit-member-accessibility": "error"
823
+ }
824
+ }
825
+ ].filter(Boolean);
826
+ };
827
+
828
+ //#endregion
829
+ //#region src/js/eslint/configs/jsdoc.ts
830
+ const jsdoc = async () => {
831
+ const { requiredAll: [pluginJsdoc], optional: [getJsdocProcessorPlugin] } = await resolvePackages(MODULES.jsdoc);
832
+ if (!pluginJsdoc) return [];
833
+ const createSetupConfig = (isForTypescript) => ({
834
+ name: buildConfigName(MAIN_SCOPES.JSDOC, `${SUB_SCOPES.SETUP}${isForTypescript ? "-typescript" : ""}`),
835
+ ...isForTypescript ? void 0 : { plugins: { jsdoc: pluginJsdoc } },
836
+ settings: { jsdoc: { mode: isForTypescript ? "typescript" : "jsdoc" } }
837
+ });
838
+ const createRulesConfig = (isForTypescript) => ({
839
+ name: buildConfigName(MAIN_SCOPES.JSDOC, `${SUB_SCOPES.RULES}${isForTypescript ? "-typescript" : ""}`),
840
+ files: isForTypescript ? [GLOB_TS] : [GLOB_TS, ...GLOB_SCRIPT_FILES_WITHOUT_TS],
841
+ rules: { ...isForTypescript ? {
842
+ ...Object.fromEntries(objectEntries(pluginJsdoc.configs["flat/recommended-typescript-error"].rules ?? {}).map(([key, value]) => Object.is(pluginJsdoc.configs["flat/recommended-error"].rules?.[key], value) ? void 0 : [key, value]).filter(Boolean)),
843
+ "jsdoc/require-param": "off",
844
+ "jsdoc/require-returns": "off"
845
+ } : {
846
+ ...pluginJsdoc.configs["flat/recommended-error"].rules,
847
+ "jsdoc/check-indentation": ["error", { allowIndentedSections: true }],
848
+ "jsdoc/check-line-alignment": "error",
849
+ "jsdoc/check-syntax": "error",
850
+ "jsdoc/check-template-names": "error",
851
+ "jsdoc/convert-to-jsdoc-comments": ["error", { lineOrBlockStyle: "block" }],
852
+ "jsdoc/imports-as-dependencies": "error",
853
+ "jsdoc/informative-docs": ["error", { excludedTags: ["default"] }],
854
+ "jsdoc/match-description": "error",
855
+ "jsdoc/multiline-blocks": ["error", {
856
+ noSingleLineBlocks: true,
857
+ singleLineTags: []
858
+ }],
859
+ "jsdoc/no-bad-blocks": "error",
860
+ "jsdoc/no-blank-block-descriptions": "error",
861
+ "jsdoc/no-blank-blocks": "error",
862
+ "jsdoc/prefer-import-tag": "error",
863
+ "jsdoc/require-description-complete-sentence": "error",
864
+ "jsdoc/require-asterisk-prefix": "error",
865
+ "jsdoc/require-hyphen-before-param-description": "error",
866
+ "jsdoc/require-param-description": "off",
867
+ "jsdoc/require-property-description": "off",
868
+ "jsdoc/require-returns-description": "off",
869
+ "jsdoc/require-jsdoc": "off",
870
+ "jsdoc/require-template": "error",
871
+ "jsdoc/require-throws": "error",
872
+ "jsdoc/sort-tags": ["error", { tagSequence: [
873
+ { tags: ["import"] },
874
+ { tags: [
875
+ "deprecated",
876
+ "ignore",
877
+ "since",
878
+ "version",
879
+ ["to", "do"].join("")
880
+ ] },
881
+ { tags: [
882
+ "author",
883
+ "copyright",
884
+ "license"
885
+ ] },
886
+ { tags: ["summary", "typeSummary"] },
887
+ { tags: [
888
+ "desc",
889
+ "description",
890
+ "classdesc"
891
+ ] },
892
+ { tags: [
893
+ "internal",
894
+ "namespace",
895
+ "category",
896
+ "package",
897
+ "file",
898
+ "fileoverview",
899
+ "overview",
900
+ "module",
901
+ "override",
902
+ "requires",
903
+ "implements",
904
+ "mixes",
905
+ "mixin",
906
+ "mixinClass",
907
+ "mixinFunction",
908
+ "borrows",
909
+ "constructs",
910
+ "lends",
911
+ "final",
912
+ "global",
913
+ "readonly",
914
+ "abstract",
915
+ "virtual",
916
+ "static",
917
+ "private",
918
+ "protected",
919
+ "public",
920
+ "access",
921
+ "const",
922
+ "constant",
923
+ "variation",
924
+ "var",
925
+ "member",
926
+ "memberof",
927
+ "inner",
928
+ "instance",
929
+ "inheritdoc",
930
+ "inheritDoc",
931
+ "hideconstructor"
932
+ ] },
933
+ { tags: [
934
+ "this",
935
+ "interface",
936
+ "enum",
937
+ "event",
938
+ "augments",
939
+ "extends",
940
+ "name",
941
+ "kind",
942
+ "type",
943
+ "alias",
944
+ "external",
945
+ "host",
946
+ "async",
947
+ "callback",
948
+ "func",
949
+ "function",
950
+ "method",
951
+ "class",
952
+ "constructor",
953
+ "generator",
954
+ "fires",
955
+ "emits",
956
+ "listens"
957
+ ] },
958
+ { tags: ["template"] },
959
+ { tags: ["typedef"] },
960
+ { tags: [
961
+ "param",
962
+ "arg",
963
+ "argument",
964
+ "prop",
965
+ "property"
966
+ ] },
967
+ { tags: ["return", "returns"] },
968
+ { tags: ["yield", "yields"] },
969
+ { tags: ["throws", "exception"] },
970
+ { tags: ["satisfies"] },
971
+ { tags: ["default", "defaultvalue"] },
972
+ { tags: ["exports"] },
973
+ { tags: ["see", "tutorial"] },
974
+ { tags: ["example"] }
975
+ ] }],
976
+ "jsdoc/tag-lines": [
977
+ "error",
978
+ "any",
979
+ {
980
+ maxBlockLines: 1,
981
+ startLines: 1
982
+ }
983
+ ],
984
+ "jsdoc/text-escaping": ["error", { escapeHTML: true }],
985
+ "jsdoc/ts-method-signature-style": "error",
986
+ "jsdoc/ts-no-unnecessary-template-expression": "error",
987
+ "jsdoc/ts-prefer-function-type": "error"
988
+ } }
989
+ });
990
+ const parser = await getTsEslintParserIfExists();
991
+ const examplePlugin = getJsdocProcessorPlugin ? getJsdocProcessorPlugin.getJsdocProcessorPlugin({
992
+ checkDefaults: true,
993
+ checkExamples: true,
994
+ checkParams: true,
995
+ checkProperties: true,
996
+ parser
997
+ }) : void 0;
998
+ return [
999
+ createSetupConfig(false),
1000
+ parser ? createSetupConfig(true) : void 0,
1001
+ createRulesConfig(false),
1002
+ parser ? createRulesConfig(true) : void 0,
1003
+ ...examplePlugin ? [{
1004
+ name: buildConfigName(MAIN_SCOPES.JSDOC, `${SUB_SCOPES.EXAMPLES}/${SUB_SCOPES.SETUP}`),
1005
+ plugins: { examples: examplePlugin }
1006
+ }, {
1007
+ name: buildConfigName(MAIN_SCOPES.JSDOC, `${SUB_SCOPES.EXAMPLES}/${SUB_SCOPES.PROCESSOR}`),
1008
+ files: GLOB_SCRIPT_FILES,
1009
+ processor: examplePlugin.processors?.["examples"]
1010
+ }] : []
1011
+ ].filter(Boolean);
1012
+ };
1013
+
1014
+ //#endregion
1015
+ //#region src/js/eslint/configs/json.ts
1016
+ const TSCONFIG_FILES = ["**/tsconfig.json", "**/tsconfig.*.json"];
1017
+ const JSON_FILES_TO_TREAT_AS_JSONC = [...TSCONFIG_FILES, ".vscode/**/*.json"];
1018
+ const LANGUAGE_TO_GLOB_MAP = {
1019
+ json: [GLOB_JSON],
1020
+ jsonc: [GLOB_JSONC, ...JSON_FILES_TO_TREAT_AS_JSONC],
1021
+ json5: [GLOB_JSON5]
1022
+ };
1023
+ const extractAllRules = (configs$1) => {
1024
+ const rules = {};
1025
+ for (const config of configs$1) if (config.rules) objectAssign(rules, config.rules);
1026
+ return rules;
1027
+ };
1028
+ const getJsoncSortConfigs = () => [
1029
+ {
1030
+ name: buildConfigName(MAIN_SCOPES.JSON, `${SUB_SCOPES.RULES}-sort-package-json`),
1031
+ files: ["**/package.json"],
1032
+ rules: {
1033
+ "jsonc/sort-array-values": ["error", {
1034
+ pathPattern: "^files$",
1035
+ order: { type: "asc" }
1036
+ }],
1037
+ "jsonc/sort-keys": [
1038
+ "error",
1039
+ {
1040
+ pathPattern: "^$",
1041
+ order: [
1042
+ "$schema",
1043
+ "jscpd",
1044
+ "jspm",
1045
+ "name",
1046
+ "version",
1047
+ "description",
1048
+ "license",
1049
+ "private",
1050
+ "author",
1051
+ "homepage",
1052
+ "man",
1053
+ "readme",
1054
+ "repository",
1055
+ "bugs",
1056
+ "funding",
1057
+ "type",
1058
+ "packageManager",
1059
+ "bundleDependencies",
1060
+ "os",
1061
+ "cpu",
1062
+ "libc",
1063
+ "engines",
1064
+ "devEngines",
1065
+ "browserslist",
1066
+ "scripts",
1067
+ "esnext",
1068
+ "module",
1069
+ "pnpm",
1070
+ "main",
1071
+ "browser",
1072
+ "dist",
1073
+ "bin",
1074
+ "types",
1075
+ "typings",
1076
+ "typesVersions",
1077
+ "imports",
1078
+ "exports",
1079
+ "files",
1080
+ "directories",
1081
+ "dependencies",
1082
+ "peerDependencies",
1083
+ "peerDependenciesMeta",
1084
+ "optionalDependencies",
1085
+ "devDependencies",
1086
+ "patchedDependencies",
1087
+ "overrides",
1088
+ "resolutions",
1089
+ "workspaces",
1090
+ "maintainers",
1091
+ "contributors",
1092
+ "keywords",
1093
+ "config",
1094
+ "publishConfig",
1095
+ "release",
1096
+ "husky",
1097
+ "simple-git-hooks",
1098
+ "lint-staged",
1099
+ "eslintConfig",
1100
+ "stylelint",
1101
+ "prettier",
1102
+ "ava",
1103
+ "stackblitz",
1104
+ "volta"
1105
+ ]
1106
+ },
1107
+ {
1108
+ pathPattern: "^exports.*$",
1109
+ order: [
1110
+ "default",
1111
+ "import",
1112
+ "require",
1113
+ "types"
1114
+ ]
1115
+ },
1116
+ {
1117
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$",
1118
+ order: { type: "asc" }
1119
+ },
1120
+ {
1121
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$",
1122
+ order: { type: "asc" }
1123
+ },
1124
+ {
1125
+ pathPattern: "^contributors.*$",
1126
+ order: [
1127
+ "name",
1128
+ "email",
1129
+ "url"
1130
+ ]
1131
+ },
1132
+ {
1133
+ pathPattern: "^(?:husky|simple-git-hooks)$",
1134
+ order: [
1135
+ "pre-commit",
1136
+ "prepare-commit-msg",
1137
+ "commit-msg",
1138
+ "post-commit",
1139
+ "pre-rebase",
1140
+ "post-rewrite",
1141
+ "post-checkout",
1142
+ "post-merge",
1143
+ "pre-push",
1144
+ "pre-auto-gc"
1145
+ ]
1146
+ }
1147
+ ]
1148
+ }
1149
+ },
1150
+ {
1151
+ name: buildConfigName(MAIN_SCOPES.JSON, `${SUB_SCOPES.RULES}-sort-composer-json`),
1152
+ files: ["**/composer.json"],
1153
+ rules: { "jsonc/sort-keys": [
1154
+ "error",
1155
+ {
1156
+ pathPattern: "^$",
1157
+ order: [
1158
+ "$schema",
1159
+ "name",
1160
+ "version",
1161
+ "time",
1162
+ "description",
1163
+ "_comment",
1164
+ "license",
1165
+ "authors",
1166
+ "abandoned",
1167
+ "homepage",
1168
+ "readme",
1169
+ "support",
1170
+ "funding",
1171
+ "type",
1172
+ "scripts",
1173
+ "bin",
1174
+ "require",
1175
+ "require-dev",
1176
+ "replace",
1177
+ "provide",
1178
+ "conflict",
1179
+ "suggest",
1180
+ "autoload",
1181
+ "autoload-dev",
1182
+ "include-path",
1183
+ "target-dir",
1184
+ "extra",
1185
+ "minimum-stability",
1186
+ "prefer-stable",
1187
+ "config",
1188
+ "repositories",
1189
+ "archive",
1190
+ "keywords"
1191
+ ]
1192
+ },
1193
+ {
1194
+ pathPattern: "^authors.*$",
1195
+ order: [
1196
+ "name",
1197
+ "role",
1198
+ "email",
1199
+ "homepage"
1200
+ ]
1201
+ },
1202
+ {
1203
+ pathPattern: "^require|require-dev|replace|provide|conflict|suggest$",
1204
+ order: [
1205
+ { keyPattern: "^php$" },
1206
+ { keyPattern: "^ext-(.+)$" },
1207
+ { order: { type: "asc" } }
1208
+ ]
1209
+ },
1210
+ {
1211
+ pathPattern: "autoload(-dev)?",
1212
+ order: [
1213
+ "psr-0",
1214
+ "psr-4",
1215
+ "classmap",
1216
+ "files",
1217
+ "exclude-from-classmap"
1218
+ ]
1219
+ },
1220
+ {
1221
+ pathPattern: "^extra$",
1222
+ order: { type: "asc" }
1223
+ },
1224
+ {
1225
+ pathPattern: "^config$",
1226
+ order: [
1227
+ "platform",
1228
+ "platform-check",
1229
+ "allow-missing-requirements",
1230
+ "bin-compat",
1231
+ "bump-after-update",
1232
+ "classmap-authoritative",
1233
+ "discard-changes",
1234
+ "lock",
1235
+ "notify-on-install",
1236
+ "preferred-install",
1237
+ "sort-packages",
1238
+ "apcu-autoloader",
1239
+ "autoloader-suffix",
1240
+ "prepend-autoloader",
1241
+ "optimize-autoloader",
1242
+ "process-timeout",
1243
+ "store-auths",
1244
+ "allow-plugins",
1245
+ "use-include-path",
1246
+ "use-parent-dir",
1247
+ "archive-format",
1248
+ "archive-dir",
1249
+ "vendor-dir",
1250
+ "bin-dir",
1251
+ "data-dir",
1252
+ "cache-dir",
1253
+ "cache-files-dir",
1254
+ "cache-repo-dir",
1255
+ "cache-vcs-dir",
1256
+ "cache-files-ttl",
1257
+ "cache-files-maxsize",
1258
+ "cache-read-only",
1259
+ "audit",
1260
+ "htaccess-protect",
1261
+ "disable-tls",
1262
+ "secure-http",
1263
+ "cafile",
1264
+ "capath",
1265
+ "http-basic",
1266
+ "bearer",
1267
+ "use-github-api",
1268
+ "github-expose-hostname",
1269
+ "github-protocols",
1270
+ "bitbucket-oauth",
1271
+ "secure-svn-domains",
1272
+ "github-oauth",
1273
+ "github-domains",
1274
+ "gitlab-token",
1275
+ "gitlab-protocol",
1276
+ "gitlab-oauth",
1277
+ "gitlab-domains"
1278
+ ]
1279
+ }
1280
+ ] }
1281
+ },
1282
+ {
1283
+ name: buildConfigName(MAIN_SCOPES.JSON, `${SUB_SCOPES.RULES}-sort-tsconfig-json`),
1284
+ files: TSCONFIG_FILES,
1285
+ rules: {
1286
+ "jsonc/sort-array-values": ["error", {
1287
+ pathPattern: "^(?:files|include|exclude)$",
1288
+ order: { type: "asc" }
1289
+ }],
1290
+ "jsonc/sort-keys": [
1291
+ "error",
1292
+ {
1293
+ pathPattern: "^$",
1294
+ order: [
1295
+ "$schema",
1296
+ "extends",
1297
+ "references",
1298
+ "files",
1299
+ "include",
1300
+ "exclude",
1301
+ "compilerOptions",
1302
+ "watchOptions",
1303
+ "typeAcquisition"
1304
+ ]
1305
+ },
1306
+ {
1307
+ pathPattern: "^compilerOptions$",
1308
+ order: [
1309
+ "emitDecoratorMetadata",
1310
+ "experimentalDecorators",
1311
+ "jsx",
1312
+ "jsxFactory",
1313
+ "jsxFragmentFactory",
1314
+ "jsxImportSource",
1315
+ "lib",
1316
+ "libReplacement",
1317
+ "moduleDetection",
1318
+ "noLib",
1319
+ "reactNamespace",
1320
+ "target",
1321
+ "useDefineForClassFields",
1322
+ "incremental",
1323
+ "composite",
1324
+ "tsBuildInfoFile",
1325
+ "disableReferencedProjectLoad",
1326
+ "disableSolutionSearching",
1327
+ "disableSourceOfProjectReferenceRedirect",
1328
+ "allowArbitraryExtensions",
1329
+ "allowImportingTsExtensions",
1330
+ "allowUmdGlobalAccess",
1331
+ "baseUrl",
1332
+ "customConditions",
1333
+ "module",
1334
+ "moduleResolution",
1335
+ "moduleSuffixes",
1336
+ "noResolve",
1337
+ "noUncheckedSideEffectImports",
1338
+ "paths",
1339
+ "resolveJsonModule",
1340
+ "resolvePackageJsonExports",
1341
+ "resolvePackageJsonImports",
1342
+ "rewriteRelativeImportExtensions",
1343
+ "rootDir",
1344
+ "rootDirs",
1345
+ "typeRoots",
1346
+ "types",
1347
+ "declaration",
1348
+ "declarationDir",
1349
+ "declarationMap",
1350
+ "downlevelIteration",
1351
+ "emitBOM",
1352
+ "emitDeclarationOnly",
1353
+ "importHelpers",
1354
+ "inlineSourceMap",
1355
+ "inlineSources",
1356
+ "mapRoot",
1357
+ "newLine",
1358
+ "noEmit",
1359
+ "noEmitHelpers",
1360
+ "noEmitOnError",
1361
+ "outDir",
1362
+ "outFile",
1363
+ "preserveConstEnums",
1364
+ "removeComments",
1365
+ "sourceMap",
1366
+ "sourceRoot",
1367
+ "stripInternal",
1368
+ "skipDefaultLibCheck",
1369
+ "skipLibCheck",
1370
+ "noErrorTruncation",
1371
+ "preserveWatchOutput",
1372
+ "pretty",
1373
+ "assumeChangesOnlyAffectDirectDependencies",
1374
+ "allowJs",
1375
+ "checkJs",
1376
+ "maxNodeModuleJsDepth",
1377
+ "allowSyntheticDefaultImports",
1378
+ "erasableSyntaxOnly",
1379
+ "esModuleInterop",
1380
+ "forceConsistentCasingInFileNames",
1381
+ "isolatedDeclarations",
1382
+ "isolatedModules",
1383
+ "preserveSymlinks",
1384
+ "verbatimModuleSyntax",
1385
+ "allowUnreachableCode",
1386
+ "allowUnusedLabels",
1387
+ "alwaysStrict",
1388
+ "exactOptionalPropertyTypes",
1389
+ "noFallthroughCasesInSwitch",
1390
+ "noImplicitAny",
1391
+ "noImplicitOverride",
1392
+ "noImplicitReturns",
1393
+ "noImplicitThis",
1394
+ "noPropertyAccessFromIndexSignature",
1395
+ "noUncheckedIndexedAccess",
1396
+ "noUnusedLocals",
1397
+ "noUnusedParameters",
1398
+ "strict",
1399
+ "strictBindCallApply",
1400
+ "strictBuiltinIteratorReturn",
1401
+ "strictFunctionTypes",
1402
+ "strictNullChecks",
1403
+ "strictPropertyInitialization",
1404
+ "useUnknownInCatchVariables",
1405
+ "diagnostics",
1406
+ "explainFiles",
1407
+ "extendedDiagnostics",
1408
+ "generateCpuProfile",
1409
+ "generateTrace",
1410
+ "listEmittedFiles",
1411
+ "listFiles",
1412
+ "noCheck",
1413
+ "traceResolution",
1414
+ "charset",
1415
+ "importsNotUsedAsValues",
1416
+ "keyofStringsOnly",
1417
+ "noImplicitUseStrict",
1418
+ "noStrictGenericChecks",
1419
+ "out",
1420
+ "preserveValueImports",
1421
+ "suppressExcessPropertyErrors",
1422
+ "suppressImplicitAnyIndexErrors",
1423
+ "disableSizeLimit",
1424
+ "plugins"
1425
+ ]
1426
+ },
1427
+ {
1428
+ pathPattern: "^watchOptions$",
1429
+ order: [
1430
+ "watchFile",
1431
+ "watchDirectory",
1432
+ "fallbackPolling",
1433
+ "synchronousWatchDirectory",
1434
+ "excludeDirectories ",
1435
+ "excludeFiles"
1436
+ ]
1437
+ },
1438
+ {
1439
+ pathPattern: "^typeAcquisition$",
1440
+ order: [
1441
+ "enable",
1442
+ "include",
1443
+ "exclude",
1444
+ "disableFilenameBasedTypeAcquisition"
1445
+ ]
1446
+ }
1447
+ ]
1448
+ }
1449
+ }
1450
+ ];
1451
+ const json = async () => {
1452
+ const { requiredAll: [pluginJson], optional: [pluginJsonc, parserJsonc] } = await resolvePackages(MODULES.json);
1453
+ if (!pluginJson) return [];
1454
+ const createRulesConfig = (language) => ({
1455
+ name: buildConfigName(MAIN_SCOPES.JSON, `${SUB_SCOPES.RULES}-${language}`),
1456
+ language: `json/${language}`,
1457
+ files: LANGUAGE_TO_GLOB_MAP[language],
1458
+ ...language === "json" ? { ignores: JSON_FILES_TO_TREAT_AS_JSONC } : void 0,
1459
+ rules: {
1460
+ ...pluginJson.configs.recommended.rules,
1461
+ ...pluginJsonc ? extractAllRules(pluginJsonc.configs[`flat/recommended-with-${language}`]) : void 0,
1462
+ ...pluginJsonc ? {
1463
+ "jsonc/array-bracket-newline": ["error", "consistent"],
1464
+ "jsonc/array-bracket-spacing": "error",
1465
+ "jsonc/comma-style": "error",
1466
+ "jsonc/indent": ["error", INDENT],
1467
+ "jsonc/key-spacing": "error",
1468
+ "jsonc/no-irregular-whitespace": "error",
1469
+ "jsonc/no-octal-escape": "error",
1470
+ "jsonc/object-curly-newline": "error",
1471
+ "jsonc/object-curly-spacing": ["error", "always"],
1472
+ "jsonc/object-property-newline": "error",
1473
+ "jsonc/quotes": ["error", "double"]
1474
+ } : void 0
1475
+ }
1476
+ });
1477
+ const plugins = { json: pluginJson };
1478
+ let jsoncSortConfigs = [];
1479
+ if (pluginJsonc) {
1480
+ plugins["jsonc"] = pluginJsonc;
1481
+ jsoncSortConfigs = getJsoncSortConfigs();
1482
+ }
1483
+ return [
1484
+ {
1485
+ name: buildConfigName(MAIN_SCOPES.JSON, SUB_SCOPES.SETUP),
1486
+ plugins
1487
+ },
1488
+ parserJsonc ? {
1489
+ name: buildConfigName(MAIN_SCOPES.JSON, SUB_SCOPES.PARSER),
1490
+ files: [
1491
+ GLOB_JSON,
1492
+ GLOB_JSONC,
1493
+ GLOB_JSON5
1494
+ ],
1495
+ languageOptions: { parser: parserJsonc }
1496
+ } : void 0,
1497
+ createRulesConfig("json"),
1498
+ createRulesConfig("jsonc"),
1499
+ ...jsoncSortConfigs,
1500
+ createRulesConfig("json5")
1501
+ ].filter(Boolean);
1502
+ };
1503
+
1504
+ //#endregion
1505
+ //#region src/js/eslint/configs/markdown.ts
1506
+ const extractRelevantValues = (identifier, configs$1, key) => {
1507
+ for (const config of configs$1) if (config.name === `markdown/${key}` && config[identifier] !== void 0 && config[identifier] !== null) return config[identifier];
1508
+ throw new Error(`Expected key "${key}" to be contained in given config.`);
1509
+ };
1510
+ const markdown = async (options) => {
1511
+ const { requiredAll: [pluginMarkdown, eslintMergeProcessors] } = await resolvePackages(MODULES.markdown);
1512
+ if (!pluginMarkdown || !eslintMergeProcessors) return [];
1513
+ const language = options?.language ?? "markdown/commonmark";
1514
+ const frontmatter = options?.frontmatter ?? false;
1515
+ const { mergeProcessors, processorPassThrough } = eslintMergeProcessors;
1516
+ return [
1517
+ {
1518
+ name: buildConfigName(MAIN_SCOPES.MARKDOWN, SUB_SCOPES.SETUP),
1519
+ plugins: { markdown: pluginMarkdown }
1520
+ },
1521
+ {
1522
+ name: buildConfigName(MAIN_SCOPES.MARKDOWN, SUB_SCOPES.PROCESSOR),
1523
+ files: [GLOB_MD],
1524
+ processor: mergeProcessors([pluginMarkdown.processors.markdown, processorPassThrough])
1525
+ },
1526
+ {
1527
+ name: buildConfigName(MAIN_SCOPES.MARKDOWN, SUB_SCOPES.RULES),
1528
+ files: [GLOB_MD],
1529
+ language,
1530
+ languageOptions: { frontmatter },
1531
+ rules: {
1532
+ ...extractRelevantValues("rules", pluginMarkdown.configs.recommended, "recommended"),
1533
+ "markdown/no-bare-urls": "error",
1534
+ "markdown/no-duplicate-headings": ["error", { checkSiblingsOnly: true }],
1535
+ "markdown/no-html": ["error", { allowed: [
1536
+ "a",
1537
+ "br",
1538
+ "dd",
1539
+ "del",
1540
+ "details",
1541
+ "div",
1542
+ "dl",
1543
+ "dt",
1544
+ "h1",
1545
+ "img",
1546
+ "ins",
1547
+ "kbd",
1548
+ "p",
1549
+ "q",
1550
+ "rp",
1551
+ "rt",
1552
+ "ruby",
1553
+ "samp",
1554
+ "sub",
1555
+ "summary",
1556
+ "sup",
1557
+ "var"
1558
+ ] }]
1559
+ }
1560
+ },
1561
+ {
1562
+ name: buildConfigName(MAIN_SCOPES.MARKDOWN, `${SUB_SCOPES.RULES}-code-blocks`),
1563
+ files: extractRelevantValues("files", pluginMarkdown.configs.processor, "recommended/code-blocks"),
1564
+ languageOptions: extractRelevantValues("languageOptions", pluginMarkdown.configs.processor, "recommended/code-blocks"),
1565
+ rules: {
1566
+ ...extractRelevantValues("rules", pluginMarkdown.configs.processor, "recommended/code-blocks"),
1567
+ "no-alert": "off",
1568
+ "no-console": "off",
1569
+ "no-inline-comments": "off",
1570
+ "import/no-default-export": "off",
1571
+ "import/unambiguous": "off",
1572
+ "node/no-missing-import": "off",
1573
+ "ts/no-redeclare": "off",
1574
+ "ts/no-unused-vars": "off",
1575
+ "unused/no-unused-imports": "off",
1576
+ "unused/no-unused-vars": "off"
1577
+ }
1578
+ }
1579
+ ];
1580
+ };
1581
+
1582
+ //#endregion
1583
+ //#region src/js/eslint/configs/node.ts
1584
+ const node = async (options) => {
1585
+ const { requiredAll: [pluginNode] } = await resolvePackages(MODULES.node);
1586
+ if (!pluginNode) return [];
1587
+ return [{
1588
+ name: buildConfigName(MAIN_SCOPES.NODE, SUB_SCOPES.SETUP),
1589
+ plugins: { node: pluginNode },
1590
+ settings: { n: { version: options?.version ?? process.versions.node } }
1591
+ }, {
1592
+ name: buildConfigName(MAIN_SCOPES.NODE, SUB_SCOPES.RULES),
1593
+ files: GLOB_SCRIPT_FILES,
1594
+ rules: {
1595
+ ...renameRules(pluginNode.configs["flat/recommended"].rules, { n: "node" }),
1596
+ "node/exports-style": "error",
1597
+ "node/global-require": "error",
1598
+ "node/handle-callback-err": "error",
1599
+ "node/no-missing-import": "error",
1600
+ "node/no-mixed-requires": "error",
1601
+ "node/no-new-require": "error",
1602
+ "node/no-path-concat": "error",
1603
+ "node/no-process-env": "error",
1604
+ "node/no-sync": "error",
1605
+ "node/prefer-global/buffer": "error",
1606
+ "node/prefer-global/console": "error",
1607
+ "node/prefer-global/process": "error",
1608
+ "node/prefer-global/text-decoder": "error",
1609
+ "node/prefer-global/text-encoder": "error",
1610
+ "node/prefer-global/url-search-params": "error",
1611
+ "node/prefer-global/url": "error",
1612
+ "node/prefer-node-protocol": "error",
1613
+ "node/prefer-promises/dns": "error",
1614
+ "node/prefer-promises/fs": "error"
1615
+ }
1616
+ }];
1617
+ };
1618
+
1619
+ //#endregion
1620
+ //#region src/js/eslint/configs/unicorn.ts
1621
+ const FILE_NAMES_TO_IGNORE = [
1622
+ "ACKNOWLEDGMENTS.md",
1623
+ "ADOPTERS.md",
1624
+ "AGENTS.md",
1625
+ "API_REFERENCE.md",
1626
+ "ARCHITECTURE.md",
1627
+ "AUTHORS.md",
1628
+ "BUILD.md",
1629
+ "CHANGELOG.md",
1630
+ "CODE_OF_CONDUCT.md",
1631
+ "CODEOWNERS.md",
1632
+ "CODING_STANDARDS.md",
1633
+ "COMMUNITY_GUIDELINES.md",
1634
+ "CONFIGURATION.md",
1635
+ "CONTRIBUTING.md",
1636
+ "CONTRIBUTORS.md",
1637
+ "DATA_CARD.md",
1638
+ "DATA_MODEL.md",
1639
+ "DATA_PRIVACY.md",
1640
+ "DEPENDENCIES.md",
1641
+ "DESIGN.md",
1642
+ "DEVELOPMENT.md",
1643
+ "ETHICS.md",
1644
+ "EVALUATION.md",
1645
+ "FAQ.md",
1646
+ "GOVERNANCE.md",
1647
+ "INSTALL.md",
1648
+ "ISSUE_TEMPLATE.md",
1649
+ "LICENSE.md",
1650
+ "LLMS.md",
1651
+ "LOCALIZATION.md",
1652
+ "MAINTAINERS.md",
1653
+ "MEETING_NOTES.md",
1654
+ "MIGRATIONS.md",
1655
+ "ML_LIFECYCLE.md",
1656
+ "ML_PIPELINE.md",
1657
+ "MLOPS.md",
1658
+ "MODEL_CARD.md",
1659
+ "MODEL_MONITORING.md",
1660
+ "NFR.md",
1661
+ "OVERVIEW.md",
1662
+ "PERFORMANCE.md",
1663
+ "PROJECT_METADATA.md",
1664
+ "PULL_REQUEST_TEMPLATE.md",
1665
+ "README.md",
1666
+ "REFERENCES.md",
1667
+ "RELEASE_PROCESS.md",
1668
+ "RELEASING.md",
1669
+ "RESEARCH.md",
1670
+ "ROADMAP.md",
1671
+ "SPEC.md",
1672
+ "SECURITY_POLICY.md",
1673
+ "SECURITY.md",
1674
+ "STYLE_GUIDE.md",
1675
+ "SUPPORT.md",
1676
+ "TESTING.md",
1677
+ "THIRD_PARTY.md",
1678
+ "THREAT_MODEL.md",
1679
+ "TROUBLESHOOTING.md",
1680
+ "UPGRADE_NOTES.md",
1681
+ "VERSIONING.md"
1682
+ ];
1683
+ const unicorn = async () => {
1684
+ const { requiredAll: [pluginUnicorn] } = await resolvePackages(MODULES.unicorn);
1685
+ if (!pluginUnicorn) return [];
1686
+ return [{
1687
+ name: buildConfigName(MAIN_SCOPES.UNICORN, SUB_SCOPES.SETUP),
1688
+ plugins: { unicorn: pluginUnicorn }
1689
+ }, {
1690
+ name: buildConfigName(MAIN_SCOPES.UNICORN, SUB_SCOPES.RULES),
1691
+ files: GLOB_SCRIPT_FILES,
1692
+ rules: {
1693
+ ...pluginUnicorn.configs.recommended.rules,
1694
+ "unicorn/better-regex": "error",
1695
+ "unicorn/consistent-destructuring": "error",
1696
+ "unicorn/custom-error-definition": "error",
1697
+ "unicorn/filename-case": ["error", {
1698
+ case: "kebabCase",
1699
+ ignore: FILE_NAMES_TO_IGNORE
1700
+ }],
1701
+ "unicorn/require-post-message-target-origin": "error",
1702
+ "unicorn/no-keyword-prefix": "error",
1703
+ "unicorn/no-nested-ternay": "off",
1704
+ "no-nested-ternary": "error",
1705
+ "unicorn/no-unused-properties": "error",
1706
+ "unicorn/prefer-json-parse-buffer": "error",
1707
+ "unicorn/prefer-switch": "off",
1708
+ "unicorn/string-content": ["error", { patterns: {
1709
+ "\\.\\.\\.": "…",
1710
+ "^http:\\/\\/": String.raw`^https:\/\/`
1711
+ } }]
1712
+ }
1713
+ }];
1714
+ };
1715
+
1716
+ //#endregion
1717
+ //#region src/js/eslint/configs/overrides.ts
1718
+ const jsOverrides = [{
1719
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.JAVASCRIPT}/scripts`),
1720
+ files: ["scripts/**/*.?(c)js"],
1721
+ languageOptions: {
1722
+ sourceType: "script",
1723
+ parserOptions: { sourceType: "script" }
1724
+ },
1725
+ rules: {
1726
+ "no-console": "off",
1727
+ strict: ["error", "global"]
1728
+ }
1729
+ }, {
1730
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.JAVASCRIPT}/cjs`),
1731
+ files: [GLOB_CJS],
1732
+ languageOptions: {
1733
+ sourceType: "commonjs",
1734
+ parserOptions: { sourceType: "commonjs" }
1735
+ },
1736
+ rules: {
1737
+ strict: ["error", "global"],
1738
+ "unicorn/prefer-module": "off",
1739
+ "ts/no-require-imports": "off"
1740
+ }
1741
+ }];
1742
+ const tsOverrides = isModuleEnabled(MODULES.typescript) ? [{
1743
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.TYPESCRIPT}/ts`),
1744
+ files: [GLOB_TS],
1745
+ rules: {
1746
+ strict: "off",
1747
+ "node/no-missing-import": "off"
1748
+ }
1749
+ }, {
1750
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.TYPESCRIPT}/dts`),
1751
+ files: [GLOB_DTS],
1752
+ rules: {
1753
+ "max-lines": "off",
1754
+ "no-restricted-syntax": "off",
1755
+ "no-var": "off",
1756
+ "vars-on-top": "off",
1757
+ "comments/no-unlimited-disable": "off",
1758
+ "import/no-extraneous-dependencies": "off",
1759
+ "import/unambiguous": "off",
1760
+ "import/no-default-export": "off",
1761
+ "import/no-named-as-default": "off",
1762
+ "import/no-named-as-default-member": "off"
1763
+ }
1764
+ }] : [];
1765
+ const testOverrides = isModuleEnabled(MODULES.test) ? [{
1766
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.TEST}/general`),
1767
+ files: GLOB_TEST_FILES,
1768
+ rules: { "node/no-sync": "off" }
1769
+ }] : [];
1770
+ const unicornOverrides = isModuleEnabled(MODULES.unicorn) ? [{
1771
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.UNICORN}/general`),
1772
+ files: [...GLOB_SCRIPT_FILES.map((glob) => `**/classes/${glob}`), ...GLOB_SCRIPT_FILES.map((glob) => `**/errors/${glob}`)],
1773
+ rules: { "unicorn/filename-case": ["error", {
1774
+ case: "pascalCase",
1775
+ ignore: FILE_NAMES_TO_IGNORE
1776
+ }] }
1777
+ }] : [];
1778
+ const jsdocOverrides = isModuleEnabled(MODULES.jsdoc) ? [{
1779
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.JSDOC}/${SUB_SCOPES.EXAMPLES}`),
1780
+ files: [GLOB_EXAMPLES],
1781
+ rules: {
1782
+ "no-console": "off",
1783
+ "no-undef": "off",
1784
+ "no-unused-expressions": "off",
1785
+ "no-unused-vars": "off",
1786
+ "node/no-missing-import": "off",
1787
+ "node/no-missing-require": "off",
1788
+ strict: "off",
1789
+ "import/no-unresolved": "off",
1790
+ "import/unambiguous": "off",
1791
+ "style/eol-last": "off",
1792
+ "style/no-multiple-empty-lines": "off",
1793
+ "ts/no-unused-expressions": "off",
1794
+ "ts/no-unused-vars": "off"
1795
+ }
1796
+ }, {
1797
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.JSDOC}/default-expressions`),
1798
+ files: [
1799
+ "**/*.jsdoc-defaults",
1800
+ "**/*.jsdoc-params",
1801
+ "**/*.jsdoc-properties"
1802
+ ],
1803
+ rules: {
1804
+ "no-empty-function": "off",
1805
+ "no-new": "off",
1806
+ strict: "off",
1807
+ "import/unambiguous": "off",
1808
+ "style/eol-last": "off",
1809
+ "style/no-extra-parens": "off",
1810
+ "style/semi": "off"
1811
+ }
1812
+ }] : [];
1813
+ const svelteOverrides = isModuleEnabled(MODULES.svelte) ? [{
1814
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.SVELTE}/general`),
1815
+ files: [GLOB_SVELTE],
1816
+ rules: {
1817
+ "no-inner-declarations": "off",
1818
+ "no-self-assign": "off",
1819
+ "import/no-rename-default": "off",
1820
+ "import/unambiguous": "off",
1821
+ "svelte/comment-directive": ["error", { reportUnusedDisableDirectives: true }],
1822
+ "svelte/system": "error"
1823
+ }
1824
+ }, {
1825
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.SVELTE}/components`),
1826
+ files: [`**/components/${GLOB_SVELTE}`],
1827
+ rules: { "unicorn/filename-case": ["error", { case: "pascalCase" }] }
1828
+ }] : [];
1829
+ const tomlOverrides = isModuleEnabled(MODULES.toml) ? [{
1830
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.TOML}/general`),
1831
+ files: [GLOB_TOML],
1832
+ rules: { "no-irregular-whitespace": "off" }
1833
+ }] : [];
1834
+ const yamlOverrides = isModuleEnabled(MODULES.yaml) ? [{
1835
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, `${MAIN_SCOPES.YAML}/general`),
1836
+ files: [GLOB_YAML],
1837
+ rules: {
1838
+ "no-irregular-whitespace": "off",
1839
+ "no-unused-vars": "off"
1840
+ }
1841
+ }] : [];
1842
+ const overrides = () => [
1843
+ ...jsOverrides,
1844
+ ...tsOverrides,
1845
+ ...testOverrides,
1846
+ ...unicornOverrides,
1847
+ ...jsdocOverrides,
1848
+ ...svelteOverrides,
1849
+ ...tomlOverrides,
1850
+ ...yamlOverrides,
1851
+ {
1852
+ name: buildConfigName(MAIN_SCOPES.OVERRIDES, SUB_SCOPES.DEVELOPMENT),
1853
+ files: GLOB_DEVELOPMENT_FILES,
1854
+ rules: {
1855
+ "max-lines": "off",
1856
+ "max-lines-per-function": "off",
1857
+ "no-irregular-whitespace": "off",
1858
+ "no-restricted-exports": "off",
1859
+ "import/max-dependencies": "off",
1860
+ "import/no-default-export": "off",
1861
+ "import/no-rename-default": "off",
1862
+ "import/no-named-as-default-member": "off",
1863
+ "node/no-sync": "off"
1864
+ }
1865
+ }
1866
+ ];
1867
+
1868
+ //#endregion
1869
+ //#region src/js/eslint/configs/perfectionist.ts
1870
+ const perfectionist = async () => {
1871
+ const { requiredAll: [pluginPerfectionist] } = await resolvePackages(MODULES.perfectionist);
1872
+ if (!pluginPerfectionist) return [];
1873
+ return [{
1874
+ name: buildConfigName(MAIN_SCOPES.PERFECTIONIST, SUB_SCOPES.SETUP),
1875
+ plugins: { perfectionist: pluginPerfectionist }
1876
+ }, {
1877
+ name: buildConfigName(MAIN_SCOPES.PERFECTIONIST, SUB_SCOPES.RULES),
1878
+ files: GLOB_SCRIPT_FILES,
1879
+ rules: {
1880
+ "perfectionist/sort-array-includes": "error",
1881
+ "perfectionist/sort-heritage-clauses": "error",
1882
+ "perfectionist/sort-maps": "error",
1883
+ "perfectionist/sort-named-exports": "error",
1884
+ "perfectionist/sort-sets": "error",
1885
+ "perfectionist/sort-switch-case": "error"
1886
+ }
1887
+ }];
1888
+ };
1889
+
1890
+ //#endregion
1891
+ //#region src/js/eslint/configs/regexp.ts
1892
+ const regexp = async () => {
1893
+ const { requiredAll: [pluginRegExp] } = await resolvePackages(MODULES.regexp);
1894
+ if (!pluginRegExp) return [];
1895
+ return [{
1896
+ name: buildConfigName(MAIN_SCOPES.REGEXP, SUB_SCOPES.SETUP),
1897
+ plugins: { regexp: pluginRegExp }
1898
+ }, {
1899
+ name: buildConfigName(MAIN_SCOPES.REGEXP, SUB_SCOPES.RULES),
1900
+ files: GLOB_SCRIPT_FILES,
1901
+ rules: {
1902
+ ...pluginRegExp.configs.recommended.rules,
1903
+ "regexp/confusing-quantifier": "error",
1904
+ "regexp/grapheme-string-literal": "error",
1905
+ "regexp/letter-case": ["error", {
1906
+ caseInsensitive: "lowercase",
1907
+ unicodeEscape: "lowercase",
1908
+ hexadecimalEscape: "lowercase",
1909
+ controlEscape: "uppercase"
1910
+ }],
1911
+ "regexp/no-control-character": "error",
1912
+ "regexp/no-empty-alternative": "error",
1913
+ "regexp/no-lazy-ends": "error",
1914
+ "regexp/no-octal": "error",
1915
+ "regexp/no-potentially-useless-backreference": "error",
1916
+ "regexp/no-standalone-backslash": "error",
1917
+ "regexp/no-super-linear-move": "error",
1918
+ "regexp/no-useless-flag": "error",
1919
+ "regexp/optimal-lookaround-quantifier": "error",
1920
+ "regexp/prefer-escape-replacement-dollar-char": "error",
1921
+ "regexp/prefer-lookaround": "error",
1922
+ "regexp/prefer-named-backreference": "error",
1923
+ "regexp/prefer-named-capture-group": "error",
1924
+ "regexp/prefer-named-replacement": "error",
1925
+ "regexp/prefer-quantifier": "error",
1926
+ "regexp/prefer-regexp-exec": "error",
1927
+ "regexp/prefer-regexp-test": "error",
1928
+ "regexp/prefer-result-array-groups": "error",
1929
+ "regexp/require-unicode-sets-regexp": "error",
1930
+ "regexp/sort-alternatives": "error",
1931
+ "regexp/sort-character-class-elements": "error",
1932
+ "regexp/unicode-escape": "error",
1933
+ "regexp/unicode-property": ["error", {
1934
+ generalCategory: "never",
1935
+ key: "short",
1936
+ property: "long"
1937
+ }]
1938
+ }
1939
+ }];
1940
+ };
1941
+
1942
+ //#endregion
1943
+ //#region src/js/eslint/configs/style.ts
1944
+ const style = async () => {
1945
+ const { requiredAll: [pluginStyle] } = await resolvePackages(MODULES.style);
1946
+ if (!pluginStyle) return [];
1947
+ const styleConfig = pluginStyle.configs.customize({
1948
+ jsx: true,
1949
+ semi: true,
1950
+ indent: INDENT,
1951
+ quotes: QUOTES,
1952
+ quoteProps: "as-needed",
1953
+ arrowParens: true,
1954
+ blockSpacing: true,
1955
+ braceStyle: "1tbs",
1956
+ commaDangle: "always-multiline"
1957
+ });
1958
+ const indentRuleConfig = Array.isArray(styleConfig.rules?.["@stylistic/indent"]) && typeof styleConfig.rules["@stylistic/indent"][2] === "object" && styleConfig.rules["@stylistic/indent"][2] !== null ? styleConfig.rules["@stylistic/indent"][2] : void 0;
1959
+ return [{
1960
+ name: buildConfigName(MAIN_SCOPES.STYLE, SUB_SCOPES.SETUP),
1961
+ plugins: { style: pluginStyle }
1962
+ }, {
1963
+ name: buildConfigName(MAIN_SCOPES.STYLE, SUB_SCOPES.RULES),
1964
+ files: GLOB_SCRIPT_FILES,
1965
+ rules: {
1966
+ ...renameRules(styleConfig.rules, { "@stylistic": "style" }),
1967
+ "style/array-bracket-newline": ["error", "consistent"],
1968
+ "style/array-element-newline": ["error", "consistent"],
1969
+ "style/function-call-argument-newline": ["error", "consistent"],
1970
+ "style/function-call-spacing": "error",
1971
+ "style/function-paren-newline": ["error", "multiline-arguments"],
1972
+ "style/generator-star-spacing": ["error", {
1973
+ before: false,
1974
+ after: true,
1975
+ method: "before",
1976
+ shorthand: "neither"
1977
+ }],
1978
+ "style/implicit-arrow-linebreak": "error",
1979
+ "style/indent": [
1980
+ "error",
1981
+ INDENT,
1982
+ {
1983
+ ...indentRuleConfig,
1984
+ offsetTernaryExpressions: false
1985
+ }
1986
+ ],
1987
+ "style/jsx-child-element-spacing": "error",
1988
+ "style/jsx-pascal-case": "error",
1989
+ "style/jsx-self-closing-comp": "error",
1990
+ "style/line-comment-position": "error",
1991
+ "style/linebreak-style": "error",
1992
+ "style/lines-around-comment": ["error", {
1993
+ beforeBlockComment: false,
1994
+ afterHashbangComment: true,
1995
+ allowBlockStart: true,
1996
+ allowObjectStart: true,
1997
+ allowArrayStart: true,
1998
+ allowClassStart: true,
1999
+ allowEnumStart: true,
2000
+ allowInterfaceStart: true,
2001
+ allowModuleStart: true,
2002
+ allowTypeStart: true
2003
+ }],
2004
+ "style/max-len": ["error", {
2005
+ code: MAX_LEN,
2006
+ tabWidth: INDENT,
2007
+ ignoreUrls: true,
2008
+ ignoreStrings: true,
2009
+ ignoreComments: true
2010
+ }],
2011
+ "style/newline-per-chained-call": "error",
2012
+ "style/no-confusing-arrow": "error",
2013
+ "style/no-extra-parens": [
2014
+ "error",
2015
+ "all",
2016
+ {
2017
+ ignoredNodes: [
2018
+ "ArrowFunctionExpression[body.type=ConditionalExpression]",
2019
+ "SpreadElement[argument.type=ConditionalExpression]",
2020
+ "SpreadElement[argument.type=LogicalExpression]",
2021
+ "SpreadElement[argument.type=AwaitExpression]"
2022
+ ],
2023
+ nestedBinaryExpressions: false,
2024
+ nestedConditionalExpressions: false,
2025
+ ternaryOperandBinaryExpressions: false
2026
+ }
2027
+ ],
2028
+ "style/no-extra-semi": "error",
2029
+ "style/no-mixed-operators": ["error", {
2030
+ allowSamePrecedence: false,
2031
+ groups: [
2032
+ [
2033
+ "+",
2034
+ "-",
2035
+ "*",
2036
+ "/",
2037
+ "%",
2038
+ "**",
2039
+ "??"
2040
+ ],
2041
+ [
2042
+ "&",
2043
+ "|",
2044
+ "^",
2045
+ "~",
2046
+ "<<",
2047
+ ">>",
2048
+ ">>>",
2049
+ "??"
2050
+ ],
2051
+ [
2052
+ "==",
2053
+ "!=",
2054
+ "===",
2055
+ "!==",
2056
+ ">",
2057
+ ">=",
2058
+ "<",
2059
+ "<=",
2060
+ "??"
2061
+ ],
2062
+ [
2063
+ "&&",
2064
+ "||",
2065
+ "?:",
2066
+ "??"
2067
+ ],
2068
+ [
2069
+ "in",
2070
+ "instanceof",
2071
+ "??"
2072
+ ]
2073
+ ]
2074
+ }],
2075
+ "style/nonblock-statement-body-position": ["error", "below"],
2076
+ "style/object-curly-newline": ["error", {
2077
+ ObjectExpression: {
2078
+ minProperties: 4,
2079
+ multiline: true,
2080
+ consistent: true
2081
+ },
2082
+ ObjectPattern: {
2083
+ minProperties: 4,
2084
+ multiline: true,
2085
+ consistent: true
2086
+ },
2087
+ ImportDeclaration: {
2088
+ minProperties: 4,
2089
+ multiline: true,
2090
+ consistent: true
2091
+ },
2092
+ ExportDeclaration: {
2093
+ minProperties: 4,
2094
+ multiline: true,
2095
+ consistent: true
2096
+ }
2097
+ }],
2098
+ "style/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
2099
+ "style/one-var-declaration-per-line": ["error", "always"],
2100
+ "style/operator-linebreak": [
2101
+ "error",
2102
+ "before",
2103
+ { overrides: { "=": "none" } }
2104
+ ],
2105
+ "style/padding-line-between-statements": [
2106
+ "error",
2107
+ {
2108
+ blankLine: "always",
2109
+ prev: "*",
2110
+ next: [
2111
+ "block-like",
2112
+ "block",
2113
+ "break",
2114
+ "class",
2115
+ "continue",
2116
+ "enum",
2117
+ "expression",
2118
+ "function-overload",
2119
+ "interface",
2120
+ "multiline-return",
2121
+ "multiline-const",
2122
+ "multiline-export",
2123
+ "multiline-expression",
2124
+ "multiline-let",
2125
+ "multiline-var",
2126
+ "return",
2127
+ "singleline-const",
2128
+ "singleline-export",
2129
+ "singleline-let",
2130
+ "singleline-var",
2131
+ "throw",
2132
+ "type"
2133
+ ]
2134
+ },
2135
+ {
2136
+ blankLine: "always",
2137
+ next: "*",
2138
+ prev: [
2139
+ "block-like",
2140
+ "block",
2141
+ "class",
2142
+ "directive",
2143
+ "enum",
2144
+ "expression",
2145
+ "interface",
2146
+ "multiline-const",
2147
+ "multiline-export",
2148
+ "multiline-expression",
2149
+ "multiline-let",
2150
+ "multiline-var",
2151
+ "singleline-const",
2152
+ "singleline-export",
2153
+ "singleline-let",
2154
+ "singleline-var"
2155
+ ]
2156
+ },
2157
+ {
2158
+ blankLine: "never",
2159
+ prev: [
2160
+ "singleline-const",
2161
+ "singleline-let",
2162
+ "singleline-var"
2163
+ ],
2164
+ next: [
2165
+ "singleline-const",
2166
+ "singleline-let",
2167
+ "singleline-var"
2168
+ ]
2169
+ },
2170
+ {
2171
+ blankLine: "never",
2172
+ prev: ["singleline-export"],
2173
+ next: ["singleline-export"]
2174
+ },
2175
+ {
2176
+ blankLine: "never",
2177
+ prev: "function-overload",
2178
+ next: ["function", "function-overload"]
2179
+ },
2180
+ {
2181
+ blankLine: "never",
2182
+ prev: "directive",
2183
+ next: "directive"
2184
+ },
2185
+ {
2186
+ blankLine: "any",
2187
+ prev: "expression",
2188
+ next: "expression"
2189
+ },
2190
+ {
2191
+ blankLine: "always",
2192
+ prev: "*",
2193
+ next: "multiline-expression"
2194
+ },
2195
+ {
2196
+ blankLine: "always",
2197
+ prev: "multiline-expression",
2198
+ next: "*"
2199
+ },
2200
+ {
2201
+ blankLine: "never",
2202
+ prev: "type",
2203
+ next: "type"
2204
+ },
2205
+ {
2206
+ blankLine: "always",
2207
+ prev: "multiline-type",
2208
+ next: "type"
2209
+ },
2210
+ {
2211
+ blankLine: "always",
2212
+ prev: "type",
2213
+ next: "multiline-type"
2214
+ },
2215
+ {
2216
+ blankLine: "always",
2217
+ prev: "multiline-type",
2218
+ next: "multiline-type"
2219
+ },
2220
+ {
2221
+ blankLine: "always",
2222
+ prev: "cjs-import",
2223
+ next: ["*"]
2224
+ },
2225
+ {
2226
+ blankLine: "any",
2227
+ prev: "cjs-import",
2228
+ next: "cjs-import"
2229
+ },
2230
+ {
2231
+ blankLine: "always",
2232
+ next: "*",
2233
+ prev: "cjs-export"
2234
+ }
2235
+ ],
2236
+ "style/semi-style": "error",
2237
+ "style/switch-colon-spacing": "error",
2238
+ "style/yield-star-spacing": ["error", {
2239
+ before: false,
2240
+ after: true
2241
+ }]
2242
+ }
2243
+ }];
2244
+ };
2245
+
2246
+ //#endregion
2247
+ //#region src/js/eslint/configs/svelte.ts
2248
+ const extractRelevantConfig = (configs$1, key) => {
2249
+ for (const config of configs$1) if (config.name === `svelte:${key}` && config.rules) return config;
2250
+ throw new Error(`Expected key "${key}" to be contained in given config.`);
2251
+ };
2252
+ const svelte = async () => {
2253
+ const { requiredAll: [isSvelteInstalled, pluginSvelte] } = await resolvePackages(MODULES.svelte);
2254
+ if (!isSvelteInstalled || !pluginSvelte) return [];
2255
+ return [
2256
+ {
2257
+ name: buildConfigName(MAIN_SCOPES.SVELTE, SUB_SCOPES.SETUP),
2258
+ plugins: { svelte: pluginSvelte }
2259
+ },
2260
+ {
2261
+ name: buildConfigName(MAIN_SCOPES.SVELTE, SUB_SCOPES.PARSER),
2262
+ files: [GLOB_SVELTE, GLOB_SVELTE_SCRIPT],
2263
+ languageOptions: {
2264
+ parser: extractRelevantConfig(pluginSvelte.configs["flat/base"], "base:setup-for-svelte").languageOptions?.["parser"],
2265
+ parserOptions: {
2266
+ extraFileExtensions: [".svelte"],
2267
+ parser: await getTsEslintParserIfExists()
2268
+ }
2269
+ }
2270
+ },
2271
+ {
2272
+ name: buildConfigName(MAIN_SCOPES.SVELTE, SUB_SCOPES.PROCESSOR),
2273
+ files: [GLOB_SVELTE],
2274
+ processor: pluginSvelte.processors.svelte
2275
+ },
2276
+ {
2277
+ name: buildConfigName(MAIN_SCOPES.SVELTE, SUB_SCOPES.RULES),
2278
+ files: [GLOB_SVELTE, GLOB_SVELTE_SCRIPT],
2279
+ rules: {
2280
+ ...extractRelevantConfig(pluginSvelte.configs["flat/recommended"], "recommended:rules").rules,
2281
+ "svelte/block-lang": ["error", {
2282
+ enforceScriptPresent: false,
2283
+ enforceStylePresent: false,
2284
+ script: ["ts", null],
2285
+ style: ["scss", null]
2286
+ }],
2287
+ "svelte/button-has-type": "error",
2288
+ "svelte/consistent-selector-style": ["error", {
2289
+ checkGlobal: false,
2290
+ style: [
2291
+ "type",
2292
+ "class",
2293
+ "id"
2294
+ ]
2295
+ }],
2296
+ "svelte/derived-has-same-inputs-outputs": "error",
2297
+ "svelte/experimental-require-strict-events": "error",
2298
+ "svelte/experimental-require-slot-types": "error",
2299
+ "svelte/first-attribute-linebreak": "error",
2300
+ "svelte/html-closing-bracket-new-line": "error",
2301
+ "svelte/html-closing-bracket-spacing": ["error", { selfClosingTag: "never" }],
2302
+ "svelte/html-quotes": "error",
2303
+ "svelte/html-self-closing": ["error", {
2304
+ normal: "ignore",
2305
+ void: "never"
2306
+ }],
2307
+ "style/indent": "off",
2308
+ "svelte/indent": ["error", { indent: INDENT }],
2309
+ "svelte/max-attributes-per-line": ["error", {
2310
+ multiline: 1,
2311
+ singleline: 3
2312
+ }],
2313
+ "svelte/mustache-spacing": "error",
2314
+ "svelte/no-add-event-listener": "error",
2315
+ "svelte/no-at-debug-tags": "error",
2316
+ "svelte/no-extra-reactive-curlies": "error",
2317
+ "svelte/no-ignored-unsubscribe": "error",
2318
+ "svelte/no-inline-styles": "error",
2319
+ "svelte/no-inspect": "error",
2320
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
2321
+ "svelte/no-target-blank": "error",
2322
+ "svelte/no-top-level-browser-globals": "error",
2323
+ "style/no-trailing-spaces": "off",
2324
+ "svelte/no-trailing-spaces": "error",
2325
+ "svelte/prefer-class-directive": "error",
2326
+ "prefer-const": "off",
2327
+ "svelte/prefer-const": "error",
2328
+ "svelte/prefer-destructured-store-props": "error",
2329
+ "svelte/prefer-style-directive": "error",
2330
+ "svelte/require-event-prefix": "error",
2331
+ "svelte/require-optimized-style-attribute": "error",
2332
+ "svelte/require-store-callbacks-use-set-param": "error",
2333
+ "svelte/require-stores-init": "error",
2334
+ "svelte/shorthand-attribute": "error",
2335
+ "svelte/shorthand-directive": "error",
2336
+ "svelte/sort-attributes": "error",
2337
+ "svelte/spaced-html-comment": "error",
2338
+ "svelte/valid-compile": "error",
2339
+ "svelte/valid-style-parse": "error"
2340
+ }
2341
+ }
2342
+ ];
2343
+ };
2344
+
2345
+ //#endregion
2346
+ //#region src/js/eslint/configs/test.ts
2347
+ const test = async () => {
2348
+ const { requiredAll: [pluginVitest] } = await resolvePackages(MODULES.test);
2349
+ if (!pluginVitest) return [];
2350
+ return [{
2351
+ name: buildConfigName(MAIN_SCOPES.TEST, SUB_SCOPES.SETUP),
2352
+ plugins: { test: pluginVitest }
2353
+ }, {
2354
+ name: buildConfigName(MAIN_SCOPES.TEST, SUB_SCOPES.RULES),
2355
+ files: GLOB_TEST_FILES,
2356
+ rules: {
2357
+ ...renameRules(pluginVitest.configs.recommended.rules, { vitest: "test" }),
2358
+ "test/consistent-each-for": ["error", {
2359
+ test: "each",
2360
+ it: "each",
2361
+ describe: "each",
2362
+ suite: "each"
2363
+ }],
2364
+ "test/consistent-test-filename": "error",
2365
+ "test/consistent-test-it": "error",
2366
+ "test/consistent-vitest-vi": "error",
2367
+ "test/hoisted-apis-on-top": "error",
2368
+ "test/no-alias-methods": "error",
2369
+ "test/no-conditional-in-test": "error",
2370
+ "test/no-conditional-tests": "error",
2371
+ "test/no-duplicate-hooks": "error",
2372
+ "test/no-test-prefixes": "error",
2373
+ "test/no-test-return-statement": "error",
2374
+ "test/padding-around-all": "error",
2375
+ "test/prefer-called-once": "error",
2376
+ "test/prefer-called-with": "error",
2377
+ "test/prefer-comparison-matcher": "error",
2378
+ "test/prefer-each": "error",
2379
+ "test/prefer-equality-matcher": "error",
2380
+ "test/prefer-expect-resolves": "error",
2381
+ "test/prefer-expect-type-of": "error",
2382
+ "test/prefer-hooks-in-order": "error",
2383
+ "test/prefer-hooks-on-top": "error",
2384
+ "test/prefer-import-in-mock": "error",
2385
+ "test/prefer-importing-vitest-globals": "error",
2386
+ "test/prefer-lowercase-title": "error",
2387
+ "test/prefer-mock-promise-shorthand": "error",
2388
+ "test/prefer-snapshot-hint": "error",
2389
+ "test/prefer-spy-on": "error",
2390
+ "test/prefer-strict-boolean-matchers": "error",
2391
+ "test/prefer-strict-equal": "error",
2392
+ "test/prefer-to-be-object": "error",
2393
+ "test/prefer-to-be": "error",
2394
+ "test/prefer-to-contain": "error",
2395
+ "test/prefer-to-have-length": "error",
2396
+ "test/prefer-todo": "error",
2397
+ "test/prefer-vi-mocked": "error",
2398
+ "test/require-awaited-expect-poll": "error",
2399
+ "test/require-hook": "error",
2400
+ "test/require-mock-type-parameters": "error",
2401
+ "test/warn-todo": "error"
2402
+ }
2403
+ }];
2404
+ };
2405
+
2406
+ //#endregion
2407
+ //#region src/js/eslint/configs/toml.ts
2408
+ const toml = async () => {
2409
+ const { requiredAll: [pluginToml, parserToml] } = await resolvePackages(MODULES.toml);
2410
+ if (!pluginToml || !parserToml) return [];
2411
+ return [
2412
+ {
2413
+ name: buildConfigName(MAIN_SCOPES.TOML, SUB_SCOPES.SETUP),
2414
+ plugins: { toml: pluginToml }
2415
+ },
2416
+ {
2417
+ name: buildConfigName(MAIN_SCOPES.TOML, SUB_SCOPES.PARSER),
2418
+ files: [GLOB_TOML],
2419
+ languageOptions: { parser: parserToml }
2420
+ },
2421
+ {
2422
+ name: buildConfigName(MAIN_SCOPES.TOML, SUB_SCOPES.RULES),
2423
+ files: [GLOB_TOML],
2424
+ language: "toml/toml",
2425
+ rules: {
2426
+ ...pluginToml.configs.standard[2]?.rules,
2427
+ "toml/array-bracket-spacing": ["error", "never"],
2428
+ "toml/indent": ["error", INDENT],
2429
+ "toml/no-mixed-type-in-array": "error"
2430
+ }
2431
+ }
2432
+ ];
2433
+ };
2434
+
2435
+ //#endregion
2436
+ //#region src/js/eslint/configs/yaml.ts
2437
+ const yaml = async () => {
2438
+ const { requiredAll: [pluginYaml, parserYaml] } = await resolvePackages(MODULES.yaml);
2439
+ if (!pluginYaml || !parserYaml) return [];
2440
+ return [
2441
+ {
2442
+ name: buildConfigName(MAIN_SCOPES.YAML, SUB_SCOPES.SETUP),
2443
+ plugins: { yaml: pluginYaml }
2444
+ },
2445
+ {
2446
+ name: buildConfigName(MAIN_SCOPES.YAML, SUB_SCOPES.PARSER),
2447
+ files: [GLOB_YAML],
2448
+ languageOptions: { parser: parserYaml }
2449
+ },
2450
+ {
2451
+ name: buildConfigName(MAIN_SCOPES.YAML, SUB_SCOPES.RULES),
2452
+ files: [GLOB_YAML],
2453
+ language: "yaml/yaml",
2454
+ rules: {
2455
+ ...renameRules(pluginYaml.configs.standard[2]?.rules, { yml: "yaml" }),
2456
+ "yaml/block-mapping-colon-indicator-newline": ["error", "never"],
2457
+ "yaml/file-extension": "error",
2458
+ "yaml/flow-mapping-curly-spacing": ["error", "always"],
2459
+ "yaml/indent": ["error", INDENT],
2460
+ "yaml/no-multiple-empty-lines": "error",
2461
+ "yaml/no-trailing-zeros": "error",
2462
+ "yaml/quotes": ["error", {
2463
+ avoidEscape: true,
2464
+ prefer: QUOTES
2465
+ }],
2466
+ "yaml/require-string-key": "error"
2467
+ }
2468
+ }
2469
+ ];
2470
+ };
2471
+
2472
+ //#endregion
2473
+ //#region src/js/eslint/configs/index.ts
2474
+ const configs = {
2475
+ [packageOrganization]: builtinConfig[packageOrganization],
2476
+ comments,
2477
+ css,
2478
+ gitignore,
2479
+ ignores,
2480
+ import: imports,
2481
+ javascript,
2482
+ jsdoc,
2483
+ json,
2484
+ markdown,
2485
+ node,
2486
+ overrides,
2487
+ perfectionist,
2488
+ regexp,
2489
+ style,
2490
+ svelte,
2491
+ test,
2492
+ toml,
2493
+ typescript,
2494
+ unicorn,
2495
+ yaml
2496
+ };
2497
+
2498
+ //#endregion
2499
+ //#region src/js/eslint/index.ts
2500
+ const getConfig = (optionsAndGlobalConfig, ...additionalConfigs) => {
2501
+ const resolvedOptions = {
2502
+ [packageOrganization]: isModuleEnabledByDefault(MODULES[packageOrganization]),
2503
+ comments: isModuleEnabledByDefault(MODULES.comments),
2504
+ css: isModuleEnabledByDefault(MODULES.css),
2505
+ gitignore: isModuleEnabledByDefault(MODULES.gitignore),
2506
+ import: isModuleEnabledByDefault(MODULES.import),
2507
+ jsdoc: isModuleEnabledByDefault(MODULES.jsdoc),
2508
+ json: isModuleEnabledByDefault(MODULES.json),
2509
+ markdown: isModuleEnabledByDefault(MODULES.markdown),
2510
+ node: isModuleEnabledByDefault(MODULES.node),
2511
+ perfectionist: isModuleEnabledByDefault(MODULES.perfectionist),
2512
+ regexp: isModuleEnabledByDefault(MODULES.regexp),
2513
+ style: isModuleEnabledByDefault(MODULES.style),
2514
+ svelte: isModuleEnabledByDefault(MODULES.svelte),
2515
+ test: isModuleEnabledByDefault(MODULES.test),
2516
+ toml: isModuleEnabledByDefault(MODULES.toml),
2517
+ typescript: isModuleEnabledByDefault(MODULES.typescript),
2518
+ unicorn: isModuleEnabledByDefault(MODULES.unicorn),
2519
+ yaml: isModuleEnabledByDefault(MODULES.yaml),
2520
+ ...optionsAndGlobalConfig
2521
+ };
2522
+ setModuleEnabled(MODULES[packageOrganization], resolvedOptions[packageOrganization]);
2523
+ setModuleEnabled(MODULES.comments, resolvedOptions.comments);
2524
+ setModuleEnabled(MODULES.css, resolvedOptions.css);
2525
+ setModuleEnabled(MODULES.gitignore, resolvedOptions.gitignore !== false);
2526
+ setModuleEnabled(MODULES.import, resolvedOptions.import);
2527
+ setModuleEnabled(MODULES.jsdoc, resolvedOptions.jsdoc);
2528
+ setModuleEnabled(MODULES.json, resolvedOptions.json);
2529
+ setModuleEnabled(MODULES.markdown, resolvedOptions.markdown !== false);
2530
+ setModuleEnabled(MODULES.node, resolvedOptions.node !== false);
2531
+ setModuleEnabled(MODULES.perfectionist, resolvedOptions.perfectionist);
2532
+ setModuleEnabled(MODULES.regexp, resolvedOptions.regexp);
2533
+ setModuleEnabled(MODULES.style, resolvedOptions.style);
2534
+ setModuleEnabled(MODULES.svelte, resolvedOptions.svelte);
2535
+ setModuleEnabled(MODULES.test, resolvedOptions.test);
2536
+ setModuleEnabled(MODULES.toml, resolvedOptions.toml);
2537
+ setModuleEnabled(MODULES.typescript, resolvedOptions.typescript !== false);
2538
+ setModuleEnabled(MODULES.unicorn, resolvedOptions.unicorn);
2539
+ setModuleEnabled(MODULES.yaml, resolvedOptions.yaml);
2540
+ const composer = new FlatConfigComposer();
2541
+ const appendToComposer = (...configsToAppend) => {
2542
+ composer.append(...configsToAppend);
2543
+ };
2544
+ appendToComposer(configs.ignores(resolvedOptions.ignores));
2545
+ if (isModuleEnabled(MODULES.gitignore)) appendToComposer(configs.gitignore(typeof resolvedOptions.gitignore === "object" ? resolvedOptions.gitignore : { strict: false }));
2546
+ appendToComposer(configs.javascript());
2547
+ if (isModuleEnabled(MODULES.typescript)) appendToComposer(configs.typescript(typeof resolvedOptions.typescript === "object" ? resolvedOptions.typescript : void 0));
2548
+ if (isModuleEnabled(MODULES.test)) appendToComposer(configs.test());
2549
+ if (isModuleEnabled(MODULES.jsdoc)) appendToComposer(configs.jsdoc());
2550
+ if (isModuleEnabled(MODULES.node)) appendToComposer(configs.node(typeof resolvedOptions.node === "object" ? resolvedOptions.node : void 0));
2551
+ if (isModuleEnabled(MODULES[packageOrganization])) appendToComposer(configs[packageOrganization]());
2552
+ if (isModuleEnabled(MODULES.comments)) appendToComposer(configs.comments());
2553
+ if (isModuleEnabled(MODULES.regexp)) appendToComposer(configs.regexp());
2554
+ if (isModuleEnabled(MODULES.unicorn)) appendToComposer(configs.unicorn());
2555
+ if (isModuleEnabled(MODULES.import)) appendToComposer(configs.import());
2556
+ if (isModuleEnabled(MODULES.style)) appendToComposer(configs.style());
2557
+ if (isModuleEnabled(MODULES.perfectionist)) appendToComposer(configs.perfectionist());
2558
+ if (isModuleEnabled(MODULES.svelte)) appendToComposer(configs.svelte());
2559
+ if (isModuleEnabled(MODULES.json)) appendToComposer(configs.json());
2560
+ if (isModuleEnabled(MODULES.toml)) appendToComposer(configs.toml());
2561
+ if (isModuleEnabled(MODULES.yaml)) appendToComposer(configs.yaml());
2562
+ if (isModuleEnabled(MODULES.css)) appendToComposer(configs.css());
2563
+ if (isModuleEnabled(MODULES.markdown)) appendToComposer(configs.markdown(typeof resolvedOptions.markdown === "object" ? resolvedOptions.markdown : void 0));
2564
+ appendToComposer(configs.overrides());
2565
+ appendToComposer(...getUserConfigs(resolvedOptions, additionalConfigs));
2566
+ return composer;
2567
+ };
2568
+ var eslint_default = getConfig();
2569
+
2570
+ //#endregion
2571
+ export { eslint_default as default, getConfig };