@frabbit/eslint-config 1.5.15 → 7.4.6

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.mjs ADDED
@@ -0,0 +1,1094 @@
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+ const __cjs_require = __cjs_createRequire(import.meta.url);
3
+ import baselineJs from "eslint-plugin-baseline-js";
4
+ const configJs = __cjs_require("@eslint/js");
5
+ import pluginMarkdown from "@eslint/markdown";
6
+ const configComments = __cjs_require("@eslint-community/eslint-plugin-eslint-comments/configs");
7
+ import pluginIgnore from "eslint-config-flat-gitignore";
8
+ import pluginAntfu from "eslint-plugin-antfu";
9
+ import configCommand from "eslint-plugin-command/config";
10
+ import pluginDeMorgan from "eslint-plugin-de-morgan";
11
+ import pluginImport from "eslint-plugin-import-x";
12
+ import pluginJsdoc from "eslint-plugin-jsdoc";
13
+ const pluginJsonc = __cjs_require("eslint-plugin-jsonc");
14
+ const pluginNode = __cjs_require("eslint-plugin-n");
15
+ const pluginPerfectionist = __cjs_require("eslint-plugin-perfectionist");
16
+ import pluginPnpm from "eslint-plugin-pnpm";
17
+ const pluginPrettier = __cjs_require("eslint-plugin-prettier");
18
+ const pluginPrettierRecommended = __cjs_require("eslint-plugin-prettier/recommended");
19
+ const pluginSecurity = __cjs_require("eslint-plugin-security");
20
+ const pluginSonarJS = __cjs_require("eslint-plugin-sonarjs");
21
+ import pluginSxzz from "eslint-plugin-sxzz";
22
+ import pluginUnicorn from "eslint-plugin-unicorn";
23
+ import pluginUnusedImports from "eslint-plugin-unused-imports";
24
+ const pluginVue = __cjs_require("eslint-plugin-vue");
25
+ const pluginYml = __cjs_require("eslint-plugin-yml");
26
+ const parserJsonc = __cjs_require("jsonc-eslint-parser");
27
+ const tseslint = __cjs_require("typescript-eslint");
28
+ const parserVue = __cjs_require("vue-eslint-parser");
29
+ const parserYml = __cjs_require("yaml-eslint-parser");
30
+ const globals = __cjs_require("globals");
31
+ const {
32
+ configs
33
+ } = __cjs_require("eslint-plugin-regexp");
34
+ const {
35
+ defineConfig
36
+ } = __cjs_require("eslint/config");
37
+ import process from "node:process";
38
+ import { isPackageExists } from "local-pkg";
39
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
40
+
41
+ //#region src/configs/baseline.ts
42
+ const baseline = (options = {}) => [{
43
+ name: "frabbit/baseline",
44
+ plugins: { "baseline-js": baselineJs },
45
+ rules: { "baseline-js/use-baseline": ["warn", {
46
+ ignoreFeatures: ["functions-caller-arguments"],
47
+ includeJsBuiltins: { preset: "auto" },
48
+ includeWebApis: { preset: "auto" },
49
+ ...options
50
+ }] }
51
+ }];
52
+
53
+ //#endregion
54
+ //#region src/configs/command.ts
55
+ const command = () => [{
56
+ ...configCommand(),
57
+ name: "frabbit/command"
58
+ }];
59
+
60
+ //#endregion
61
+ //#region src/configs/comments.ts
62
+ const comments = () => [{
63
+ ...configComments.recommended,
64
+ name: "frabbit/comments/recommended"
65
+ }, {
66
+ name: "frabbit/comments",
67
+ rules: { "@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }] }
68
+ }];
69
+
70
+ //#endregion
71
+ //#region src/configs/de-morgan.ts
72
+ const deMorgan = () => [{
73
+ ...pluginDeMorgan.configs.recommended,
74
+ name: "frabbit/de-morgan"
75
+ }];
76
+
77
+ //#endregion
78
+ //#region src/globs.ts
79
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
80
+ const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
81
+ const GLOB_JS = "**/*.?([cm])js";
82
+ const GLOB_JSX = "**/*.jsx";
83
+ const GLOB_TS = "**/*.?([cm])ts";
84
+ const GLOB_TSX = "**/*.tsx";
85
+ const GLOB_STYLE = "**/*.{c,le,sc}ss";
86
+ const GLOB_CSS = "**/*.css";
87
+ const GLOB_LESS = "**/*.less";
88
+ const GLOB_SCSS = "**/*.scss";
89
+ const GLOB_JSON = "**/*.json";
90
+ const GLOB_JSON5 = "**/*.json5";
91
+ const GLOB_JSONC = "**/*.jsonc";
92
+ const GLOB_MARKDOWN = "**/*.md";
93
+ const GLOB_VUE = "**/*.vue";
94
+ const GLOB_NUXT_PAGE = "pages/**/*.vue";
95
+ const GLOB_NUXT_LAYOUTS = "layouts/**/*.vue";
96
+ const GLOB_YAML = "**/*.y?(a)ml";
97
+ const GLOB_HTML = "**/*.htm?(l)";
98
+ const GLOB_ALL_SRC = [
99
+ GLOB_SRC,
100
+ GLOB_STYLE,
101
+ GLOB_JSON,
102
+ GLOB_JSON5,
103
+ GLOB_MARKDOWN,
104
+ GLOB_VUE,
105
+ GLOB_NUXT_PAGE,
106
+ GLOB_NUXT_LAYOUTS,
107
+ GLOB_YAML,
108
+ GLOB_HTML
109
+ ];
110
+ const GLOB_NODE_MODULES = "**/node_modules";
111
+ const GLOB_DIST = "**/dist";
112
+ const GLOB_LOCKFILE = [
113
+ "**/package-lock.json",
114
+ "**/yarn.lock",
115
+ "**/pnpm-lock.yaml",
116
+ "**/bun.lockb"
117
+ ];
118
+ const GLOB_EXCLUDE = [
119
+ GLOB_NODE_MODULES,
120
+ GLOB_DIST,
121
+ ...GLOB_LOCKFILE,
122
+ "output",
123
+ "**/coverage",
124
+ "**/temp",
125
+ "**/fixtures",
126
+ "**/.vitepress/cache",
127
+ "**/.nuxt",
128
+ "**/.vercel",
129
+ "**/.changeset",
130
+ "**/.idea",
131
+ "**/.output",
132
+ "**/.vite-inspect",
133
+ "**/.nitro",
134
+ "**/CHANGELOG*.md",
135
+ "**/*.min.*",
136
+ "**/LICENSE*",
137
+ "**/__snapshots__",
138
+ "**/auto-import?(s).d.ts",
139
+ "**/components.d.ts"
140
+ ];
141
+
142
+ //#endregion
143
+ //#region src/configs/ignores.ts
144
+ const ignores = () => [{
145
+ ignores: GLOB_EXCLUDE,
146
+ name: "frabbit/global-ignores"
147
+ }, {
148
+ ...pluginIgnore({ strict: false }),
149
+ name: "frabbit/gitignore"
150
+ }];
151
+
152
+ //#endregion
153
+ //#region src/configs/imports.ts
154
+ const imports = () => [{
155
+ name: "frabbit/imports",
156
+ plugins: {
157
+ antfu: pluginAntfu,
158
+ import: pluginImport
159
+ },
160
+ rules: {
161
+ "antfu/import-dedupe": "error",
162
+ "import/first": "error",
163
+ "import/newline-after-import": ["error", { count: 1 }],
164
+ "import/no-default-export": "error",
165
+ "import/no-duplicates": "error",
166
+ "import/no-mutable-exports": "error",
167
+ "import/no-named-default": "error",
168
+ "import/no-self-import": "error",
169
+ "import/no-webpack-loader-syntax": "error"
170
+ }
171
+ }, {
172
+ files: [
173
+ `**/*config*.${GLOB_SRC_EXT}`,
174
+ `**/views/${GLOB_SRC}`,
175
+ `**/pages/${GLOB_SRC}`,
176
+ `**/{index,vite,esbuild,rollup,webpack,rspack}.ts`,
177
+ "**/*.d.ts",
178
+ `${GLOB_MARKDOWN}/**`
179
+ ],
180
+ plugins: { import: pluginImport },
181
+ rules: { "import/no-default-export": "off" }
182
+ }];
183
+
184
+ //#endregion
185
+ //#region src/configs/javascript.ts
186
+ const restrictedSyntaxJs = ["ForInStatement", "LabeledStatement"];
187
+ const javascript = () => [{
188
+ ...configJs.configs.recommended,
189
+ name: "frabbit/js/recommended"
190
+ }, {
191
+ languageOptions: {
192
+ globals: {
193
+ ...globals.browser,
194
+ ...globals.es2026,
195
+ ...globals.node
196
+ },
197
+ parserOptions: {
198
+ ecmaFeatures: { jsx: true },
199
+ sourceType: "module"
200
+ },
201
+ sourceType: "module"
202
+ },
203
+ name: "frabbit/js",
204
+ plugins: {
205
+ sxzz: pluginSxzz,
206
+ "unused-imports": pluginUnusedImports
207
+ },
208
+ rules: {
209
+ "array-callback-return": "error",
210
+ "block-scoped-var": "error",
211
+ "dot-notation": "warn",
212
+ eqeqeq: ["error", "smart"],
213
+ "no-alert": "warn",
214
+ "no-console": ["warn", { allow: [
215
+ "warn",
216
+ "error",
217
+ "info",
218
+ "clear"
219
+ ] }],
220
+ "no-debugger": "warn",
221
+ "no-duplicate-imports": "error",
222
+ "no-empty": ["error", { allowEmptyCatch: true }],
223
+ "no-fallthrough": ["warn", { commentPattern: String.raw`break[\s\w]*omitted` }],
224
+ "no-inner-declarations": "error",
225
+ "no-lonely-if": "error",
226
+ "no-multi-str": "error",
227
+ "no-restricted-syntax": ["error", ...restrictedSyntaxJs],
228
+ "no-unused-expressions": ["error", {
229
+ allowShortCircuit: true,
230
+ allowTaggedTemplates: true,
231
+ allowTernary: true
232
+ }],
233
+ "no-unused-vars": "off",
234
+ "no-useless-call": "error",
235
+ "no-useless-computed-key": "error",
236
+ "no-useless-constructor": "error",
237
+ "no-useless-rename": "error",
238
+ "no-var": "error",
239
+ "no-void": "error",
240
+ "object-shorthand": [
241
+ "error",
242
+ "always",
243
+ {
244
+ avoidQuotes: true,
245
+ ignoreConstructors: false
246
+ }
247
+ ],
248
+ "one-var": ["error", { initialized: "never" }],
249
+ "prefer-arrow-callback": ["error", {
250
+ allowNamedFunctions: false,
251
+ allowUnboundThis: true
252
+ }],
253
+ "prefer-const": ["warn", {
254
+ destructuring: "all",
255
+ ignoreReadBeforeAssign: true
256
+ }],
257
+ "prefer-exponentiation-operator": "error",
258
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
259
+ "prefer-rest-params": "error",
260
+ "prefer-spread": "error",
261
+ "prefer-template": "error",
262
+ "require-await": "error",
263
+ "sxzz/prefer-string-function": "warn",
264
+ "unicode-bom": ["error", "never"],
265
+ "unused-imports/no-unused-imports": "warn",
266
+ "unused-imports/no-unused-vars": ["error", {
267
+ args: "after-used",
268
+ ignoreRestSiblings: true
269
+ }],
270
+ "use-isnan": ["error", {
271
+ enforceForIndexOf: true,
272
+ enforceForSwitchCase: true
273
+ }],
274
+ "valid-typeof": ["error", { requireStringLiterals: true }],
275
+ "vars-on-top": "error"
276
+ }
277
+ }];
278
+
279
+ //#endregion
280
+ //#region src/configs/jsdoc.ts
281
+ const jsdoc = () => [{
282
+ name: "frabbit/jsdoc",
283
+ plugins: { jsdoc: pluginJsdoc },
284
+ rules: {
285
+ "jsdoc/check-access": "warn",
286
+ "jsdoc/check-param-names": "warn",
287
+ "jsdoc/check-property-names": "warn",
288
+ "jsdoc/check-types": "warn",
289
+ "jsdoc/empty-tags": "warn",
290
+ "jsdoc/implements-on-classes": "warn",
291
+ "jsdoc/no-defaults": "warn",
292
+ "jsdoc/no-multi-asterisks": "warn",
293
+ "jsdoc/require-param-name": "warn",
294
+ "jsdoc/require-property": "warn",
295
+ "jsdoc/require-property-description": "warn",
296
+ "jsdoc/require-property-name": "warn",
297
+ "jsdoc/require-returns-check": "warn",
298
+ "jsdoc/require-returns-description": "warn",
299
+ "jsdoc/require-yields-check": "warn"
300
+ }
301
+ }];
302
+
303
+ //#endregion
304
+ //#region src/configs/jsonc.ts
305
+ const jsonc = () => [{
306
+ files: [
307
+ GLOB_JSON,
308
+ GLOB_JSON5,
309
+ GLOB_JSONC
310
+ ],
311
+ languageOptions: { parser: parserJsonc },
312
+ name: "frabbit/json",
313
+ plugins: { jsonc: pluginJsonc },
314
+ rules: {
315
+ ...pluginJsonc.configs["recommended-with-jsonc"].rules,
316
+ "jsonc/quote-props": "off",
317
+ "jsonc/quotes": "off"
318
+ }
319
+ }];
320
+
321
+ //#endregion
322
+ //#region src/configs/markdown.ts
323
+ const markdown = () => [...pluginMarkdown.configs.processor.map((config) => ({
324
+ ...config,
325
+ name: `frabbit/${config.name || "anonymous"}`
326
+ })), {
327
+ files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
328
+ name: "frabbit/markdown-rules",
329
+ rules: {
330
+ "@typescript-eslint/comma-dangle": "off",
331
+ "@typescript-eslint/consistent-type-imports": "off",
332
+ "@typescript-eslint/no-extraneous-class": "off",
333
+ "@typescript-eslint/no-namespace": "off",
334
+ "@typescript-eslint/no-redeclare": "off",
335
+ "@typescript-eslint/no-require-imports": "off",
336
+ "@typescript-eslint/no-unused-expressions": "off",
337
+ "@typescript-eslint/no-unused-vars": "off",
338
+ "@typescript-eslint/no-use-before-define": "off",
339
+ "baseline-js/use-baseline": "off",
340
+ "no-alert": "off",
341
+ "no-console": "off",
342
+ "no-restricted-imports": "off",
343
+ "no-undef": "off",
344
+ "no-unused-expressions": "off",
345
+ "no-unused-vars": "off",
346
+ "node/prefer-global/buffer": "off",
347
+ "node/prefer-global/process": "off",
348
+ "unicorn/no-anonymous-default-export": "off",
349
+ "unicorn/no-useless-undefined": "off",
350
+ "unused-imports/no-unused-imports": "off",
351
+ "unused-imports/no-unused-vars": "off"
352
+ }
353
+ }];
354
+
355
+ //#endregion
356
+ //#region src/configs/node.ts
357
+ const node = () => [{
358
+ name: "frabbit/node",
359
+ plugins: { node: pluginNode },
360
+ rules: {
361
+ "node/handle-callback-err": ["error", "^(err|error)$"],
362
+ "node/no-deprecated-api": "error",
363
+ "node/no-exports-assign": "error",
364
+ "node/no-new-require": "error",
365
+ "node/no-path-concat": "error",
366
+ "node/no-unsupported-features/es-builtins": "error",
367
+ "node/prefer-global/buffer": ["error", "never"],
368
+ "node/prefer-global/process": ["error", "never"],
369
+ "node/process-exit-as-throw": "error"
370
+ }
371
+ }];
372
+
373
+ //#endregion
374
+ //#region src/configs/pnpm.ts
375
+ async function pnpm() {
376
+ return [{
377
+ files: ["package.json", "**/package.json"],
378
+ languageOptions: { parser: await import("jsonc-eslint-parser") },
379
+ name: "frabbit/pnpm/package-json",
380
+ plugins: { pnpm: pluginPnpm },
381
+ rules: {
382
+ "pnpm/json-enforce-catalog": "error",
383
+ "pnpm/json-prefer-workspace-settings": "error",
384
+ "pnpm/json-valid-catalog": "error"
385
+ }
386
+ }, {
387
+ files: ["pnpm-workspace.yaml"],
388
+ languageOptions: { parser: await import("yaml-eslint-parser") },
389
+ name: "frabbit/pnpm/pnpm-workspace-yaml",
390
+ plugins: { pnpm: pluginPnpm },
391
+ rules: {
392
+ "pnpm/yaml-no-duplicate-catalog-item": "error",
393
+ "pnpm/yaml-no-unused-catalog-item": "error"
394
+ }
395
+ }];
396
+ }
397
+
398
+ //#endregion
399
+ //#region src/configs/prettier.ts
400
+ const rules = { ...pluginPrettierRecommended.rules };
401
+ delete rules["vue/html-self-closing"];
402
+ const prettier = () => [{
403
+ name: "frabbit/prettier",
404
+ plugins: { prettier: pluginPrettier },
405
+ rules: {
406
+ ...rules,
407
+ "prettier/prettier": "warn"
408
+ }
409
+ }];
410
+
411
+ //#endregion
412
+ //#region src/configs/regexp.ts
413
+ const regexp = () => [{
414
+ ...configs["flat/recommended"],
415
+ name: "frabbit/regexp"
416
+ }];
417
+
418
+ //#endregion
419
+ //#region src/configs/security.ts
420
+ const security = () => [{
421
+ name: "frabbit/security",
422
+ plugins: { security: pluginSecurity },
423
+ rules: {
424
+ "security/detect-bidi-characters": "warn",
425
+ "security/detect-buffer-noassert": "warn",
426
+ "security/detect-child-process": "warn",
427
+ "security/detect-disable-mustache-escape": "warn",
428
+ "security/detect-eval-with-expression": "warn",
429
+ "security/detect-new-buffer": "warn",
430
+ "security/detect-no-csrf-before-method-override": "warn",
431
+ "security/detect-non-literal-fs-filename": "warn",
432
+ "security/detect-non-literal-regexp": "warn",
433
+ "security/detect-non-literal-require": "warn",
434
+ "security/detect-object-injection": "warn",
435
+ "security/detect-possible-timing-attacks": "warn",
436
+ "security/detect-pseudoRandomBytes": "warn",
437
+ "security/detect-unsafe-regex": "warn"
438
+ }
439
+ }];
440
+
441
+ //#endregion
442
+ //#region src/configs/sonarjs.ts
443
+ const sonarjs = () => [{
444
+ name: "frabbit/sonarjs",
445
+ plugins: { sonarjs: pluginSonarJS },
446
+ rules: {
447
+ "sonarjs/cognitive-complexity": "error",
448
+ "sonarjs/elseif-without-else": "off",
449
+ "sonarjs/max-switch-cases": "error",
450
+ "sonarjs/no-all-duplicated-branches": "error",
451
+ "sonarjs/no-collapsible-if": "error",
452
+ "sonarjs/no-collection-size-mischeck": "error",
453
+ "sonarjs/no-duplicate-string": "error",
454
+ "sonarjs/no-duplicated-branches": "error",
455
+ "sonarjs/no-element-overwrite": "error",
456
+ "sonarjs/no-empty-collection": "error",
457
+ "sonarjs/no-extra-arguments": "error",
458
+ "sonarjs/no-gratuitous-expressions": "error",
459
+ "sonarjs/no-identical-conditions": "error",
460
+ "sonarjs/no-identical-expressions": "error",
461
+ "sonarjs/no-identical-functions": "error",
462
+ "sonarjs/no-ignored-return": "error",
463
+ "sonarjs/no-inverted-boolean-check": "off",
464
+ "sonarjs/no-nested-switch": "error",
465
+ "sonarjs/no-nested-template-literals": "error",
466
+ "sonarjs/no-redundant-boolean": "error",
467
+ "sonarjs/no-redundant-jump": "error",
468
+ "sonarjs/no-same-line-conditional": "error",
469
+ "sonarjs/no-small-switch": "error",
470
+ "sonarjs/no-unused-collection": "error",
471
+ "sonarjs/no-use-of-empty-return-value": "error",
472
+ "sonarjs/no-useless-catch": "error",
473
+ "sonarjs/non-existent-operator": "error",
474
+ "sonarjs/prefer-immediate-return": "error",
475
+ "sonarjs/prefer-object-literal": "error",
476
+ "sonarjs/prefer-single-boolean-return": "error",
477
+ "sonarjs/prefer-while": "error"
478
+ }
479
+ }];
480
+
481
+ //#endregion
482
+ //#region src/configs/sort.ts
483
+ const sortPackageJson = () => [{
484
+ files: ["**/package.json"],
485
+ name: "frabbit/sort/package.json",
486
+ rules: {
487
+ "jsonc/sort-array-values": ["error", {
488
+ order: { type: "asc" },
489
+ pathPattern: "^files$"
490
+ }],
491
+ "jsonc/sort-keys": [
492
+ "error",
493
+ {
494
+ order: [
495
+ "publisher",
496
+ "name",
497
+ "displayName",
498
+ "type",
499
+ "version",
500
+ "private",
501
+ "packageManager",
502
+ "description",
503
+ "author",
504
+ "contributors",
505
+ "license",
506
+ "funding",
507
+ "homepage",
508
+ "repository",
509
+ "bugs",
510
+ "keywords",
511
+ "categories",
512
+ "sideEffects",
513
+ "imports",
514
+ "exports",
515
+ "main",
516
+ "module",
517
+ "unpkg",
518
+ "jsdelivr",
519
+ "types",
520
+ "typesVersions",
521
+ "bin",
522
+ "icon",
523
+ "files",
524
+ "engines",
525
+ "activationEvents",
526
+ "contributes",
527
+ "scripts",
528
+ "peerDependencies",
529
+ "peerDependenciesMeta",
530
+ "dependencies",
531
+ "optionalDependencies",
532
+ "devDependencies",
533
+ "pnpm",
534
+ "overrides",
535
+ "resolutions",
536
+ "husky",
537
+ "simple-git-hooks",
538
+ "lint-staged",
539
+ "eslintConfig",
540
+ "prettier",
541
+ "tsdown"
542
+ ],
543
+ pathPattern: "^$"
544
+ },
545
+ {
546
+ order: { type: "asc" },
547
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
548
+ },
549
+ {
550
+ order: [
551
+ "types",
552
+ "require",
553
+ "import",
554
+ "default"
555
+ ],
556
+ pathPattern: "^exports.*$"
557
+ },
558
+ {
559
+ order: { type: "asc" },
560
+ pathPattern: String.raw`^(?:resolutions|overrides|pnpm\.overrides)$`
561
+ }
562
+ ]
563
+ }
564
+ }];
565
+ const sortTsconfig = () => [{
566
+ files: ["**/[jt]sconfig.json", "**/[jt]sconfig.*.json"],
567
+ name: "frabbit/sort/tsconfig",
568
+ rules: { "jsonc/sort-keys": [
569
+ "error",
570
+ {
571
+ order: [
572
+ "extends",
573
+ "compilerOptions",
574
+ "references",
575
+ "files",
576
+ "include",
577
+ "exclude"
578
+ ],
579
+ pathPattern: "^$"
580
+ },
581
+ {
582
+ order: [
583
+ "incremental",
584
+ "composite",
585
+ "tsBuildInfoFile",
586
+ "disableSourceOfProjectReferenceRedirect",
587
+ "disableSolutionSearching",
588
+ "disableReferencedProjectLoad",
589
+ "target",
590
+ "jsx",
591
+ "jsxFactory",
592
+ "jsxFragmentFactory",
593
+ "jsxImportSource",
594
+ "lib",
595
+ "moduleDetection",
596
+ "noLib",
597
+ "reactNamespace",
598
+ "useDefineForClassFields",
599
+ "emitDecoratorMetadata",
600
+ "experimentalDecorators",
601
+ "libReplacement",
602
+ "baseUrl",
603
+ "rootDir",
604
+ "rootDirs",
605
+ "customConditions",
606
+ "module",
607
+ "moduleResolution",
608
+ "moduleSuffixes",
609
+ "noResolve",
610
+ "paths",
611
+ "resolveJsonModule",
612
+ "resolvePackageJsonExports",
613
+ "resolvePackageJsonImports",
614
+ "typeRoots",
615
+ "types",
616
+ "allowArbitraryExtensions",
617
+ "allowImportingTsExtensions",
618
+ "allowUmdGlobalAccess",
619
+ "allowJs",
620
+ "checkJs",
621
+ "maxNodeModuleJsDepth",
622
+ "strict",
623
+ "strictBindCallApply",
624
+ "strictFunctionTypes",
625
+ "strictNullChecks",
626
+ "strictPropertyInitialization",
627
+ "allowUnreachableCode",
628
+ "allowUnusedLabels",
629
+ "alwaysStrict",
630
+ "exactOptionalPropertyTypes",
631
+ "noFallthroughCasesInSwitch",
632
+ "noImplicitAny",
633
+ "noImplicitOverride",
634
+ "noImplicitReturns",
635
+ "noImplicitThis",
636
+ "noPropertyAccessFromIndexSignature",
637
+ "noUncheckedIndexedAccess",
638
+ "noUnusedLocals",
639
+ "noUnusedParameters",
640
+ "useUnknownInCatchVariables",
641
+ "declaration",
642
+ "declarationDir",
643
+ "declarationMap",
644
+ "downlevelIteration",
645
+ "emitBOM",
646
+ "emitDeclarationOnly",
647
+ "importHelpers",
648
+ "importsNotUsedAsValues",
649
+ "inlineSourceMap",
650
+ "inlineSources",
651
+ "mapRoot",
652
+ "newLine",
653
+ "noEmit",
654
+ "noEmitHelpers",
655
+ "noEmitOnError",
656
+ "outDir",
657
+ "outFile",
658
+ "preserveConstEnums",
659
+ "preserveValueImports",
660
+ "removeComments",
661
+ "sourceMap",
662
+ "sourceRoot",
663
+ "stripInternal",
664
+ "allowSyntheticDefaultImports",
665
+ "esModuleInterop",
666
+ "forceConsistentCasingInFileNames",
667
+ "isolatedDeclarations",
668
+ "isolatedModules",
669
+ "preserveSymlinks",
670
+ "verbatimModuleSyntax",
671
+ "erasableSyntaxOnly",
672
+ "skipDefaultLibCheck",
673
+ "skipLibCheck"
674
+ ],
675
+ pathPattern: "^compilerOptions$"
676
+ }
677
+ ] }
678
+ }];
679
+ const sortPnpmWorkspace = () => [{
680
+ files: ["**/pnpm-workspace.yaml"],
681
+ name: "frabbit/sort/pnpm-workspace",
682
+ rules: { "yml/sort-keys": [
683
+ "error",
684
+ {
685
+ order: [
686
+ "packages",
687
+ "overrides",
688
+ "patchedDependencies",
689
+ "defines",
690
+ "catalog",
691
+ "catalogs",
692
+ { order: { type: "asc" } }
693
+ ],
694
+ pathPattern: "^$"
695
+ },
696
+ {
697
+ allowLineSeparatedGroups: true,
698
+ order: { type: "asc" },
699
+ pathPattern: "^(catalog|catalogs|overrides)$"
700
+ },
701
+ {
702
+ allowLineSeparatedGroups: true,
703
+ order: { type: "asc" },
704
+ pathPattern: String.raw`^catalogs\..+$`
705
+ }
706
+ ] }
707
+ }];
708
+ const sortImports = () => [{
709
+ name: "frabbit/sort/imports",
710
+ plugins: { perfectionist: pluginPerfectionist },
711
+ rules: {
712
+ "perfectionist/sort-exports": ["error", {
713
+ groups: ["value-export", "type-export"],
714
+ type: "natural"
715
+ }],
716
+ "perfectionist/sort-imports": ["warn", {
717
+ groups: [
718
+ "builtin",
719
+ "external",
720
+ "internal",
721
+ "internal-type",
722
+ "parent",
723
+ "parent-type",
724
+ "sibling",
725
+ "sibling-type",
726
+ "index",
727
+ "index-type",
728
+ "object",
729
+ "type",
730
+ "side-effect",
731
+ "side-effect-style"
732
+ ],
733
+ internalPattern: ["^[~@#]/.*"],
734
+ newlinesBetween: "ignore",
735
+ type: "natural"
736
+ }],
737
+ "perfectionist/sort-named-exports": ["warn", {
738
+ groupKind: "values-first",
739
+ type: "natural"
740
+ }],
741
+ "perfectionist/sort-named-imports": ["warn", {
742
+ groupKind: "values-first",
743
+ type: "natural"
744
+ }]
745
+ }
746
+ }];
747
+
748
+ //#endregion
749
+ //#region src/configs/special-cases.ts
750
+ const specialCases = () => [
751
+ {
752
+ files: ["**/scripts/*", "**/cli.*"],
753
+ name: "frabbit/special/cli",
754
+ rules: { "no-console": "off" }
755
+ },
756
+ {
757
+ files: [`**/*.{test,spec}.${GLOB_SRC_EXT}`],
758
+ name: "frabbit/special/tests",
759
+ rules: {
760
+ "baseline-js/use-baseline": "off",
761
+ "no-unused-expressions": "off",
762
+ "unicorn/consistent-function-scoping": "off"
763
+ }
764
+ },
765
+ {
766
+ files: [
767
+ `**/*config*.${GLOB_SRC_EXT}`,
768
+ `**/{views,pages,routes,middleware,plugins,api,modules}/${GLOB_SRC}`,
769
+ `**/{index,vite,esbuild,rollup,rolldown,webpack,rspack,farm,unloader,nuxt}.${GLOB_SRC_EXT}`,
770
+ "**/*.d.ts",
771
+ `${GLOB_MARKDOWN}/**`,
772
+ "**/.prettierrc*"
773
+ ],
774
+ name: "frabbit/special/allow-default-export",
775
+ plugins: { import: pluginImport },
776
+ rules: { "import/no-default-export": "off" }
777
+ },
778
+ {
779
+ files: ["**/ISSUE_TEMPLATE/**"],
780
+ name: "frabbit/special/github",
781
+ rules: { "unicorn/filename-case": "off" }
782
+ },
783
+ {
784
+ files: [GLOB_JSX, GLOB_TSX],
785
+ name: "frabbit/special/components",
786
+ rules: { "unicorn/no-anonymous-default-export": "off" }
787
+ }
788
+ ];
789
+
790
+ //#endregion
791
+ //#region src/configs/typescript.ts
792
+ const typescriptCore = defineConfig({
793
+ extends: [...tseslint.configs.recommended],
794
+ files: [GLOB_TS, GLOB_TSX],
795
+ name: "frabbit/typescript",
796
+ rules: {
797
+ "@typescript-eslint/ban-ts-comment": "off",
798
+ "@typescript-eslint/consistent-type-assertions": ["error", {
799
+ assertionStyle: "as",
800
+ objectLiteralTypeAssertions: "allow-as-parameter"
801
+ }],
802
+ "@typescript-eslint/consistent-type-imports": ["error", {
803
+ disallowTypeAnnotations: false,
804
+ fixStyle: "inline-type-imports"
805
+ }],
806
+ "@typescript-eslint/method-signature-style": ["error", "property"],
807
+ "@typescript-eslint/no-empty-object-type": "off",
808
+ "@typescript-eslint/no-explicit-any": "off",
809
+ "@typescript-eslint/no-import-type-side-effects": "error",
810
+ "@typescript-eslint/no-non-null-assertion": "off",
811
+ "@typescript-eslint/no-redeclare": "error",
812
+ "@typescript-eslint/no-unsafe-function-type": "off",
813
+ "@typescript-eslint/no-unused-expressions": ["error", {
814
+ allowShortCircuit: true,
815
+ allowTaggedTemplates: true,
816
+ allowTernary: true
817
+ }],
818
+ "@typescript-eslint/no-unused-vars": "off",
819
+ "@typescript-eslint/no-useless-constructor": "error",
820
+ "@typescript-eslint/prefer-as-const": "warn",
821
+ "@typescript-eslint/prefer-literal-enum-member": ["error", { allowBitwiseExpressions: true }],
822
+ "no-restricted-syntax": [
823
+ "error",
824
+ ...restrictedSyntaxJs,
825
+ "TSEnumDeclaration[const=true]"
826
+ ]
827
+ }
828
+ });
829
+ const typescript = () => [
830
+ ...typescriptCore,
831
+ {
832
+ files: ["**/*.d.ts"],
833
+ name: "frabbit/typescript/dts-rules",
834
+ rules: {
835
+ "eslint-comments/no-unlimited-disable": "off",
836
+ "import/no-duplicates": "off",
837
+ "no-restricted-syntax": "off",
838
+ "unused-imports/no-unused-vars": "off"
839
+ }
840
+ },
841
+ {
842
+ files: [GLOB_JS, "**/*.cjs"],
843
+ name: "frabbit/typescript/cjs-rules",
844
+ rules: { "@typescript-eslint/no-require-imports": "off" }
845
+ }
846
+ ];
847
+
848
+ //#endregion
849
+ //#region src/configs/unicorn.ts
850
+ const unicorn = () => [{
851
+ ...pluginUnicorn.configs.unopinionated,
852
+ name: "frabbit/unicorn/unopinionated"
853
+ }, {
854
+ name: "frabbit/unicorn",
855
+ rules: {
856
+ "unicorn/catch-error-name": "error",
857
+ "unicorn/consistent-empty-array-spread": "error",
858
+ "unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: false }],
859
+ "unicorn/custom-error-definition": "error",
860
+ "unicorn/filename-case": ["error", {
861
+ cases: {
862
+ kebabCase: true,
863
+ pascalCase: true
864
+ },
865
+ ignore: [/^[A-Z]+\..*$/, /import_map\.json/]
866
+ }],
867
+ "unicorn/import-style": "off",
868
+ "unicorn/no-abusive-eslint-disable": "off",
869
+ "unicorn/no-array-for-each": "off",
870
+ "unicorn/no-empty-file": "off",
871
+ "unicorn/no-for-loop": "error",
872
+ "unicorn/no-process-exit": "off",
873
+ "unicorn/no-this-assignment": "off",
874
+ "unicorn/no-unreadable-array-destructuring": "off",
875
+ "unicorn/no-useless-undefined": ["error", {
876
+ checkArguments: false,
877
+ checkArrowFunctionBody: false
878
+ }],
879
+ "unicorn/numeric-separators-style": "off",
880
+ "unicorn/prefer-module": "off",
881
+ "unicorn/prefer-query-selector": "error",
882
+ "unicorn/prefer-ternary": "off",
883
+ "unicorn/prefer-top-level-await": "off",
884
+ "unicorn/require-module-specifiers": "off"
885
+ }
886
+ }];
887
+
888
+ //#endregion
889
+ //#region src/configs/unocss.ts
890
+ const unocss = async () => {
891
+ const { default: unocss$1 } = await import("@unocss/eslint-plugin");
892
+ return [{
893
+ ...unocss$1.configs.flat,
894
+ name: "frabbit/unocss"
895
+ }];
896
+ };
897
+
898
+ //#endregion
899
+ //#region src/configs/vue.ts
900
+ const reactivityTransform = () => [{
901
+ languageOptions: { globals: {
902
+ $: "readonly",
903
+ $$: "readonly",
904
+ $computed: "readonly",
905
+ $customRef: "readonly",
906
+ $ref: "readonly",
907
+ $shallowRef: "readonly",
908
+ $toRef: "readonly"
909
+ } },
910
+ name: "frabbit/vue/reactivity-transform",
911
+ plugins: { vue: pluginVue },
912
+ rules: { "vue/no-setup-props-reactivity-loss": "off" }
913
+ }];
914
+ const vueTs = typescriptCore.filter((config) => config.name !== "typescript-eslint/base").map((config) => {
915
+ return {
916
+ ...config,
917
+ files: [GLOB_VUE],
918
+ name: `frabbit/vue/${config.name?.replace("frabbit/", "") || "anonymous"}`
919
+ };
920
+ });
921
+ const recommendedRules = pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
922
+ ...acc,
923
+ ...c
924
+ }), {});
925
+ const vue = () => [
926
+ ...vueTs,
927
+ {
928
+ files: [GLOB_VUE],
929
+ languageOptions: {
930
+ parser: parserVue,
931
+ parserOptions: {
932
+ ecmaFeatures: { jsx: true },
933
+ extraFileExtensions: [".vue"],
934
+ parser: tseslint.parser,
935
+ sourceType: "module"
936
+ }
937
+ },
938
+ name: "frabbit/vue",
939
+ plugins: {
940
+ "@typescript-eslint": tseslint.plugin,
941
+ vue: pluginVue
942
+ },
943
+ processor: pluginVue.processors[".vue"],
944
+ rules: {
945
+ ...recommendedRules,
946
+ "vue/block-order": ["error", { order: [
947
+ "script",
948
+ "template",
949
+ "style"
950
+ ] }],
951
+ "vue/custom-event-name-casing": ["error", "camelCase"],
952
+ "vue/eqeqeq": ["error", "smart"],
953
+ "vue/html-self-closing": ["error", {
954
+ html: {
955
+ component: "always",
956
+ normal: "always",
957
+ void: "any"
958
+ },
959
+ math: "always",
960
+ svg: "always"
961
+ }],
962
+ "vue/max-attributes-per-line": "off",
963
+ "vue/multi-word-component-names": "off",
964
+ "vue/no-constant-condition": "warn",
965
+ "vue/no-empty-pattern": "error",
966
+ "vue/no-loss-of-precision": "error",
967
+ "vue/no-ref-as-operand": "off",
968
+ "vue/no-unused-refs": "error",
969
+ "vue/no-useless-v-bind": "error",
970
+ "vue/no-v-html": "off",
971
+ "vue/object-shorthand": [
972
+ "error",
973
+ "always",
974
+ {
975
+ avoidQuotes: true,
976
+ ignoreConstructors: false
977
+ }
978
+ ],
979
+ "vue/one-component-per-file": "off",
980
+ "vue/padding-line-between-blocks": ["error", "always"],
981
+ "vue/prefer-template": "error",
982
+ "vue/require-default-prop": "off",
983
+ "vue/require-prop-types": "off",
984
+ "vue/return-in-computed-property": ["error", { treatUndefinedAsUnspecified: false }]
985
+ }
986
+ },
987
+ ...reactivityTransform()
988
+ ];
989
+
990
+ //#endregion
991
+ //#region src/configs/yml.ts
992
+ const yml = () => [{
993
+ name: "frabbit/yaml/setup",
994
+ plugins: { yml: pluginYml }
995
+ }, {
996
+ files: [GLOB_YAML],
997
+ languageOptions: { parser: parserYml },
998
+ name: "frabbit/yaml/rules",
999
+ rules: {
1000
+ ...pluginYml.configs.standard.rules,
1001
+ ...pluginYml.configs.prettier.rules,
1002
+ "yml/no-empty-mapping-value": "off"
1003
+ }
1004
+ }];
1005
+
1006
+ //#endregion
1007
+ //#region src/env.ts
1008
+ const hasTypeScript = () => isPackageExists("typescript");
1009
+ const hasVue = () => isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli");
1010
+ const hasUnocss = () => isPackageExists("unocss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt") || isPackageExists("@unocss/eslint-plugin");
1011
+ function isInEditorEnv() {
1012
+ if (process.env.CI) return false;
1013
+ if (isInGitHooksOrLintStaged()) return false;
1014
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
1015
+ }
1016
+ function isInGitHooksOrLintStaged() {
1017
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
1018
+ }
1019
+
1020
+ //#endregion
1021
+ //#region src/presets.ts
1022
+ /** Ignore common files and include javascript support */
1023
+ const presetJavaScript = () => [
1024
+ ...ignores(),
1025
+ ...javascript(),
1026
+ ...comments(),
1027
+ ...imports(),
1028
+ ...unicorn(),
1029
+ ...sonarjs(),
1030
+ ...security(),
1031
+ ...node(),
1032
+ ...jsdoc(),
1033
+ ...regexp(),
1034
+ ...deMorgan()
1035
+ ];
1036
+ /** Includes basic json(c) file support and sorting json keys */
1037
+ const presetJsonc = () => [
1038
+ ...jsonc(),
1039
+ ...sortPackageJson(),
1040
+ ...sortTsconfig(),
1041
+ ...sortPnpmWorkspace()
1042
+ ];
1043
+ /** Includes markdown, yaml + `presetJsonc` support */
1044
+ const presetLangsExtensions = () => [
1045
+ ...markdown(),
1046
+ ...yml(),
1047
+ ...presetJsonc()
1048
+ ];
1049
+ /** Includes `presetJavaScript` and typescript support */
1050
+ const presetBasic = () => [
1051
+ ...presetJavaScript(),
1052
+ ...typescript(),
1053
+ ...sortImports()
1054
+ ];
1055
+ /**
1056
+ * Includes
1057
+ * - `presetBasic` (JS+TS) support
1058
+ * - `presetLangsExtensions` (markdown, yaml, jsonc) support
1059
+ * - Vue support
1060
+ * - UnoCSS support (`uno.config.ts` is required)
1061
+ * - Prettier support
1062
+ */
1063
+ const presetAll = async () => [
1064
+ ...presetBasic(),
1065
+ ...presetLangsExtensions(),
1066
+ ...vue(),
1067
+ ...await unocss(),
1068
+ ...prettier(),
1069
+ ...command(),
1070
+ ...await pnpm(),
1071
+ ...baseline(),
1072
+ ...specialCases()
1073
+ ];
1074
+ /** `@frabbit`'s preset. */
1075
+ function frabbit(options = {}, ...userConfigs) {
1076
+ const { baseline: enableBaseline = true, command: enableCommand = true, markdown: enableMarkdown = true, pnpm: enablePnpm = false, prettier: enablePrettier = true, unocss: enableUnocss = hasUnocss(), vue: enableVue = hasVue() } = options;
1077
+ const configs$1 = [
1078
+ presetBasic(),
1079
+ yml(),
1080
+ presetJsonc()
1081
+ ];
1082
+ if (enableBaseline) configs$1.push(baseline(typeof enableBaseline === "object" ? enableBaseline : {}));
1083
+ if (enableVue) configs$1.push(vue());
1084
+ if (enableMarkdown) configs$1.push(markdown());
1085
+ if (enableUnocss) configs$1.push(unocss());
1086
+ if (enablePrettier) configs$1.push(prettier());
1087
+ if (enableCommand) configs$1.push(command());
1088
+ if (enablePnpm) configs$1.push(pnpm());
1089
+ configs$1.push(specialCases());
1090
+ return new FlatConfigComposer(...configs$1, ...userConfigs);
1091
+ }
1092
+
1093
+ //#endregion
1094
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_NODE_MODULES, GLOB_NUXT_LAYOUTS, GLOB_NUXT_PAGE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, baseline, command, comments, configCommand, configComments, configJs, deMorgan, frabbit, hasTypeScript, hasUnocss, hasVue, ignores, imports, isInEditorEnv, isInGitHooksOrLintStaged, javascript, jsdoc, jsonc, markdown, node, parserJsonc, parserVue, parserYml, pluginAntfu, pluginDeMorgan, pluginIgnore, pluginImport, pluginJsdoc, pluginJsonc, pluginMarkdown, pluginNode, pluginPerfectionist, pluginPnpm, pluginPrettier, pluginPrettierRecommended, pluginSecurity, pluginSonarJS, pluginSxzz, pluginUnicorn, pluginUnusedImports, pluginVue, pluginYml, pnpm, presetAll, presetBasic, presetJavaScript, presetJsonc, presetLangsExtensions, prettier, reactivityTransform, regexp, restrictedSyntaxJs, security, sonarjs, sortImports, sortPackageJson, sortPnpmWorkspace, sortTsconfig, specialCases, tseslint, typescript, typescriptCore, unicorn, unocss, vue, yml };