@zayne-labs/eslint-config 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1380 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import { isObject } from '@zayne-labs/toolkit/type-helpers';
3
+ import { isPackageExists } from 'local-pkg';
4
+ import default2 from '@eslint/js';
5
+ import default3 from 'eslint-plugin-import-x';
6
+ import globals from 'globals';
7
+ import { fixupPluginRules } from '@eslint/compat';
8
+ import { FlatConfigComposer } from 'eslint-flat-config-utils';
9
+
10
+ // src/utils.ts
11
+ var combine = async (...configs) => {
12
+ const resolved = await Promise.all(configs);
13
+ return resolved.flat();
14
+ };
15
+ var interopDefault = async (module) => {
16
+ const resolved = await module;
17
+ return resolved.default ?? resolved;
18
+ };
19
+ var renameRules = (rules, renameMap) => {
20
+ const renamedRulesEntries = Object.entries(rules).map(([ruleKey, ruleValue]) => {
21
+ for (const [oldRuleName, newRuleName] of Object.entries(renameMap)) {
22
+ if (ruleKey.startsWith(`${oldRuleName}/`)) {
23
+ return [`${newRuleName}${ruleKey.slice(oldRuleName.length)}`, ruleValue];
24
+ }
25
+ }
26
+ return [ruleKey, ruleValue];
27
+ });
28
+ const renamedRules = Object.fromEntries(renamedRulesEntries);
29
+ return renamedRules;
30
+ };
31
+ var renamePlugins = (plugins, renameMap) => {
32
+ const renamedPluginEntries = Object.entries(plugins).map(([pluginKey, pluginValue]) => {
33
+ if (pluginKey in renameMap) {
34
+ return [renameMap[pluginKey], pluginValue];
35
+ }
36
+ return [pluginKey, pluginValue];
37
+ });
38
+ const renamedPlugins = Object.fromEntries(renamedPluginEntries);
39
+ return renamedPlugins;
40
+ };
41
+ var renamePluginInConfigs = (configs, renameMap, extraOverrides) => {
42
+ const renamedConfigs = configs.map((config) => ({
43
+ ...config,
44
+ ...extraOverrides,
45
+ ...isObject(config.rules) && { rules: renameRules(config.rules, renameMap) },
46
+ ...isObject(config.plugins) && { plugins: renamePlugins(config.plugins, renameMap) }
47
+ }));
48
+ return renamedConfigs;
49
+ };
50
+ var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
51
+ var isCwdInScope = isPackageExists("@zayne-labs/eslint-config");
52
+ var isPackageInScope = (name) => isPackageExists(name, { paths: [scopeUrl] });
53
+ var ensurePackages = async (packages) => {
54
+ if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
55
+ const nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));
56
+ if (nonExistingPackages.length === 0) return;
57
+ const clackPrompt = await import('@clack/prompts');
58
+ const result = await clackPrompt.confirm({
59
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
60
+ });
61
+ if (result) {
62
+ const antfuPkg = await import('@antfu/install-pkg');
63
+ await antfuPkg.installPackage(nonExistingPackages, { dev: true });
64
+ }
65
+ };
66
+
67
+ // src/globs.ts
68
+ var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
69
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
70
+ var GLOB_JS = "**/*.?([cm])js";
71
+ var GLOB_JSX = "**/*.?([cm])jsx";
72
+ var GLOB_TS = "**/*.?([cm])ts";
73
+ var GLOB_TSX = "**/*.?([cm])tsx";
74
+ var GLOB_STYLES = "**/*.{c,le,sc}ss";
75
+ var GLOB_CSS = "**/*.css";
76
+ var GLOB_POSTCSS = "**/*.{p,post}css";
77
+ var GLOB_LESS = "**/*.less";
78
+ var GLOB_SCSS = "**/*.scss";
79
+ var GLOB_JSON = "**/*.json";
80
+ var GLOB_JSON5 = "**/*.json5";
81
+ var GLOB_JSONC = "**/*.jsonc";
82
+ var GLOB_MARKDOWN = "**/*.md";
83
+ var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
84
+ var GLOB_SVELTE = "**/*.svelte";
85
+ var GLOB_VUE = "**/*.vue";
86
+ var GLOB_YAML = "**/*.y?(a)ml";
87
+ var GLOB_TOML = "**/*.toml";
88
+ var GLOB_XML = "**/*.xml";
89
+ var GLOB_SVG = "**/*.svg";
90
+ var GLOB_HTML = "**/*.htm?(l)";
91
+ var GLOB_ASTRO = "**/*.astro";
92
+ var GLOB_ASTRO_TS = "**/*.astro/*.ts";
93
+ var GLOB_GRAPHQL = "**/*.{g,graph}ql";
94
+ var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
95
+ var GLOB_TESTS = [
96
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
97
+ `**/*.spec.${GLOB_SRC_EXT}`,
98
+ `**/*.test.${GLOB_SRC_EXT}`,
99
+ `**/*.bench.${GLOB_SRC_EXT}`,
100
+ `**/*.benchmark.${GLOB_SRC_EXT}`
101
+ ];
102
+ var GLOB_ALL_SRC = [
103
+ GLOB_SRC,
104
+ GLOB_STYLES,
105
+ GLOB_JSON,
106
+ GLOB_JSON5,
107
+ GLOB_MARKDOWN,
108
+ GLOB_SVELTE,
109
+ GLOB_VUE,
110
+ GLOB_YAML,
111
+ GLOB_XML,
112
+ GLOB_HTML
113
+ ];
114
+ var GLOB_EXCLUDE = [
115
+ "**/node_modules",
116
+ "**/dist",
117
+ "**/package-lock.json",
118
+ "**/yarn.lock",
119
+ "**/pnpm-lock.yaml",
120
+ "**/bun.lockb",
121
+ "**/output",
122
+ "**/coverage",
123
+ "**/temp",
124
+ "**/.temp",
125
+ "**/tmp",
126
+ "**/.tmp",
127
+ "**/.history",
128
+ "**/.vitepress/cache",
129
+ "**/.nuxt",
130
+ "**/.next",
131
+ "**/.svelte-kit",
132
+ "**/.vercel",
133
+ "**/.changeset",
134
+ "**/.idea",
135
+ "**/.cache",
136
+ "**/.output",
137
+ "**/.vite-inspect",
138
+ "**/.yarn",
139
+ "**/vite.config.*.timestamp-*",
140
+ "**/CHANGELOG*.md",
141
+ "**/*.min.*",
142
+ "**/LICENSE*",
143
+ "**/__snapshots__",
144
+ "**/auto-import?(s).d.ts",
145
+ "**/components.d.ts"
146
+ ];
147
+
148
+ // src/configs/ignores.ts
149
+ var ignores = (userIgnores = []) => [
150
+ {
151
+ ignores: [...GLOB_EXCLUDE, ...userIgnores],
152
+ name: "zayne/defaults/ignores"
153
+ }
154
+ ];
155
+ var gitIgnores = async (options) => {
156
+ const antfuGitIgnore = await interopDefault(import('eslint-config-flat-gitignore'));
157
+ const config = antfuGitIgnore({
158
+ name: "zayne/gitignore",
159
+ ...isObject(options) ? options : { strict: false }
160
+ });
161
+ return [config];
162
+ };
163
+ var javascript = (options = {}) => {
164
+ const { overrides } = options;
165
+ return [
166
+ {
167
+ languageOptions: {
168
+ ecmaVersion: "latest",
169
+ globals: {
170
+ ...globals.browser,
171
+ ...globals.node,
172
+ document: "readonly",
173
+ navigator: "readonly",
174
+ window: "readonly"
175
+ },
176
+ parserOptions: {
177
+ ecmaFeatures: {
178
+ jsx: true
179
+ },
180
+ ecmaVersion: "latest",
181
+ sourceType: "module"
182
+ },
183
+ sourceType: "module"
184
+ },
185
+ linterOptions: {
186
+ reportUnusedDisableDirectives: true
187
+ },
188
+ name: "zayne/js-eslint/setup"
189
+ },
190
+ {
191
+ name: "zayne/js-eslint/recommended",
192
+ ...default2.configs.recommended
193
+ },
194
+ {
195
+ name: "zayne/js-eslint/rules",
196
+ rules: {
197
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
198
+ "array-callback-return": ["error", { allowImplicit: true }],
199
+ "block-scoped-var": "error",
200
+ "class-methods-use-this": "error",
201
+ complexity: ["warn", 30],
202
+ "constructor-super": "error",
203
+ curly: ["error", "multi-line"],
204
+ "default-case": ["error", { commentPattern: "^no default$" }],
205
+ "default-case-last": "error",
206
+ "default-param-last": "error",
207
+ "dot-notation": ["error", { allowKeywords: true }],
208
+ eqeqeq: ["error", "always", { null: "ignore" }],
209
+ "grouped-accessor-pairs": "error",
210
+ "logical-assignment-operators": "warn",
211
+ "max-depth": ["error", 2],
212
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
213
+ "no-alert": "warn",
214
+ "no-array-constructor": "error",
215
+ "no-async-promise-executor": "error",
216
+ "no-await-in-loop": "error",
217
+ "no-caller": "error",
218
+ "no-case-declarations": "error",
219
+ "no-class-assign": "error",
220
+ "no-compare-neg-zero": "error",
221
+ "no-cond-assign": ["error", "always"],
222
+ "no-console": ["error", { allow: ["warn", "error", "info", "trace"] }],
223
+ "no-const-assign": "error",
224
+ "no-constant-condition": "warn",
225
+ "no-constructor-return": "error",
226
+ "no-control-regex": "error",
227
+ "no-debugger": "error",
228
+ "no-delete-var": "error",
229
+ "no-dupe-args": "error",
230
+ "no-dupe-class-members": "error",
231
+ "no-dupe-keys": "error",
232
+ "no-duplicate-case": "error",
233
+ "no-else-return": ["error", { allowElseIf: false }],
234
+ "no-empty": ["error", { allowEmptyCatch: true }],
235
+ "no-empty-character-class": "error",
236
+ "no-empty-pattern": "error",
237
+ "no-eval": "error",
238
+ "no-ex-assign": "error",
239
+ "no-extend-native": "error",
240
+ "no-extra-bind": "error",
241
+ "no-extra-boolean-cast": "error",
242
+ "no-fallthrough": "error",
243
+ "no-func-assign": "error",
244
+ "no-global-assign": "error",
245
+ "no-implicit-coercion": "warn",
246
+ "no-implied-eval": "error",
247
+ "no-import-assign": "error",
248
+ "no-invalid-regexp": "error",
249
+ "no-irregular-whitespace": "error",
250
+ "no-iterator": "error",
251
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
252
+ "no-lone-blocks": "error",
253
+ "no-loop-func": "error",
254
+ "no-loss-of-precision": "error",
255
+ "no-misleading-character-class": "error",
256
+ "no-multi-str": "error",
257
+ "no-new": "error",
258
+ "no-new-func": "error",
259
+ "no-new-native-nonconstructor": "error",
260
+ "no-new-wrappers": "error",
261
+ "no-obj-calls": "error",
262
+ "no-octal": "error",
263
+ "no-octal-escape": "error",
264
+ "no-param-reassign": [
265
+ "error",
266
+ {
267
+ ignorePropertyModificationsFor: [
268
+ "acc",
269
+ // for reduce accumulators
270
+ "accumulator",
271
+ // for reduce accumulators
272
+ "e",
273
+ // for e.returnvalue
274
+ "ctx",
275
+ // for Koa routing
276
+ "context",
277
+ // for Koa routing
278
+ "req",
279
+ // for Express requests
280
+ "request",
281
+ // for Express requests
282
+ "res",
283
+ // for Express responses
284
+ "response",
285
+ // for Express responses
286
+ "$scope",
287
+ // for Angular 1 scopes
288
+ "staticContext"
289
+ // for ReactRouter context
290
+ ],
291
+ props: true
292
+ }
293
+ ],
294
+ "no-proto": "error",
295
+ "no-prototype-builtins": "error",
296
+ "no-redeclare": ["error", { builtinGlobals: false }],
297
+ "no-regex-spaces": "error",
298
+ "no-restricted-exports": [
299
+ "error",
300
+ {
301
+ restrictedNamedExports: [
302
+ "default",
303
+ // use `export default` to provide a default export
304
+ "then"
305
+ // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
306
+ ]
307
+ }
308
+ ],
309
+ "no-restricted-globals": [
310
+ "error",
311
+ {
312
+ message: "Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite",
313
+ name: "isFinite"
314
+ },
315
+ {
316
+ message: "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan",
317
+ name: "isNaN"
318
+ },
319
+ { message: "Use `globalThis` instead.", name: "global" },
320
+ { message: "Use `globalThis` instead.", name: "self" }
321
+ ],
322
+ "no-restricted-imports": ["off", { paths: [], patterns: [] }],
323
+ "no-restricted-properties": [
324
+ "error",
325
+ {
326
+ message: "arguments.callee is deprecated",
327
+ object: "arguments",
328
+ property: "callee"
329
+ },
330
+ {
331
+ message: "Please use Number.isFinite instead",
332
+ object: "global",
333
+ property: "isFinite"
334
+ },
335
+ {
336
+ message: "Please use Number.isFinite instead",
337
+ object: "self",
338
+ property: "isFinite"
339
+ },
340
+ {
341
+ message: "Please use Number.isFinite instead",
342
+ object: "window",
343
+ property: "isFinite"
344
+ },
345
+ {
346
+ message: "Please use Number.isNaN instead",
347
+ object: "global",
348
+ property: "isNaN"
349
+ },
350
+ {
351
+ message: "Please use Number.isNaN instead",
352
+ object: "self",
353
+ property: "isNaN"
354
+ },
355
+ {
356
+ message: "Please use Number.isNaN instead",
357
+ object: "window",
358
+ property: "isNaN"
359
+ },
360
+ {
361
+ message: "Use the exponentiation operator (**) instead.",
362
+ object: "Math",
363
+ property: "pow"
364
+ },
365
+ {
366
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
367
+ property: "__proto__"
368
+ },
369
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
370
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
371
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
372
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
373
+ ],
374
+ "no-restricted-syntax": [
375
+ "error",
376
+ "ForInStatement",
377
+ "LabeledStatement",
378
+ "WithStatement",
379
+ "TSEnumDeclaration[const=true]",
380
+ "TSExportAssignment"
381
+ ],
382
+ "no-return-assign": ["error", "except-parens"],
383
+ "no-script-url": "error",
384
+ "no-self-assign": ["error", { props: true }],
385
+ "no-self-compare": "error",
386
+ "no-sequences": "error",
387
+ "no-shadow-restricted-names": "error",
388
+ "no-sparse-arrays": "error",
389
+ "no-template-curly-in-string": "error",
390
+ "no-this-before-super": "error",
391
+ "no-throw-literal": "error",
392
+ "no-undef": "error",
393
+ "no-undef-init": "error",
394
+ "no-unexpected-multiline": "error",
395
+ "no-unmodified-loop-condition": "error",
396
+ "no-unneeded-ternary": ["warn", { defaultAssignment: false }],
397
+ "no-unreachable": "error",
398
+ "no-unreachable-loop": "error",
399
+ "no-unsafe-finally": "error",
400
+ "no-unsafe-negation": "error",
401
+ "no-unused-expressions": [
402
+ "error",
403
+ {
404
+ allowShortCircuit: true,
405
+ allowTaggedTemplates: true,
406
+ allowTernary: true
407
+ }
408
+ ],
409
+ "no-unused-vars": [
410
+ "warn",
411
+ {
412
+ args: "none",
413
+ caughtErrors: "none",
414
+ ignoreRestSiblings: true,
415
+ vars: "all"
416
+ }
417
+ ],
418
+ // "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
419
+ "no-useless-backreference": "error",
420
+ "no-useless-call": "error",
421
+ "no-useless-catch": "error",
422
+ "no-useless-computed-key": "error",
423
+ "no-useless-concat": "error",
424
+ "no-useless-constructor": "error",
425
+ "no-useless-rename": [
426
+ "error",
427
+ { ignoreDestructuring: false, ignoreExport: false, ignoreImport: false }
428
+ ],
429
+ "no-useless-return": "error",
430
+ "no-var": "error",
431
+ "no-with": "error",
432
+ "object-shorthand": ["error", "always", { avoidQuotes: true, ignoreConstructors: false }],
433
+ "one-var": ["error", { initialized: "never" }],
434
+ "operator-assignment": "warn",
435
+ "prefer-arrow-callback": [
436
+ "error",
437
+ {
438
+ allowNamedFunctions: false,
439
+ allowUnboundThis: true
440
+ }
441
+ ],
442
+ "prefer-const": [
443
+ "error",
444
+ {
445
+ destructuring: "all",
446
+ ignoreReadBeforeAssign: true
447
+ }
448
+ ],
449
+ "prefer-exponentiation-operator": "error",
450
+ "prefer-object-has-own": "error",
451
+ "prefer-object-spread": "warn",
452
+ "prefer-promise-reject-errors": "error",
453
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
454
+ "prefer-rest-params": "error",
455
+ "prefer-spread": "error",
456
+ "prefer-template": "error",
457
+ radix: "error",
458
+ "symbol-description": "error",
459
+ "unicode-bom": ["error", "never"],
460
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
461
+ "valid-typeof": ["error", { requireStringLiterals: true }],
462
+ "vars-on-top": "error",
463
+ yoda: ["error", "never"],
464
+ ...overrides
465
+ }
466
+ }
467
+ ];
468
+ };
469
+
470
+ // src/configs/tailwindcss.ts
471
+ var tailwindcss = async (options = {}) => {
472
+ const eslintPluginTailwindCss = await interopDefault(await import('eslint-plugin-tailwindcss'));
473
+ const { overrides, settings: tailwindCssSettings } = options;
474
+ return [
475
+ {
476
+ name: "zayne/tailwindcss/setup",
477
+ plugins: {
478
+ tailwindcss: eslintPluginTailwindCss
479
+ },
480
+ settings: {
481
+ tailwindcss: {
482
+ callees: ["tv", "cnMerge", "cn", "cnJoin", "twMerge", "twJoin"],
483
+ cssFiles: [],
484
+ removeDuplicates: false,
485
+ // Turned off cuz prettier already handles this via plugin
486
+ ...tailwindCssSettings
487
+ }
488
+ }
489
+ },
490
+ {
491
+ name: "zayne/tailwindcss/rules",
492
+ rules: {
493
+ ...eslintPluginTailwindCss.rules,
494
+ "tailwindcss/no-contradicting-classname": "off",
495
+ // Turned off cuz tw intellisense already handles this
496
+ "tailwindcss/no-custom-classname": [
497
+ "warn",
498
+ { ignoredKeys: ["compoundVariants", "defaultVariants", "responsiveVariants"] }
499
+ ],
500
+ ...overrides
501
+ }
502
+ }
503
+ ];
504
+ };
505
+
506
+ // src/configs/typescript.ts
507
+ var typescript = async (options = {}) => {
508
+ const {
509
+ allowDefaultProjects,
510
+ componentExts = [],
511
+ overrides,
512
+ parserOptions,
513
+ stylistic: stylistic2 = true,
514
+ tsconfigPath
515
+ } = options;
516
+ const isTypeAware = Boolean(tsconfigPath);
517
+ const files = options.files ?? [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)];
518
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
519
+ const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
520
+ const tsEslint = await interopDefault(import('typescript-eslint'));
521
+ const makeParser = (parsedFiles, ignores2) => ({
522
+ files: parsedFiles,
523
+ ...ignores2 && { ignores: ignores2 },
524
+ languageOptions: {
525
+ parser: tsEslint.parser,
526
+ parserOptions: {
527
+ ecmaFeatures: { globalReturn: true },
528
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
529
+ ...isTypeAware && {
530
+ ...allowDefaultProjects ? {
531
+ projectService: {
532
+ allowDefaultProject: allowDefaultProjects,
533
+ defaultProject: tsconfigPath
534
+ }
535
+ } : { project: tsconfigPath },
536
+ tsconfigRootDir: process.cwd()
537
+ },
538
+ sourceType: "module",
539
+ ...parserOptions
540
+ }
541
+ }
542
+ });
543
+ const typeAwareRules = {
544
+ "ts-eslint/no-unnecessary-type-parameters": "off",
545
+ // "ts-eslint/non-nullable-type-assertion-style": "off",
546
+ "ts-eslint/prefer-nullish-coalescing": ["error", { ignoreConditionalTests: true }],
547
+ "ts-eslint/restrict-template-expressions": [
548
+ "error",
549
+ { allowBoolean: true, allowNullish: true, allowNumber: true }
550
+ ],
551
+ "ts-eslint/return-await": ["error", "in-try-catch"]
552
+ };
553
+ return [
554
+ {
555
+ name: `zayne/ts-eslint/${isTypeAware ? "type-aware-setup" : "setup"}`,
556
+ ...makeParser(files),
557
+ ...isTypeAware && makeParser(filesTypeAware, ignoresTypeAware)
558
+ },
559
+ ...renamePluginInConfigs(
560
+ tsEslint.configs[isTypeAware ? "strictTypeChecked" : "strict"],
561
+ { "@typescript-eslint": "ts-eslint" },
562
+ { files, name: `zayne/ts-eslint/${isTypeAware ? "strictTypeChecked" : "strict"}` }
563
+ ),
564
+ ...stylistic2 ? renamePluginInConfigs(
565
+ tsEslint.configs[isTypeAware ? "stylisticTypeChecked" : "stylistic"],
566
+ { "@typescript-eslint": "ts-eslint" },
567
+ { files, name: `zayne/ts-eslint/${isTypeAware ? "stylisticTypeChecked" : "stylistic"}` }
568
+ ) : [],
569
+ {
570
+ files,
571
+ name: "zayne/ts-eslint/rules",
572
+ rules: {
573
+ "ts-eslint/array-type": ["error", { default: "array-simple" }],
574
+ "ts-eslint/consistent-type-definitions": ["error", "type"],
575
+ "ts-eslint/default-param-last": "error",
576
+ "ts-eslint/member-ordering": "error",
577
+ "ts-eslint/method-signature-style": ["error", "property"],
578
+ "ts-eslint/no-confusing-void-expression": "off",
579
+ "ts-eslint/no-empty-function": [
580
+ "error",
581
+ { allow: ["arrowFunctions", "functions", "methods"] }
582
+ ],
583
+ "ts-eslint/no-import-type-side-effects": "error",
584
+ "ts-eslint/no-shadow": "error",
585
+ "ts-eslint/no-unused-expressions": [
586
+ "error",
587
+ {
588
+ allowShortCircuit: true,
589
+ allowTernary: true
590
+ }
591
+ ],
592
+ "ts-eslint/no-unused-vars": ["warn", { ignoreRestSiblings: true }],
593
+ "ts-eslint/no-use-before-define": "off",
594
+ "ts-eslint/no-useless-constructor": "error",
595
+ ...isTypeAware && typeAwareRules,
596
+ ...overrides
597
+ }
598
+ }
599
+ ];
600
+ };
601
+
602
+ // src/configs/unicorn.ts
603
+ var unicorn = async (options = {}) => {
604
+ const { overrides } = options;
605
+ const eslintPluginUnicorn = await interopDefault(import('eslint-plugin-unicorn'));
606
+ return [
607
+ { ...eslintPluginUnicorn.configs["flat/recommended"], name: "zayne/unicorn/recommended" },
608
+ {
609
+ name: "zayne/unicorn/rules",
610
+ rules: {
611
+ "unicorn/filename-case": [
612
+ "warn",
613
+ {
614
+ cases: {
615
+ camelCase: true,
616
+ kebabCase: true,
617
+ pascalCase: true
618
+ }
619
+ }
620
+ ],
621
+ "unicorn/new-for-builtins": "off",
622
+ "unicorn/no-array-for-each": "off",
623
+ "unicorn/no-array-reduce": "off",
624
+ "unicorn/no-negated-condition": "off",
625
+ "unicorn/no-null": "off",
626
+ "unicorn/no-useless-undefined": ["error", { checkArguments: true }],
627
+ "unicorn/numeric-separators-style": "off",
628
+ "unicorn/prevent-abbreviations": "off",
629
+ ...overrides
630
+ }
631
+ }
632
+ ];
633
+ };
634
+
635
+ // src/configs/imports.ts
636
+ var imports = (options) => {
637
+ const { overrides, stylistic: stylistic2 = true, typescript: typescript2 = true } = options;
638
+ return [
639
+ {
640
+ plugins: {
641
+ import: default3
642
+ },
643
+ ...typescript2 && { settings: default3.flatConfigs.typescript.settings },
644
+ name: "zayne/import/setup"
645
+ },
646
+ {
647
+ name: "zayne/import/rules",
648
+ rules: {
649
+ ...default3.flatConfigs.recommended.rules,
650
+ ...typescript2 && default3.flatConfigs.typescript.rules,
651
+ "import/export": "error",
652
+ "import/extensions": [
653
+ "error",
654
+ "never",
655
+ { ignorePackages: true, pattern: { png: "always", svg: "always" } }
656
+ ],
657
+ "import/first": "error",
658
+ "import/namespace": "off",
659
+ "import/no-absolute-path": "error",
660
+ "import/no-cycle": ["error", { ignoreExternal: true, maxDepth: 3 }],
661
+ "import/no-duplicates": "error",
662
+ "import/no-extraneous-dependencies": ["error", { devDependencies: true }],
663
+ "import/no-mutable-exports": "error",
664
+ "import/no-named-as-default": "error",
665
+ "import/no-named-as-default-member": "error",
666
+ "import/no-named-default": "error",
667
+ "import/no-relative-packages": "error",
668
+ "import/no-self-import": "error",
669
+ "import/no-unresolved": "off",
670
+ "import/no-useless-path-segments": ["error", { commonjs: true }],
671
+ "import/prefer-default-export": "off",
672
+ ...stylistic2 && { "import/newline-after-import": "error" },
673
+ ...overrides
674
+ }
675
+ }
676
+ ];
677
+ };
678
+
679
+ // src/configs/perfectionist.ts
680
+ var perfectionist = async (options = {}) => {
681
+ const { overrides } = options;
682
+ const eslintPluginPerfectionist = await interopDefault(import('eslint-plugin-perfectionist'));
683
+ return [
684
+ {
685
+ name: "zayne/perfectionist/rules",
686
+ plugins: {
687
+ perfectionist: eslintPluginPerfectionist
688
+ },
689
+ rules: {
690
+ "perfectionist/sort-array-includes": [
691
+ "warn",
692
+ {
693
+ order: "asc",
694
+ type: "alphabetical"
695
+ }
696
+ ],
697
+ "perfectionist/sort-classes": [
698
+ "warn",
699
+ {
700
+ order: "asc",
701
+ type: "alphabetical"
702
+ }
703
+ ],
704
+ "perfectionist/sort-interfaces": [
705
+ "warn",
706
+ {
707
+ order: "asc",
708
+ type: "alphabetical"
709
+ }
710
+ ],
711
+ "perfectionist/sort-intersection-types": [
712
+ "warn",
713
+ {
714
+ groups: [
715
+ "conditional",
716
+ "literal",
717
+ "import",
718
+ "intersection",
719
+ "keyword",
720
+ "tuple",
721
+ "named",
722
+ "object",
723
+ "function",
724
+ "operator",
725
+ "union",
726
+ "nullish"
727
+ ],
728
+ order: "asc",
729
+ type: "alphabetical"
730
+ }
731
+ ],
732
+ "perfectionist/sort-maps": [
733
+ "warn",
734
+ {
735
+ order: "asc",
736
+ type: "alphabetical"
737
+ }
738
+ ],
739
+ "perfectionist/sort-object-types": [
740
+ "warn",
741
+ {
742
+ order: "asc",
743
+ type: "alphabetical"
744
+ }
745
+ ],
746
+ "perfectionist/sort-objects": [
747
+ "warn",
748
+ {
749
+ order: "asc",
750
+ type: "alphabetical"
751
+ }
752
+ ],
753
+ "perfectionist/sort-switch-case": [
754
+ "warn",
755
+ {
756
+ order: "asc",
757
+ type: "alphabetical"
758
+ }
759
+ ],
760
+ "perfectionist/sort-union-types": [
761
+ "warn",
762
+ {
763
+ groups: [
764
+ "conditional",
765
+ "literal",
766
+ "import",
767
+ "intersection",
768
+ "keyword",
769
+ "tuple",
770
+ "named",
771
+ "object",
772
+ "function",
773
+ "operator",
774
+ "union",
775
+ "nullish"
776
+ ],
777
+ order: "asc",
778
+ type: "alphabetical"
779
+ }
780
+ ],
781
+ "perfectionist/sort-variable-declarations": [
782
+ "warn",
783
+ {
784
+ order: "asc",
785
+ type: "alphabetical"
786
+ }
787
+ ],
788
+ // "perfectionist/sort-svelte-attributes": [
789
+ // "warn",
790
+ // {
791
+ // order: "asc",
792
+ // type: "alphabetical",
793
+ // },
794
+ // ],
795
+ // "perfectionist/sort-astro-attributes": [
796
+ // "warn",
797
+ // {
798
+ // order: "asc",
799
+ // type: "alphabetical",
800
+ // },
801
+ // ],
802
+ // "perfectionist/sort-vue-attributes": [
803
+ // "warn",
804
+ // {
805
+ // order: "asc",
806
+ // type: "alphabetical",
807
+ // },
808
+ // ],
809
+ // "perfectionist/sort-jsx-props": [
810
+ // "warn",
811
+ // {
812
+ // // ignorePattern: ["src"],
813
+ // order: "asc",
814
+ // type: "alphabetical",
815
+ // },
816
+ // ],
817
+ ...overrides
818
+ }
819
+ }
820
+ ];
821
+ };
822
+
823
+ // src/configs/stylistic.ts
824
+ var stylistic = async (options = {}) => {
825
+ const { jsx: jsx2 = true, overrides } = options;
826
+ const eslintPluginStylistic = await interopDefault(import('@stylistic/eslint-plugin'));
827
+ return [
828
+ // == Stylistic Rules (Optional)
829
+ {
830
+ name: "zayne/stylistic/rules",
831
+ plugins: {
832
+ stylistic: eslintPluginStylistic
833
+ },
834
+ rules: {
835
+ "stylistic/no-floating-decimal": "error",
836
+ "stylistic/spaced-comment": [
837
+ "warn",
838
+ "always",
839
+ {
840
+ block: {
841
+ balanced: true,
842
+ exceptions: ["*"],
843
+ markers: ["!"]
844
+ },
845
+ line: {
846
+ exceptions: ["/", "#"],
847
+ markers: ["/"]
848
+ }
849
+ }
850
+ ],
851
+ ...jsx2 && {
852
+ "stylistic/jsx-self-closing-comp": "error"
853
+ },
854
+ ...overrides
855
+ }
856
+ }
857
+ ];
858
+ };
859
+
860
+ // src/configs/jsonc.ts
861
+ var jsonc = async (options = {}) => {
862
+ const { files, overrides, stylistic: stylistic2 = true } = options;
863
+ const [eslintPluginJsonc, jsoncParser] = await Promise.all([
864
+ interopDefault(import('eslint-plugin-jsonc')),
865
+ interopDefault(import('jsonc-eslint-parser'))
866
+ ]);
867
+ return [
868
+ {
869
+ name: "zayne/jsonc/setup",
870
+ plugins: {
871
+ jsonc: eslintPluginJsonc
872
+ }
873
+ },
874
+ {
875
+ files: files ?? [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
876
+ languageOptions: {
877
+ parser: jsoncParser
878
+ },
879
+ name: "zayne/jsonc/rules",
880
+ rules: {
881
+ "jsonc/no-bigint-literals": "error",
882
+ "jsonc/no-binary-expression": "error",
883
+ "jsonc/no-binary-numeric-literals": "error",
884
+ "jsonc/no-dupe-keys": "error",
885
+ "jsonc/no-escape-sequence-in-identifier": "error",
886
+ "jsonc/no-floating-decimal": "error",
887
+ "jsonc/no-hexadecimal-numeric-literals": "error",
888
+ "jsonc/no-infinity": "error",
889
+ "jsonc/no-multi-str": "error",
890
+ "jsonc/no-nan": "error",
891
+ "jsonc/no-number-props": "error",
892
+ "jsonc/no-numeric-separators": "error",
893
+ "jsonc/no-octal": "error",
894
+ "jsonc/no-octal-escape": "error",
895
+ "jsonc/no-octal-numeric-literals": "error",
896
+ "jsonc/no-parenthesized": "error",
897
+ "jsonc/no-plus-sign": "error",
898
+ "jsonc/no-regexp-literals": "error",
899
+ "jsonc/no-sparse-arrays": "error",
900
+ "jsonc/no-template-literals": "error",
901
+ "jsonc/no-undefined-value": "error",
902
+ "jsonc/no-unicode-codepoint-escapes": "error",
903
+ "jsonc/no-useless-escape": "error",
904
+ "jsonc/space-unary-ops": "error",
905
+ "jsonc/valid-json-number": "error",
906
+ "jsonc/vue-custom-block/no-parsing-error": "error",
907
+ ...stylistic2 && {
908
+ "jsonc/array-bracket-spacing": ["error", "never"],
909
+ "jsonc/comma-dangle": ["error", "never"],
910
+ "jsonc/comma-style": ["error", "last"],
911
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
912
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
913
+ "jsonc/object-curly-spacing": ["error", "always"],
914
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
915
+ "jsonc/quote-props": "error",
916
+ "jsonc/quotes": "error"
917
+ },
918
+ ...overrides
919
+ }
920
+ }
921
+ ];
922
+ };
923
+
924
+ // src/configs/jsdoc.ts
925
+ var jsdoc = async (options = {}) => {
926
+ const { overrides, stylistic: stylistic2 = true } = options;
927
+ const eslintPluginJsdoc = await interopDefault(import('eslint-plugin-jsdoc'));
928
+ return [
929
+ {
930
+ name: "zayne/jsdoc/rules",
931
+ plugins: {
932
+ jsdoc: eslintPluginJsdoc
933
+ },
934
+ rules: {
935
+ "jsdoc/check-access": "warn",
936
+ "jsdoc/check-param-names": "warn",
937
+ "jsdoc/check-property-names": "warn",
938
+ "jsdoc/check-types": "warn",
939
+ "jsdoc/empty-tags": "warn",
940
+ "jsdoc/implements-on-classes": "warn",
941
+ "jsdoc/no-defaults": "warn",
942
+ "jsdoc/no-multi-asterisks": "warn",
943
+ "jsdoc/require-description": "warn",
944
+ "jsdoc/require-param-name": "warn",
945
+ "jsdoc/require-property": "warn",
946
+ "jsdoc/require-property-description": "warn",
947
+ "jsdoc/require-property-name": "warn",
948
+ "jsdoc/require-returns-check": "warn",
949
+ "jsdoc/require-returns-description": "warn",
950
+ "jsdoc/require-yields-check": "warn",
951
+ ...stylistic2 && {
952
+ "jsdoc/check-alignment": "warn",
953
+ "jsdoc/multiline-blocks": "warn"
954
+ },
955
+ ...overrides
956
+ }
957
+ }
958
+ ];
959
+ };
960
+ var ReactRefreshAllowConstantExportPackages = ["vite"];
961
+ var RemixPackages = ["@remix-run/node", "@remix-run/react", "@remix-run/serve", "@remix-run/dev"];
962
+ var NextJsPackages = ["next"];
963
+ var eslintReactRenameMap = {
964
+ "@eslint-react": "react",
965
+ "@eslint-react/debug": "react/debug",
966
+ "@eslint-react/dom": "react/dom",
967
+ "@eslint-react/hooks-extra": "react/hooks-extra",
968
+ "@eslint-react/naming-convention": "react/naming-convention",
969
+ "@eslint-react/web-api": "react/web-api"
970
+ };
971
+ var react = async (options = {}) => {
972
+ const { files, overrides, typescript: typescript2 = true } = options;
973
+ await ensurePackages([
974
+ "@eslint-react/eslint-plugin",
975
+ "eslint-plugin-react-hooks",
976
+ "eslint-plugin-react-refresh",
977
+ "typescript-eslint"
978
+ ]);
979
+ const [eslintPluginReact, eslintReactHooks, eslintPluginReactRefresh] = await Promise.all([
980
+ interopDefault(import('@eslint-react/eslint-plugin')),
981
+ interopDefault(import('eslint-plugin-react-hooks')),
982
+ interopDefault(import('eslint-plugin-react-refresh'))
983
+ ]);
984
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
985
+ const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
986
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
987
+ const recommendedReactConfig = eslintPluginReact.configs[typescript2 ? "recommended-type-checked" : "recommended"];
988
+ return [
989
+ {
990
+ name: "zayne/react/setup",
991
+ plugins: {
992
+ ...renamePlugins(recommendedReactConfig.plugins, eslintReactRenameMap),
993
+ "react-hooks": fixupPluginRules(eslintReactHooks),
994
+ "react-refresh": eslintPluginReactRefresh
995
+ },
996
+ settings: recommendedReactConfig.settings
997
+ },
998
+ {
999
+ files: files ?? [GLOB_SRC],
1000
+ name: "zayne/react/rules",
1001
+ rules: {
1002
+ ...renameRules(recommendedReactConfig.rules, eslintReactRenameMap),
1003
+ "react/avoid-shorthand-boolean": "error",
1004
+ "react/function-component-definition": "off",
1005
+ "react/hooks-extra/ensure-custom-hooks-using-other-hooks": "error",
1006
+ "react/hooks-extra/prefer-use-state-lazy-initialization": "error",
1007
+ "react/naming-convention/component-name": "warn",
1008
+ "react/naming-convention/use-state": "warn",
1009
+ "react/no-array-index-key": "error",
1010
+ "react/no-children-count": "off",
1011
+ "react/no-children-only": "off",
1012
+ "react/no-children-prop": "error",
1013
+ "react/no-children-to-array": "off",
1014
+ "react/no-clone-element": "off",
1015
+ "react/no-missing-component-display-name": "error",
1016
+ "react/prefer-destructuring-assignment": "error",
1017
+ "react/prefer-read-only-props": "off",
1018
+ "react/prefer-shorthand-fragment": "error",
1019
+ // Hook rules
1020
+ // eslint-disable-next-line perfectionist/sort-objects
1021
+ "react-hooks/exhaustive-deps": "warn",
1022
+ "react-hooks/rules-of-hooks": "error",
1023
+ // react refresh
1024
+ "react-refresh/only-export-components": [
1025
+ "warn",
1026
+ {
1027
+ allowConstantExport: isAllowConstantExport,
1028
+ allowExportNames: [
1029
+ ...isUsingNext ? [
1030
+ "dynamic",
1031
+ "dynamicParams",
1032
+ "revalidate",
1033
+ "fetchCache",
1034
+ "runtime",
1035
+ "preferredRegion",
1036
+ "maxDuration",
1037
+ "config",
1038
+ "generateStaticParams",
1039
+ "metadata",
1040
+ "generateMetadata",
1041
+ "viewport",
1042
+ "generateViewport"
1043
+ ] : [],
1044
+ ...isUsingRemix ? ["meta", "links", "headers", "loader", "action"] : []
1045
+ ]
1046
+ }
1047
+ ],
1048
+ // overrides
1049
+ ...overrides
1050
+ }
1051
+ }
1052
+ ];
1053
+ };
1054
+
1055
+ // src/configs/sort.ts
1056
+ var sortPackageJson = () => [
1057
+ {
1058
+ files: ["**/package.json"],
1059
+ name: "zayne/sort/package-json",
1060
+ rules: {
1061
+ "jsonc/sort-array-values": [
1062
+ "error",
1063
+ {
1064
+ order: { type: "asc" },
1065
+ pathPattern: "^files$"
1066
+ }
1067
+ ],
1068
+ "jsonc/sort-keys": [
1069
+ "error",
1070
+ {
1071
+ order: [
1072
+ "publisher",
1073
+ "name",
1074
+ "displayName",
1075
+ "type",
1076
+ "version",
1077
+ "private",
1078
+ "packageManager",
1079
+ "description",
1080
+ "author",
1081
+ "contributors",
1082
+ "license",
1083
+ "funding",
1084
+ "homepage",
1085
+ "repository",
1086
+ "bugs",
1087
+ "keywords",
1088
+ "categories",
1089
+ "sideEffects",
1090
+ "exports",
1091
+ "main",
1092
+ "module",
1093
+ "unpkg",
1094
+ "jsdelivr",
1095
+ "types",
1096
+ "typesVersions",
1097
+ "bin",
1098
+ "icon",
1099
+ "files",
1100
+ "engines",
1101
+ "activationEvents",
1102
+ "contributes",
1103
+ "scripts",
1104
+ "peerDependencies",
1105
+ "peerDependenciesMeta",
1106
+ "dependencies",
1107
+ "optionalDependencies",
1108
+ "devDependencies",
1109
+ "pnpm",
1110
+ "overrides",
1111
+ "resolutions",
1112
+ "husky",
1113
+ "simple-git-hooks",
1114
+ "lint-staged",
1115
+ "eslintConfig"
1116
+ ],
1117
+ pathPattern: "^$"
1118
+ },
1119
+ {
1120
+ order: { type: "asc" },
1121
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1122
+ },
1123
+ {
1124
+ order: { type: "asc" },
1125
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1126
+ },
1127
+ {
1128
+ order: ["types", "import", "require", "default"],
1129
+ pathPattern: "^exports.*$"
1130
+ },
1131
+ {
1132
+ order: [
1133
+ // client hooks only
1134
+ "pre-commit",
1135
+ "prepare-commit-msg",
1136
+ "commit-msg",
1137
+ "post-commit",
1138
+ "pre-rebase",
1139
+ "post-rewrite",
1140
+ "post-checkout",
1141
+ "post-merge",
1142
+ "pre-push",
1143
+ "pre-auto-gc"
1144
+ ],
1145
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1146
+ }
1147
+ ]
1148
+ }
1149
+ }
1150
+ ];
1151
+ var sortTsconfig = () => [
1152
+ {
1153
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1154
+ name: "zayne/sort/tsconfig-json",
1155
+ rules: {
1156
+ "jsonc/sort-keys": [
1157
+ "error",
1158
+ {
1159
+ order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
1160
+ pathPattern: "^$"
1161
+ },
1162
+ {
1163
+ order: [
1164
+ /* Projects */
1165
+ "incremental",
1166
+ "composite",
1167
+ "tsBuildInfoFile",
1168
+ "disableSourceOfProjectReferenceRedirect",
1169
+ "disableSolutionSearching",
1170
+ "disableReferencedProjectLoad",
1171
+ /* Language and Environment */
1172
+ "target",
1173
+ "jsx",
1174
+ "jsxFactory",
1175
+ "jsxFragmentFactory",
1176
+ "jsxImportSource",
1177
+ "lib",
1178
+ "moduleDetection",
1179
+ "noLib",
1180
+ "reactNamespace",
1181
+ "useDefineForClassFields",
1182
+ "emitDecoratorMetadata",
1183
+ "experimentalDecorators",
1184
+ /* Modules */
1185
+ "baseUrl",
1186
+ "rootDir",
1187
+ "rootDirs",
1188
+ "customConditions",
1189
+ "module",
1190
+ "moduleResolution",
1191
+ "moduleSuffixes",
1192
+ "noResolve",
1193
+ "paths",
1194
+ "resolveJsonModule",
1195
+ "resolvePackageJsonExports",
1196
+ "resolvePackageJsonImports",
1197
+ "typeRoots",
1198
+ "types",
1199
+ "allowArbitraryExtensions",
1200
+ "allowImportingTsExtensions",
1201
+ "allowUmdGlobalAccess",
1202
+ /* JavaScript Support */
1203
+ "allowJs",
1204
+ "checkJs",
1205
+ "maxNodeModuleJsDepth",
1206
+ /* Type Checking */
1207
+ "strict",
1208
+ "strictBindCallApply",
1209
+ "strictFunctionTypes",
1210
+ "strictNullChecks",
1211
+ "strictPropertyInitialization",
1212
+ "allowUnreachableCode",
1213
+ "allowUnusedLabels",
1214
+ "alwaysStrict",
1215
+ "exactOptionalPropertyTypes",
1216
+ "noFallthroughCasesInSwitch",
1217
+ "noImplicitAny",
1218
+ "noImplicitOverride",
1219
+ "noImplicitReturns",
1220
+ "noImplicitThis",
1221
+ "noPropertyAccessFromIndexSignature",
1222
+ "noUncheckedIndexedAccess",
1223
+ "noUnusedLocals",
1224
+ "noUnusedParameters",
1225
+ "useUnknownInCatchVariables",
1226
+ /* Emit */
1227
+ "declaration",
1228
+ "declarationDir",
1229
+ "declarationMap",
1230
+ "downlevelIteration",
1231
+ "emitBOM",
1232
+ "emitDeclarationOnly",
1233
+ "importHelpers",
1234
+ "importsNotUsedAsValues",
1235
+ "inlineSourceMap",
1236
+ "inlineSources",
1237
+ "mapRoot",
1238
+ "newLine",
1239
+ "noEmit",
1240
+ "noEmitHelpers",
1241
+ "noEmitOnError",
1242
+ "outDir",
1243
+ "outFile",
1244
+ "preserveConstEnums",
1245
+ "preserveValueImports",
1246
+ "removeComments",
1247
+ "sourceMap",
1248
+ "sourceRoot",
1249
+ "stripInternal",
1250
+ /* Interop Constraints */
1251
+ "allowSyntheticDefaultImports",
1252
+ "esModuleInterop",
1253
+ "forceConsistentCasingInFileNames",
1254
+ "isolatedDeclarations",
1255
+ "isolatedModules",
1256
+ "preserveSymlinks",
1257
+ "verbatimModuleSyntax",
1258
+ /* Completeness */
1259
+ "skipDefaultLibCheck",
1260
+ "skipLibCheck"
1261
+ ],
1262
+ pathPattern: "^compilerOptions$"
1263
+ }
1264
+ ]
1265
+ }
1266
+ }
1267
+ ];
1268
+
1269
+ // src/configs/jsx.ts
1270
+ var jsx = () => {
1271
+ return [
1272
+ {
1273
+ files: [GLOB_JSX, GLOB_TSX],
1274
+ languageOptions: {
1275
+ parserOptions: {
1276
+ ecmaFeatures: {
1277
+ jsx: true
1278
+ }
1279
+ }
1280
+ },
1281
+ name: "zayne/jsx/setup"
1282
+ }
1283
+ ];
1284
+ };
1285
+
1286
+ // src/factory.ts
1287
+ var getOverrides = (option) => {
1288
+ return isObject(option) ? option.overrides : {};
1289
+ };
1290
+ var defaultPluginRenaming = {
1291
+ ...eslintReactRenameMap,
1292
+ "@stylistic": "stylistic",
1293
+ "@typescript-eslint": "ts-eslint",
1294
+ "import-x": "import",
1295
+ n: "node"
1296
+ };
1297
+ var zayne = (options = {}, userConfigs = []) => {
1298
+ const {
1299
+ autoRenamePlugins = true,
1300
+ componentExts = [],
1301
+ gitignore: enableGitignore = true,
1302
+ jsonc: enableJsonc = true,
1303
+ jsx: enableJsx = true,
1304
+ perfectionist: enablePerfectionist = true,
1305
+ react: enableReact = false,
1306
+ stylistic: enableStylistic = true,
1307
+ typescript: enableTypeScript = isPackageExists("typescript"),
1308
+ unicorn: enableUnicorn = true,
1309
+ ...restOfOptions
1310
+ } = options;
1311
+ const isStylistic = Boolean(enableStylistic);
1312
+ const tsconfigPath = isObject(enableTypeScript) && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : null;
1313
+ const configs = [];
1314
+ if (enableGitignore) {
1315
+ configs.push(gitIgnores(enableGitignore));
1316
+ }
1317
+ configs.push(
1318
+ ignores(restOfOptions.ignores),
1319
+ javascript(restOfOptions.javascript),
1320
+ imports({ stylistic: isStylistic }),
1321
+ jsdoc({ stylistic: isStylistic })
1322
+ );
1323
+ if (enablePerfectionist) {
1324
+ configs.push(perfectionist({ overrides: getOverrides(enablePerfectionist) }));
1325
+ }
1326
+ if (enableUnicorn) {
1327
+ configs.push(unicorn({ overrides: getOverrides(enableUnicorn) }));
1328
+ }
1329
+ if (enableJsonc) {
1330
+ configs.push(
1331
+ jsonc({
1332
+ overrides: getOverrides(enableJsonc),
1333
+ stylistic: isStylistic
1334
+ }),
1335
+ sortPackageJson(),
1336
+ sortTsconfig()
1337
+ );
1338
+ }
1339
+ if (enableTypeScript) {
1340
+ configs.push(
1341
+ typescript({
1342
+ ...isObject(enableTypeScript) && enableTypeScript,
1343
+ componentExts,
1344
+ overrides: getOverrides(enableTypeScript),
1345
+ stylistic: true
1346
+ })
1347
+ );
1348
+ }
1349
+ if (enableJsx) {
1350
+ configs.push(jsx());
1351
+ }
1352
+ if (enableStylistic) {
1353
+ const stylisticOptions = isObject(enableStylistic) ? enableStylistic : {};
1354
+ !Object.hasOwn(stylisticOptions, "jsx") && (stylisticOptions.jsx = enableJsx);
1355
+ configs.push(stylistic(stylisticOptions));
1356
+ }
1357
+ if (enableReact) {
1358
+ configs.push(
1359
+ react({
1360
+ overrides: getOverrides(enableReact),
1361
+ typescript: Boolean(tsconfigPath)
1362
+ })
1363
+ );
1364
+ }
1365
+ if ("files" in restOfOptions) {
1366
+ throw new Error(
1367
+ '[@zayne-labs/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second config array instead.'
1368
+ );
1369
+ }
1370
+ let composer = new FlatConfigComposer();
1371
+ composer = composer.append(...configs, ...userConfigs);
1372
+ if (autoRenamePlugins) {
1373
+ composer = composer.renamePlugins(defaultPluginRenaming);
1374
+ }
1375
+ return composer;
1376
+ };
1377
+
1378
+ export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, combine, zayne as default, defaultPluginRenaming, ensurePackages, eslintReactRenameMap, gitIgnores, ignores, imports, interopDefault, isPackageInScope, javascript, jsdoc, jsonc, perfectionist, react, renamePluginInConfigs, renamePlugins, renameRules, sortPackageJson, sortTsconfig, stylistic, tailwindcss, typescript, unicorn, zayne };
1379
+ //# sourceMappingURL=index.js.map
1380
+ //# sourceMappingURL=index.js.map