@curev/eslint-config 0.3.3 → 0.3.5

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 CHANGED
@@ -1,69 +1,2017 @@
1
- import jiti from "file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/lib/index.js";
2
-
3
- /** @type {import("/home/runner/work/eslint-config/eslint-config/src/index")} */
4
- const _module = jiti(null, {
5
- "esmResolve": true,
6
- "interopDefault": true,
7
- "alias": {
8
- "@curev/eslint-config": "/home/runner/work/eslint-config/eslint-config"
9
- }
10
- })("/home/runner/work/eslint-config/eslint-config/src/index.ts");
11
-
12
- export default _module;
13
- export const comments = _module.comments;
14
- export const ignores = _module.ignores;
15
- export const imports = _module.imports;
16
- export const javascript = _module.javascript;
17
- export const jsdoc = _module.jsdoc;
18
- export const jsonc = _module.jsonc;
19
- export const markdown = _module.markdown;
20
- export const node = _module.node;
21
- export const perfectionist = _module.perfectionist;
22
- export const formatters = _module.formatters;
23
- export const react = _module.react;
24
- export const sortPackageJson = _module.sortPackageJson;
25
- export const sortTsconfig = _module.sortTsconfig;
26
- export const StylisticConfigDefaults = _module.StylisticConfigDefaults;
27
- export const stylistic = _module.stylistic;
28
- export const svelte = _module.svelte;
29
- export const test = _module.test;
30
- export const typescript = _module.typescript;
31
- export const unicorn = _module.unicorn;
32
- export const unocss = _module.unocss;
33
- export const vue = _module.vue;
34
- export const yaml = _module.yaml;
35
- export const toml = _module.toml;
36
- export const curev = _module.curev;
37
- export const resolveSubOptions = _module.resolveSubOptions;
38
- export const getOverrides = _module.getOverrides;
39
- export const GLOB_SRC_EXT = _module.GLOB_SRC_EXT;
40
- export const GLOB_SRC = _module.GLOB_SRC;
41
- export const GLOB_JS = _module.GLOB_JS;
42
- export const GLOB_JSX = _module.GLOB_JSX;
43
- export const GLOB_TS = _module.GLOB_TS;
44
- export const GLOB_TSX = _module.GLOB_TSX;
45
- export const GLOB_STYLE = _module.GLOB_STYLE;
46
- export const GLOB_CSS = _module.GLOB_CSS;
47
- export const GLOB_POSTCSS = _module.GLOB_POSTCSS;
48
- export const GLOB_LESS = _module.GLOB_LESS;
49
- export const GLOB_SCSS = _module.GLOB_SCSS;
50
- export const GLOB_JSON = _module.GLOB_JSON;
51
- export const GLOB_JSON5 = _module.GLOB_JSON5;
52
- export const GLOB_JSONC = _module.GLOB_JSONC;
53
- export const GLOB_MARKDOWN = _module.GLOB_MARKDOWN;
54
- export const GLOB_MARKDOWN_IN_MARKDOWN = _module.GLOB_MARKDOWN_IN_MARKDOWN;
55
- export const GLOB_SVELTE = _module.GLOB_SVELTE;
56
- export const GLOB_VUE = _module.GLOB_VUE;
57
- export const GLOB_YAML = _module.GLOB_YAML;
58
- export const GLOB_TOML = _module.GLOB_TOML;
59
- export const GLOB_HTML = _module.GLOB_HTML;
60
- export const GLOB_MARKDOWN_CODE = _module.GLOB_MARKDOWN_CODE;
61
- export const GLOB_TESTS = _module.GLOB_TESTS;
62
- export const GLOB_ALL_SRC = _module.GLOB_ALL_SRC;
63
- export const GLOB_EXCLUDE = _module.GLOB_EXCLUDE;
64
- export const parserPlain = _module.parserPlain;
65
- export const combine = _module.combine;
66
- export const renameRules = _module.renameRules;
67
- export const toArray = _module.toArray;
68
- export const interopDefault = _module.interopDefault;
69
- export const ensurePackages = _module.ensurePackages;
1
+ import process from 'node:process';
2
+ import fs from 'node:fs';
3
+ import { isPackageExists } from 'local-pkg';
4
+ import pluginCurev from '@curev/eslint-plugin';
5
+ import pluginComments from 'eslint-plugin-eslint-comments';
6
+ import * as pluginImport from 'eslint-plugin-i';
7
+ import pluginNode from 'eslint-plugin-n';
8
+ import pluginUnicorn from 'eslint-plugin-unicorn';
9
+ import pluginUnusedImports from 'eslint-plugin-unused-imports';
10
+ import pluginPerfectionist from 'eslint-plugin-perfectionist';
11
+ import globals from 'globals';
12
+ import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
13
+
14
+ async function comments() {
15
+ return [
16
+ {
17
+ name: "curev:eslint-comments",
18
+ plugins: {
19
+ "eslint-comments": pluginComments
20
+ },
21
+ rules: {
22
+ "eslint-comments/no-aggregating-enable": "error",
23
+ "eslint-comments/no-duplicate-disable": "error",
24
+ "eslint-comments/no-unlimited-disable": "error",
25
+ "eslint-comments/no-unused-enable": "error"
26
+ }
27
+ }
28
+ ];
29
+ }
30
+
31
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
32
+ const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
33
+ const GLOB_JS = "**/*.?([cm])js";
34
+ const GLOB_JSX = "**/*.?([cm])jsx";
35
+ const GLOB_TS = "**/*.?([cm])ts";
36
+ const GLOB_TSX = "**/*.?([cm])tsx";
37
+ const GLOB_STYLE = "**/*.{c,le,sc}ss";
38
+ const GLOB_CSS = "**/*.css";
39
+ const GLOB_POSTCSS = "**/*.{p,post}css";
40
+ const GLOB_LESS = "**/*.less";
41
+ const GLOB_SCSS = "**/*.scss";
42
+ const GLOB_JSON = "**/*.json";
43
+ const GLOB_JSON5 = "**/*.json5";
44
+ const GLOB_JSONC = "**/*.jsonc";
45
+ const GLOB_MARKDOWN = "**/*.md";
46
+ const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
47
+ const GLOB_SVELTE = "**/*.svelte";
48
+ const GLOB_VUE = "**/*.vue";
49
+ const GLOB_YAML = "**/*.y?(a)ml";
50
+ const GLOB_TOML = "**/*.toml";
51
+ const GLOB_HTML = "**/*.htm?(l)";
52
+ const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
53
+ const GLOB_TESTS = [
54
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
55
+ `**/*.spec.${GLOB_SRC_EXT}`,
56
+ `**/*.test.${GLOB_SRC_EXT}`,
57
+ `**/*.bench.${GLOB_SRC_EXT}`,
58
+ `**/*.benchmark.${GLOB_SRC_EXT}`
59
+ ];
60
+ const GLOB_ALL_SRC = [
61
+ GLOB_SRC,
62
+ GLOB_STYLE,
63
+ GLOB_JSON,
64
+ GLOB_JSON5,
65
+ GLOB_MARKDOWN,
66
+ GLOB_SVELTE,
67
+ GLOB_VUE,
68
+ GLOB_YAML,
69
+ GLOB_HTML
70
+ ];
71
+ const GLOB_EXCLUDE = [
72
+ "**/node_modules",
73
+ "**/dist",
74
+ "**/package-lock.json",
75
+ "**/yarn.lock",
76
+ "**/pnpm-lock.yaml",
77
+ "**/bun.lockb",
78
+ "**/output",
79
+ "**/coverage",
80
+ "**/temp",
81
+ "**/.temp",
82
+ "**/tmp",
83
+ "**/.tmp",
84
+ "**/.history",
85
+ "**/.vitepress/cache",
86
+ "**/.nuxt",
87
+ "**/.next",
88
+ "**/.vercel",
89
+ "**/.changeset",
90
+ "**/.idea",
91
+ "**/.cache",
92
+ "**/.output",
93
+ "**/.vite-inspect",
94
+ "**/CHANGELOG*.md",
95
+ "**/*.min.*",
96
+ "**/LICENSE*",
97
+ "**/__snapshots__",
98
+ "**/auto-import?(s).d.ts",
99
+ "**/components.d.ts"
100
+ ];
101
+
102
+ async function ignores() {
103
+ return [
104
+ {
105
+ ignores: GLOB_EXCLUDE
106
+ }
107
+ ];
108
+ }
109
+
110
+ async function imports(options = {}) {
111
+ const {
112
+ stylistic = true
113
+ } = options;
114
+ return [
115
+ {
116
+ name: "curev:imports",
117
+ plugins: {
118
+ curev: pluginCurev,
119
+ import: pluginImport
120
+ },
121
+ rules: {
122
+ "antfu/import-dedupe": "error",
123
+ "antfu/no-import-dist": "error",
124
+ "antfu/no-import-node-modules-by-path": "error",
125
+ "import/first": "error",
126
+ "import/no-duplicates": "error",
127
+ "import/no-mutable-exports": "error",
128
+ "import/no-named-default": "error",
129
+ "import/no-self-import": "error",
130
+ "import/no-webpack-loader-syntax": "error",
131
+ "import/order": "error",
132
+ ...stylistic ? {
133
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
134
+ } : {}
135
+ }
136
+ },
137
+ {
138
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
139
+ name: "curev:imports:bin",
140
+ rules: {
141
+ "antfu/no-import-dist": "off",
142
+ "antfu/no-import-node-modules-by-path": "off"
143
+ }
144
+ }
145
+ ];
146
+ }
147
+
148
+ async function javascript(options = {}) {
149
+ const {
150
+ isInEditor = false,
151
+ overrides = {}
152
+ } = options;
153
+ return [
154
+ {
155
+ languageOptions: {
156
+ ecmaVersion: 2022,
157
+ globals: {
158
+ ...globals.browser,
159
+ ...globals.es2021,
160
+ ...globals.node,
161
+ document: "readonly",
162
+ navigator: "readonly",
163
+ window: "readonly"
164
+ },
165
+ parserOptions: {
166
+ ecmaFeatures: {
167
+ jsx: true
168
+ },
169
+ ecmaVersion: 2022,
170
+ sourceType: "module"
171
+ },
172
+ sourceType: "module"
173
+ },
174
+ linterOptions: {
175
+ reportUnusedDisableDirectives: true
176
+ },
177
+ name: "curev:javascript",
178
+ plugins: {
179
+ "antfu": pluginCurev,
180
+ "unused-imports": pluginUnusedImports
181
+ },
182
+ rules: {
183
+ "no-var": "warn",
184
+ "object-shorthand": ["warn", "properties"],
185
+ "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
186
+ "array-callback-return": ["error", {
187
+ allowImplicit: false,
188
+ checkForEach: false
189
+ }],
190
+ "camelcase": ["error", {
191
+ allow: ["^UNSAFE_"],
192
+ properties: "never",
193
+ ignoreGlobals: true,
194
+ ignoreImports: true
195
+ }],
196
+ "constructor-super": "error",
197
+ "default-case-last": "error",
198
+ "eol-last": "error",
199
+ "eqeqeq": ["error", "always", { null: "ignore" }],
200
+ "func-call-spacing": ["error", "never"],
201
+ "generator-star-spacing": ["error", { before: true, after: true }],
202
+ "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
203
+ "multiline-ternary": ["error", "always-multiline"],
204
+ "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
205
+ "new-parens": "error",
206
+ "no-array-constructor": "error",
207
+ "no-async-promise-executor": "error",
208
+ "no-caller": "error",
209
+ "no-case-declarations": "error",
210
+ "no-class-assign": "error",
211
+ "no-compare-neg-zero": "error",
212
+ "no-cond-assign": "error",
213
+ "no-const-assign": "error",
214
+ "no-constant-condition": ["error", { checkLoops: false }],
215
+ "no-control-regex": "error",
216
+ "no-debugger": "error",
217
+ "no-delete-var": "error",
218
+ "no-dupe-args": "error",
219
+ "no-dupe-class-members": "error",
220
+ "no-dupe-keys": "error",
221
+ "no-duplicate-case": "error",
222
+ "no-useless-backreference": "error",
223
+ "no-empty": ["error", { allowEmptyCatch: true }],
224
+ "no-empty-character-class": "error",
225
+ "no-empty-pattern": "error",
226
+ "no-eval": "error",
227
+ "no-ex-assign": "error",
228
+ "no-extend-native": "error",
229
+ "no-extra-bind": "error",
230
+ "no-extra-boolean-cast": "error",
231
+ "no-extra-parens": ["error", "functions"],
232
+ "no-fallthrough": "error",
233
+ "no-floating-decimal": "error",
234
+ "no-func-assign": "error",
235
+ "no-global-assign": "error",
236
+ "no-implied-eval": "error",
237
+ "no-import-assign": "error",
238
+ "no-invalid-regexp": "error",
239
+ "no-irregular-whitespace": "error",
240
+ "no-iterator": "error",
241
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
242
+ "no-lone-blocks": "error",
243
+ "no-loss-of-precision": "error",
244
+ "no-misleading-character-class": "error",
245
+ "no-prototype-builtins": "error",
246
+ "no-useless-catch": "error",
247
+ "no-mixed-operators": ["error", {
248
+ groups: [
249
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
250
+ ["&&", "||"],
251
+ ["in", "instanceof"]
252
+ ],
253
+ allowSamePrecedence: true
254
+ }],
255
+ "no-mixed-spaces-and-tabs": "error",
256
+ "no-multi-spaces": "error",
257
+ "no-multi-str": "error",
258
+ "no-new": "error",
259
+ "no-new-func": "error",
260
+ "no-new-object": "error",
261
+ "no-new-symbol": "error",
262
+ "no-new-wrappers": "error",
263
+ "no-obj-calls": "error",
264
+ "no-octal": "error",
265
+ "no-octal-escape": "error",
266
+ "no-proto": "error",
267
+ "no-redeclare": ["error", { builtinGlobals: false }],
268
+ "no-regex-spaces": "error",
269
+ "no-return-assign": ["error", "except-parens"],
270
+ "no-self-assign": ["error", { props: true }],
271
+ "no-self-compare": "error",
272
+ "no-sequences": "error",
273
+ "no-shadow-restricted-names": "error",
274
+ "no-sparse-arrays": "error",
275
+ "no-tabs": "error",
276
+ "no-template-curly-in-string": "error",
277
+ "no-this-before-super": "error",
278
+ "no-throw-literal": "error",
279
+ "no-trailing-spaces": [
280
+ "error",
281
+ {
282
+ skipBlankLines: true
283
+ }
284
+ ],
285
+ "no-multiple-empty-lines": [
286
+ "error",
287
+ {
288
+ max: 3,
289
+ maxBOF: 0,
290
+ maxEOF: 1
291
+ }
292
+ ],
293
+ "no-undef": "error",
294
+ "no-undef-init": "error",
295
+ "no-unexpected-multiline": "error",
296
+ "no-unmodified-loop-condition": "error",
297
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
298
+ "no-unreachable": "error",
299
+ "no-unreachable-loop": "error",
300
+ "no-unsafe-finally": "error",
301
+ "no-unsafe-negation": "error",
302
+ "no-unused-expressions": ["error", {
303
+ allowShortCircuit: true,
304
+ allowTernary: true,
305
+ allowTaggedTemplates: true
306
+ }],
307
+ "no-unused-vars": ["error", {
308
+ args: "none",
309
+ caughtErrors: "none",
310
+ ignoreRestSiblings: true,
311
+ vars: "all"
312
+ }],
313
+ "no-use-before-define": ["error", { functions: false, classes: false, variables: false }],
314
+ "no-useless-call": "error",
315
+ "no-useless-computed-key": "error",
316
+ "no-useless-constructor": "error",
317
+ "no-useless-escape": "error",
318
+ "no-useless-rename": "error",
319
+ "no-useless-return": "error",
320
+ "no-void": "error",
321
+ "no-with": "error",
322
+ "object-curly-newline": ["error", { multiline: true, consistent: true }],
323
+ "object-curly-spacing": ["error", "always"],
324
+ "object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
325
+ "one-var": ["error", { initialized: "never" }],
326
+ "padded-blocks": ["error", { blocks: "never", switches: "never", classes: "never" }],
327
+ "prefer-const": ["error", { destructuring: "all" }],
328
+ "prefer-promise-reject-errors": "error",
329
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
330
+ "rest-spread-spacing": ["error", "never"],
331
+ "symbol-description": "error",
332
+ "template-curly-spacing": ["error", "never"],
333
+ "template-tag-spacing": ["error", "never"],
334
+ "unicode-bom": ["error", "never"],
335
+ "use-isnan": ["error", {
336
+ enforceForSwitchCase: true,
337
+ enforceForIndexOf: true
338
+ }],
339
+ "valid-typeof": ["error", { requireStringLiterals: true }],
340
+ "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
341
+ "yield-star-spacing": ["error", "both"],
342
+ "yoda": ["error", "never"],
343
+ "import/export": "error",
344
+ "import/first": "error",
345
+ "import/no-absolute-path": ["error", { esmodule: true, commonjs: true, amd: false }],
346
+ "import/no-duplicates": "error",
347
+ "import/no-named-default": "error",
348
+ "import/no-webpack-loader-syntax": "error",
349
+ "block-scoped-var": "error",
350
+ "no-alert": "error",
351
+ "no-console": ["error", { allow: ["warn", "error"] }],
352
+ "no-restricted-globals": [
353
+ "error",
354
+ { message: "Use `globalThis` instead.", name: "global" },
355
+ { message: "Use `globalThis` instead.", name: "self" }
356
+ ],
357
+ "no-restricted-properties": [
358
+ "error",
359
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
360
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
361
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
362
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
363
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
364
+ ],
365
+ "no-restricted-syntax": [
366
+ "error",
367
+ "DebuggerStatement",
368
+ "LabeledStatement",
369
+ "WithStatement",
370
+ "TSEnumDeclaration[const=true]",
371
+ "TSExportAssignment"
372
+ ],
373
+ "prefer-arrow-callback": [
374
+ "error",
375
+ {
376
+ allowNamedFunctions: false,
377
+ allowUnboundThis: true
378
+ }
379
+ ],
380
+ "prefer-exponentiation-operator": "error",
381
+ "prefer-rest-params": "error",
382
+ "prefer-spread": "error",
383
+ "prefer-template": "error",
384
+ "sort-imports": [
385
+ "error",
386
+ {
387
+ allowSeparatedGroups: false,
388
+ ignoreCase: false,
389
+ ignoreDeclarationSort: true,
390
+ ignoreMemberSort: false,
391
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
392
+ }
393
+ ],
394
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
395
+ "unused-imports/no-unused-vars": [
396
+ "error",
397
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
398
+ ],
399
+ "vars-on-top": "error",
400
+ ...overrides
401
+ }
402
+ },
403
+ {
404
+ files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
405
+ name: "curev:scripts-overrides",
406
+ rules: {
407
+ "no-console": "off"
408
+ }
409
+ }
410
+ ];
411
+ }
412
+
413
+ const parserPlain = {
414
+ meta: {
415
+ name: "parser-plain"
416
+ },
417
+ parseForESLint: (code) => ({
418
+ ast: {
419
+ body: [],
420
+ comments: [],
421
+ loc: { end: code.length, start: 0 },
422
+ range: [0, code.length],
423
+ tokens: [],
424
+ type: "Program"
425
+ },
426
+ scopeManager: null,
427
+ services: { isPlain: true },
428
+ visitorKeys: {
429
+ Program: []
430
+ }
431
+ })
432
+ };
433
+ async function combine(...configs) {
434
+ const resolved = await Promise.all(configs);
435
+ return resolved.flat();
436
+ }
437
+ function renameRules(rules, from, to) {
438
+ return Object.fromEntries(
439
+ Object.entries(rules).map(([key, value]) => {
440
+ if (key.startsWith(from)) {
441
+ return [to + key.slice(from.length), value];
442
+ }
443
+ return [key, value];
444
+ })
445
+ );
446
+ }
447
+ function toArray(value) {
448
+ return Array.isArray(value) ? value : [value];
449
+ }
450
+ async function interopDefault(m) {
451
+ const resolved = await m;
452
+ return resolved.default || resolved;
453
+ }
454
+ async function ensurePackages(packages) {
455
+ if (process.env.CI || process.stdout.isTTY === false) {
456
+ return;
457
+ }
458
+ const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
459
+ if (nonExistingPackages.length === 0) {
460
+ return;
461
+ }
462
+ const { default: prompts } = await import('prompts');
463
+ const { result } = await prompts([
464
+ {
465
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
466
+ name: "result",
467
+ type: "confirm"
468
+ }
469
+ ]);
470
+ if (result) {
471
+ await import('@antfu/install-pkg').then((i) => i.installPackage(nonExistingPackages, { dev: true }));
472
+ }
473
+ }
474
+
475
+ async function jsdoc(options = {}) {
476
+ const {
477
+ stylistic = true
478
+ } = options;
479
+ return [
480
+ {
481
+ name: "curev:jsdoc",
482
+ plugins: {
483
+ jsdoc: await interopDefault(import('eslint-plugin-jsdoc'))
484
+ },
485
+ rules: {
486
+ "jsdoc/check-access": "warn",
487
+ "jsdoc/check-param-names": "warn",
488
+ "jsdoc/check-property-names": "warn",
489
+ "jsdoc/check-types": "warn",
490
+ "jsdoc/empty-tags": "warn",
491
+ "jsdoc/implements-on-classes": "warn",
492
+ "jsdoc/no-defaults": "warn",
493
+ "jsdoc/no-multi-asterisks": "warn",
494
+ "jsdoc/require-param-name": "warn",
495
+ "jsdoc/require-property": "warn",
496
+ "jsdoc/require-property-description": "warn",
497
+ "jsdoc/require-property-name": "warn",
498
+ "jsdoc/require-returns-check": "warn",
499
+ "jsdoc/require-returns-description": "warn",
500
+ "jsdoc/require-yields-check": "warn",
501
+ ...stylistic ? {
502
+ "jsdoc/check-alignment": "warn",
503
+ "jsdoc/multiline-blocks": "warn"
504
+ } : {}
505
+ }
506
+ }
507
+ ];
508
+ }
509
+
510
+ async function jsonc(options = {}) {
511
+ const {
512
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
513
+ overrides = {},
514
+ stylistic = true
515
+ } = options;
516
+ const {
517
+ indent = 2
518
+ } = typeof stylistic === "boolean" ? {} : stylistic;
519
+ const [
520
+ pluginJsonc,
521
+ parserJsonc
522
+ ] = await Promise.all([
523
+ interopDefault(import('eslint-plugin-jsonc')),
524
+ interopDefault(import('jsonc-eslint-parser'))
525
+ ]);
526
+ return [
527
+ {
528
+ name: "curev:jsonc:setup",
529
+ plugins: {
530
+ jsonc: pluginJsonc
531
+ }
532
+ },
533
+ {
534
+ files,
535
+ languageOptions: {
536
+ parser: parserJsonc
537
+ },
538
+ name: "curev:jsonc:rules",
539
+ rules: {
540
+ "jsonc/no-bigint-literals": "error",
541
+ "jsonc/no-binary-expression": "error",
542
+ "jsonc/no-binary-numeric-literals": "error",
543
+ "jsonc/no-dupe-keys": "error",
544
+ "jsonc/no-escape-sequence-in-identifier": "error",
545
+ "jsonc/no-floating-decimal": "error",
546
+ "jsonc/no-hexadecimal-numeric-literals": "error",
547
+ "jsonc/no-infinity": "error",
548
+ "jsonc/no-multi-str": "error",
549
+ "jsonc/no-nan": "error",
550
+ "jsonc/no-number-props": "error",
551
+ "jsonc/no-numeric-separators": "error",
552
+ "jsonc/no-octal": "error",
553
+ "jsonc/no-octal-escape": "error",
554
+ "jsonc/no-octal-numeric-literals": "error",
555
+ "jsonc/no-parenthesized": "error",
556
+ "jsonc/no-plus-sign": "error",
557
+ "jsonc/no-regexp-literals": "error",
558
+ "jsonc/no-sparse-arrays": "error",
559
+ "jsonc/no-template-literals": "error",
560
+ "jsonc/no-undefined-value": "error",
561
+ "jsonc/no-unicode-codepoint-escapes": "error",
562
+ "jsonc/no-useless-escape": "error",
563
+ "jsonc/space-unary-ops": "error",
564
+ "jsonc/valid-json-number": "error",
565
+ "jsonc/vue-custom-block/no-parsing-error": "error",
566
+ ...stylistic ? {
567
+ "jsonc/array-bracket-spacing": ["error", "never"],
568
+ "jsonc/comma-dangle": ["error", "never"],
569
+ "jsonc/comma-style": ["error", "last"],
570
+ "jsonc/indent": ["error", indent],
571
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
572
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
573
+ "jsonc/object-curly-spacing": ["error", "always"],
574
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
575
+ "jsonc/quote-props": "error",
576
+ "jsonc/quotes": "error"
577
+ } : {},
578
+ ...overrides
579
+ }
580
+ }
581
+ ];
582
+ }
583
+
584
+ async function markdown(options = {}) {
585
+ const {
586
+ componentExts = [],
587
+ files = [GLOB_MARKDOWN],
588
+ overrides = {}
589
+ } = options;
590
+ const markdown2 = await interopDefault(import('eslint-plugin-markdown'));
591
+ return [
592
+ {
593
+ name: "curev:markdown:setup",
594
+ plugins: {
595
+ markdown: markdown2
596
+ }
597
+ },
598
+ {
599
+ files,
600
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
601
+ name: "curev:markdown:processor",
602
+ // `eslint-plugin-markdown` only creates virtual files for code blocks,
603
+ // but not the markdown file itself. We use `eslint-merge-processors` to
604
+ // add a pass-through processor for the markdown file itself.
605
+ processor: mergeProcessors([
606
+ markdown2.processors.markdown,
607
+ processorPassThrough
608
+ ])
609
+ },
610
+ {
611
+ files,
612
+ languageOptions: {
613
+ parser: parserPlain
614
+ },
615
+ name: "curev:markdown:parser"
616
+ },
617
+ {
618
+ files: [
619
+ GLOB_MARKDOWN_CODE,
620
+ ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
621
+ ],
622
+ languageOptions: {
623
+ parserOptions: {
624
+ ecmaFeatures: {
625
+ impliedStrict: true
626
+ }
627
+ }
628
+ },
629
+ name: "curev:markdown:disables",
630
+ rules: {
631
+ "import/newline-after-import": "off",
632
+ "no-alert": "off",
633
+ "no-console": "off",
634
+ "no-labels": "off",
635
+ "no-lone-blocks": "off",
636
+ "no-restricted-syntax": "off",
637
+ "no-undef": "off",
638
+ "no-unused-expressions": "off",
639
+ "no-unused-labels": "off",
640
+ "no-unused-vars": "off",
641
+ "node/prefer-global/process": "off",
642
+ "style/comma-dangle": "off",
643
+ "style/eol-last": "off",
644
+ "ts/consistent-type-imports": "off",
645
+ "ts/no-namespace": "off",
646
+ "ts/no-redeclare": "off",
647
+ "ts/no-require-imports": "off",
648
+ "ts/no-unused-vars": "off",
649
+ "ts/no-use-before-define": "off",
650
+ "ts/no-var-requires": "off",
651
+ "unicode-bom": "off",
652
+ "unused-imports/no-unused-imports": "off",
653
+ "unused-imports/no-unused-vars": "off",
654
+ // Type aware rules
655
+ ...{
656
+ "ts/await-thenable": "off",
657
+ "ts/dot-notation": "off",
658
+ "ts/no-floating-promises": "off",
659
+ "ts/no-for-in-array": "off",
660
+ "ts/no-implied-eval": "off",
661
+ "ts/no-misused-promises": "off",
662
+ "ts/no-throw-literal": "off",
663
+ "ts/no-unnecessary-type-assertion": "off",
664
+ "ts/no-unsafe-argument": "off",
665
+ "ts/no-unsafe-assignment": "off",
666
+ "ts/no-unsafe-call": "off",
667
+ "ts/no-unsafe-member-access": "off",
668
+ "ts/no-unsafe-return": "off",
669
+ "ts/restrict-plus-operands": "off",
670
+ "ts/restrict-template-expressions": "off",
671
+ "ts/unbound-method": "off"
672
+ },
673
+ ...overrides
674
+ }
675
+ }
676
+ ];
677
+ }
678
+
679
+ async function node() {
680
+ return [
681
+ {
682
+ name: "curev:node",
683
+ plugins: {
684
+ node: pluginNode
685
+ },
686
+ rules: {
687
+ "node/handle-callback-err": ["error", "^(err|error)$"],
688
+ "node/no-deprecated-api": "error",
689
+ "node/no-exports-assign": "error",
690
+ "node/no-new-require": "error",
691
+ "node/no-path-concat": "error",
692
+ "node/prefer-global/buffer": ["error", "never"],
693
+ "node/prefer-global/process": ["error", "never"],
694
+ "node/process-exit-as-throw": "error",
695
+ "node/no-callback-literal": "error"
696
+ }
697
+ }
698
+ ];
699
+ }
700
+
701
+ async function perfectionist() {
702
+ return [
703
+ {
704
+ name: "curev:perfectionist",
705
+ plugins: {
706
+ perfectionist: pluginPerfectionist
707
+ }
708
+ }
709
+ ];
710
+ }
711
+
712
+ const StylisticConfigDefaults = {
713
+ indent: 2,
714
+ jsx: true,
715
+ quotes: "double",
716
+ semi: true,
717
+ braceStyle: "1tbs",
718
+ commaDangle: "never",
719
+ arrowParens: true
720
+ };
721
+ async function stylistic(options = {}) {
722
+ const mergeOptions = {
723
+ ...StylisticConfigDefaults,
724
+ ...options
725
+ };
726
+ const { overrides = {} } = mergeOptions;
727
+ const pluginStylistic = await interopDefault(import('@stylistic/eslint-plugin'));
728
+ const config = pluginStylistic.configs.customize({
729
+ flat: true,
730
+ pluginName: "style",
731
+ ...mergeOptions
732
+ });
733
+ return [
734
+ {
735
+ name: "curev:stylistic",
736
+ plugins: {
737
+ curev: pluginCurev,
738
+ style: pluginStylistic
739
+ },
740
+ rules: {
741
+ ...config.rules,
742
+ "curev/consistent-list-newline": "error",
743
+ "curev/if-newline": "off",
744
+ "curev/top-level-function": "error",
745
+ "semi-spacing": ["error", { before: false, after: true }],
746
+ "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
747
+ "curly": ["error", "all"],
748
+ "style/max-statements-per-line": ["off"],
749
+ "curev/max-statements-per-line": ["error", { max: 1 }],
750
+ ...overrides
751
+ }
752
+ }
753
+ ];
754
+ }
755
+
756
+ async function formatters(options = {}, stylistic = {}) {
757
+ await ensurePackages([
758
+ "eslint-plugin-format"
759
+ ]);
760
+ if (options === true) {
761
+ options = {
762
+ css: true,
763
+ graphql: true,
764
+ html: true,
765
+ markdown: true
766
+ };
767
+ }
768
+ const {
769
+ indent,
770
+ quotes,
771
+ semi
772
+ } = {
773
+ ...StylisticConfigDefaults,
774
+ ...stylistic
775
+ };
776
+ const prettierOptions = Object.assign(
777
+ {
778
+ endOfLine: "auto",
779
+ semi,
780
+ singleQuote: quotes === "single",
781
+ tabWidth: typeof indent === "number" ? indent : 2,
782
+ trailingComma: "all",
783
+ useTabs: indent === "tab"
784
+ },
785
+ options.prettierOptions || {}
786
+ );
787
+ const dprintOptions = Object.assign(
788
+ {
789
+ indentWidth: typeof indent === "number" ? indent : 2,
790
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
791
+ useTabs: indent === "tab"
792
+ },
793
+ options.dprintOptions || {}
794
+ );
795
+ const pluginFormat = await interopDefault(import('eslint-plugin-format'));
796
+ const configs = [
797
+ {
798
+ name: "curev:formatters:setup",
799
+ plugins: {
800
+ format: pluginFormat
801
+ }
802
+ }
803
+ ];
804
+ if (options.css) {
805
+ configs.push(
806
+ {
807
+ files: [GLOB_CSS, GLOB_POSTCSS],
808
+ languageOptions: {
809
+ parser: parserPlain
810
+ },
811
+ name: "curev:formatter:css",
812
+ rules: {
813
+ "format/prettier": [
814
+ "error",
815
+ {
816
+ ...prettierOptions,
817
+ parser: "css"
818
+ }
819
+ ]
820
+ }
821
+ },
822
+ {
823
+ files: [GLOB_SCSS],
824
+ languageOptions: {
825
+ parser: parserPlain
826
+ },
827
+ name: "curev:formatter:scss",
828
+ rules: {
829
+ "format/prettier": [
830
+ "error",
831
+ {
832
+ ...prettierOptions,
833
+ parser: "scss"
834
+ }
835
+ ]
836
+ }
837
+ },
838
+ {
839
+ files: [GLOB_LESS],
840
+ languageOptions: {
841
+ parser: parserPlain
842
+ },
843
+ name: "curev:formatter:less",
844
+ rules: {
845
+ "format/prettier": [
846
+ "error",
847
+ {
848
+ ...prettierOptions,
849
+ parser: "less"
850
+ }
851
+ ]
852
+ }
853
+ }
854
+ );
855
+ }
856
+ if (options.html) {
857
+ configs.push({
858
+ files: ["**/*.html"],
859
+ languageOptions: {
860
+ parser: parserPlain
861
+ },
862
+ name: "curev:formatter:html",
863
+ rules: {
864
+ "format/prettier": [
865
+ "error",
866
+ {
867
+ ...prettierOptions,
868
+ parser: "html"
869
+ }
870
+ ]
871
+ }
872
+ });
873
+ }
874
+ if (options.markdown) {
875
+ const formater = options.markdown === true ? "prettier" : options.markdown;
876
+ configs.push({
877
+ files: [GLOB_MARKDOWN],
878
+ languageOptions: {
879
+ parser: parserPlain
880
+ },
881
+ name: "curev:formatter:markdown",
882
+ rules: {
883
+ [`format/${formater}`]: [
884
+ "error",
885
+ formater === "prettier" ? {
886
+ printWidth: 120,
887
+ ...prettierOptions,
888
+ embeddedLanguageFormatting: "off",
889
+ parser: "markdown"
890
+ } : {
891
+ ...dprintOptions,
892
+ language: "markdown"
893
+ }
894
+ ]
895
+ }
896
+ });
897
+ }
898
+ if (options.graphql) {
899
+ configs.push({
900
+ files: ["**/*.graphql"],
901
+ languageOptions: {
902
+ parser: parserPlain
903
+ },
904
+ name: "curev:formatter:graphql",
905
+ rules: {
906
+ "format/prettier": [
907
+ "error",
908
+ {
909
+ ...prettierOptions,
910
+ parser: "graphql"
911
+ }
912
+ ]
913
+ }
914
+ });
915
+ }
916
+ return configs;
917
+ }
918
+
919
+ const ReactRefreshAllowConstantExportPackages = [
920
+ "vite"
921
+ ];
922
+ async function react(options = {}) {
923
+ const {
924
+ files = [GLOB_JSX, GLOB_TSX],
925
+ overrides = {},
926
+ typescript = true
927
+ } = options;
928
+ await ensurePackages([
929
+ "eslint-plugin-react",
930
+ "eslint-plugin-react-hooks",
931
+ "eslint-plugin-react-refresh"
932
+ ]);
933
+ const [
934
+ pluginReact,
935
+ pluginReactHooks,
936
+ pluginReactRefresh
937
+ ] = await Promise.all([
938
+ interopDefault(import('eslint-plugin-react')),
939
+ interopDefault(import('eslint-plugin-react-hooks')),
940
+ interopDefault(import('eslint-plugin-react-refresh'))
941
+ ]);
942
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
943
+ (i) => isPackageExists(i)
944
+ );
945
+ return [
946
+ {
947
+ name: "curev:react:setup",
948
+ plugins: {
949
+ "react": pluginReact,
950
+ "react-hooks": pluginReactHooks,
951
+ "react-refresh": pluginReactRefresh
952
+ },
953
+ settings: {
954
+ react: {
955
+ version: "detect"
956
+ }
957
+ }
958
+ },
959
+ {
960
+ files,
961
+ languageOptions: {
962
+ parserOptions: {
963
+ ecmaFeatures: {
964
+ jsx: true
965
+ }
966
+ }
967
+ },
968
+ name: "curev:react:rules",
969
+ rules: {
970
+ // recommended rules react-hooks
971
+ "react-hooks/exhaustive-deps": "warn",
972
+ "react-hooks/rules-of-hooks": "error",
973
+ // react refresh
974
+ "react-refresh/only-export-components": [
975
+ "warn",
976
+ { allowConstantExport: isAllowConstantExport }
977
+ ],
978
+ // recommended rules react
979
+ "react/display-name": "error",
980
+ "react/jsx-key": "error",
981
+ "react/jsx-no-comment-textnodes": "error",
982
+ "react/jsx-no-duplicate-props": "error",
983
+ "react/jsx-no-target-blank": "error",
984
+ "react/jsx-no-undef": "error",
985
+ "react/jsx-uses-react": "error",
986
+ "react/jsx-uses-vars": "error",
987
+ "react/no-children-prop": "error",
988
+ "react/no-danger-with-children": "error",
989
+ "react/no-deprecated": "error",
990
+ "react/no-direct-mutation-state": "error",
991
+ "react/no-find-dom-node": "error",
992
+ "react/no-is-mounted": "error",
993
+ "react/no-render-return-value": "error",
994
+ "react/no-string-refs": "error",
995
+ "react/no-unescaped-entities": "error",
996
+ "react/no-unknown-property": "error",
997
+ "react/no-unsafe": "off",
998
+ "react/prop-types": "error",
999
+ "react/react-in-jsx-scope": "off",
1000
+ "react/require-render-return": "error",
1001
+ ...typescript ? {
1002
+ "react/jsx-no-undef": "off",
1003
+ "react/prop-type": "off"
1004
+ } : {},
1005
+ // overrides
1006
+ ...overrides
1007
+ }
1008
+ }
1009
+ ];
1010
+ }
1011
+
1012
+ async function sortPackageJson() {
1013
+ return [
1014
+ {
1015
+ files: ["**/package.json"],
1016
+ name: "curev:sort-package-json",
1017
+ rules: {
1018
+ "jsonc/sort-array-values": [
1019
+ "error",
1020
+ {
1021
+ order: { type: "asc" },
1022
+ pathPattern: "^files$"
1023
+ }
1024
+ ],
1025
+ "jsonc/sort-keys": [
1026
+ "error",
1027
+ {
1028
+ order: [
1029
+ "publisher",
1030
+ "name",
1031
+ "displayName",
1032
+ "type",
1033
+ "version",
1034
+ "private",
1035
+ "packageManager",
1036
+ "description",
1037
+ "author",
1038
+ "license",
1039
+ "funding",
1040
+ "homepage",
1041
+ "repository",
1042
+ "bugs",
1043
+ "keywords",
1044
+ "categories",
1045
+ "sideEffects",
1046
+ "exports",
1047
+ "main",
1048
+ "module",
1049
+ "unpkg",
1050
+ "jsdelivr",
1051
+ "types",
1052
+ "typesVersions",
1053
+ "bin",
1054
+ "icon",
1055
+ "files",
1056
+ "engines",
1057
+ "activationEvents",
1058
+ "contributes",
1059
+ "scripts",
1060
+ "peerDependencies",
1061
+ "peerDependenciesMeta",
1062
+ "dependencies",
1063
+ "optionalDependencies",
1064
+ "devDependencies",
1065
+ "pnpm",
1066
+ "overrides",
1067
+ "resolutions",
1068
+ "husky",
1069
+ "simple-git-hooks",
1070
+ "lint-staged",
1071
+ "eslintConfig"
1072
+ ],
1073
+ pathPattern: "^$"
1074
+ },
1075
+ {
1076
+ order: { type: "asc" },
1077
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1078
+ },
1079
+ {
1080
+ order: { type: "asc" },
1081
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1082
+ },
1083
+ {
1084
+ order: [
1085
+ "types",
1086
+ "import",
1087
+ "require",
1088
+ "default"
1089
+ ],
1090
+ pathPattern: "^exports.*$"
1091
+ }
1092
+ ]
1093
+ }
1094
+ }
1095
+ ];
1096
+ }
1097
+ function sortTsconfig() {
1098
+ return [
1099
+ {
1100
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1101
+ name: "curev:sort-tsconfig",
1102
+ rules: {
1103
+ "jsonc/sort-keys": [
1104
+ "error",
1105
+ {
1106
+ order: [
1107
+ "extends",
1108
+ "compilerOptions",
1109
+ "references",
1110
+ "files",
1111
+ "include",
1112
+ "exclude"
1113
+ ],
1114
+ pathPattern: "^$"
1115
+ },
1116
+ {
1117
+ order: [
1118
+ /* Projects */
1119
+ "incremental",
1120
+ "composite",
1121
+ "tsBuildInfoFile",
1122
+ "disableSourceOfProjectReferenceRedirect",
1123
+ "disableSolutionSearching",
1124
+ "disableReferencedProjectLoad",
1125
+ /* Language and Environment */
1126
+ "target",
1127
+ "jsx",
1128
+ "jsxFactory",
1129
+ "jsxFragmentFactory",
1130
+ "jsxImportSource",
1131
+ "lib",
1132
+ "moduleDetection",
1133
+ "noLib",
1134
+ "reactNamespace",
1135
+ "useDefineForClassFields",
1136
+ "emitDecoratorMetadata",
1137
+ "experimentalDecorators",
1138
+ /* Modules */
1139
+ "baseUrl",
1140
+ "rootDir",
1141
+ "rootDirs",
1142
+ "customConditions",
1143
+ "module",
1144
+ "moduleResolution",
1145
+ "moduleSuffixes",
1146
+ "noResolve",
1147
+ "paths",
1148
+ "resolveJsonModule",
1149
+ "resolvePackageJsonExports",
1150
+ "resolvePackageJsonImports",
1151
+ "typeRoots",
1152
+ "types",
1153
+ "allowArbitraryExtensions",
1154
+ "allowImportingTsExtensions",
1155
+ "allowUmdGlobalAccess",
1156
+ /* JavaScript Support */
1157
+ "allowJs",
1158
+ "checkJs",
1159
+ "maxNodeModuleJsDepth",
1160
+ /* Type Checking */
1161
+ "strict",
1162
+ "strictBindCallApply",
1163
+ "strictFunctionTypes",
1164
+ "strictNullChecks",
1165
+ "strictPropertyInitialization",
1166
+ "allowUnreachableCode",
1167
+ "allowUnusedLabels",
1168
+ "alwaysStrict",
1169
+ "exactOptionalPropertyTypes",
1170
+ "noFallthroughCasesInSwitch",
1171
+ "noImplicitAny",
1172
+ "noImplicitOverride",
1173
+ "noImplicitReturns",
1174
+ "noImplicitThis",
1175
+ "noPropertyAccessFromIndexSignature",
1176
+ "noUncheckedIndexedAccess",
1177
+ "noUnusedLocals",
1178
+ "noUnusedParameters",
1179
+ "useUnknownInCatchVariables",
1180
+ /* Emit */
1181
+ "declaration",
1182
+ "declarationDir",
1183
+ "declarationMap",
1184
+ "downlevelIteration",
1185
+ "emitBOM",
1186
+ "emitDeclarationOnly",
1187
+ "importHelpers",
1188
+ "importsNotUsedAsValues",
1189
+ "inlineSourceMap",
1190
+ "inlineSources",
1191
+ "mapRoot",
1192
+ "newLine",
1193
+ "noEmit",
1194
+ "noEmitHelpers",
1195
+ "noEmitOnError",
1196
+ "outDir",
1197
+ "outFile",
1198
+ "preserveConstEnums",
1199
+ "preserveValueImports",
1200
+ "removeComments",
1201
+ "sourceMap",
1202
+ "sourceRoot",
1203
+ "stripInternal",
1204
+ /* Interop Constraints */
1205
+ "allowSyntheticDefaultImports",
1206
+ "esModuleInterop",
1207
+ "forceConsistentCasingInFileNames",
1208
+ "isolatedModules",
1209
+ "preserveSymlinks",
1210
+ "verbatimModuleSyntax",
1211
+ /* Completeness */
1212
+ "skipDefaultLibCheck",
1213
+ "skipLibCheck"
1214
+ ],
1215
+ pathPattern: "^compilerOptions$"
1216
+ }
1217
+ ]
1218
+ }
1219
+ }
1220
+ ];
1221
+ }
1222
+
1223
+ async function svelte(options = {}) {
1224
+ const {
1225
+ files = [GLOB_SVELTE],
1226
+ overrides = {},
1227
+ stylistic = true
1228
+ } = options;
1229
+ const {
1230
+ indent = 2,
1231
+ quotes = "single"
1232
+ } = typeof stylistic === "boolean" ? {} : stylistic;
1233
+ await ensurePackages([
1234
+ "eslint-plugin-svelte"
1235
+ ]);
1236
+ const [
1237
+ pluginSvelte,
1238
+ parserSvelte
1239
+ ] = await Promise.all([
1240
+ interopDefault(import('eslint-plugin-svelte')),
1241
+ interopDefault(import('svelte-eslint-parser'))
1242
+ ]);
1243
+ return [
1244
+ {
1245
+ name: "curev:svelte:setup",
1246
+ plugins: {
1247
+ svelte: pluginSvelte
1248
+ }
1249
+ },
1250
+ {
1251
+ files,
1252
+ languageOptions: {
1253
+ parser: parserSvelte,
1254
+ parserOptions: {
1255
+ extraFileExtensions: [".svelte"],
1256
+ parser: options.typescript ? await interopDefault(import('@typescript-eslint/parser')) : null
1257
+ }
1258
+ },
1259
+ name: "curev:svelte:rules",
1260
+ processor: pluginSvelte.processors[".svelte"],
1261
+ rules: {
1262
+ "import/no-mutable-exports": "off",
1263
+ "no-undef": "off",
1264
+ // incompatible with most recent (attribute-form) generic types RFC
1265
+ "no-unused-vars": ["error", {
1266
+ args: "none",
1267
+ caughtErrors: "none",
1268
+ ignoreRestSiblings: true,
1269
+ vars: "all",
1270
+ varsIgnorePattern: "^\\$\\$Props$"
1271
+ }],
1272
+ "svelte/comment-directive": "error",
1273
+ "svelte/no-at-debug-tags": "warn",
1274
+ "svelte/no-at-html-tags": "error",
1275
+ "svelte/no-dupe-else-if-blocks": "error",
1276
+ "svelte/no-dupe-style-properties": "error",
1277
+ "svelte/no-dupe-use-directives": "error",
1278
+ "svelte/no-dynamic-slot-name": "error",
1279
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1280
+ "svelte/no-inner-declarations": "error",
1281
+ "svelte/no-not-function-handler": "error",
1282
+ "svelte/no-object-in-text-mustaches": "error",
1283
+ "svelte/no-reactive-functions": "error",
1284
+ "svelte/no-reactive-literals": "error",
1285
+ "svelte/no-shorthand-style-property-overrides": "error",
1286
+ "svelte/no-unknown-style-directive-property": "error",
1287
+ "svelte/no-unused-svelte-ignore": "error",
1288
+ "svelte/no-useless-mustaches": "error",
1289
+ "svelte/require-store-callbacks-use-set-param": "error",
1290
+ "svelte/system": "error",
1291
+ "svelte/valid-compile": "error",
1292
+ "svelte/valid-each-key": "error",
1293
+ "unused-imports/no-unused-vars": [
1294
+ "error",
1295
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
1296
+ ],
1297
+ ...stylistic ? {
1298
+ "style/no-trailing-spaces": "off",
1299
+ // superseded by svelte/no-trailing-spaces
1300
+ "svelte/derived-has-same-inputs-outputs": "error",
1301
+ "svelte/html-closing-bracket-spacing": "error",
1302
+ "svelte/html-quotes": ["error", { prefer: quotes }],
1303
+ "svelte/indent": ["error", { alignAttributesVertically: true, indent }],
1304
+ "svelte/mustache-spacing": "error",
1305
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1306
+ "svelte/no-trailing-spaces": "error",
1307
+ "svelte/spaced-html-comment": "error"
1308
+ } : {},
1309
+ ...overrides
1310
+ }
1311
+ }
1312
+ ];
1313
+ }
1314
+
1315
+ async function test(options = {}) {
1316
+ const {
1317
+ files = GLOB_TESTS,
1318
+ isInEditor = false,
1319
+ overrides = {}
1320
+ } = options;
1321
+ const [
1322
+ pluginVitest,
1323
+ pluginNoOnlyTests
1324
+ ] = await Promise.all([
1325
+ interopDefault(import('eslint-plugin-vitest')),
1326
+ // @ts-expect-error missing types
1327
+ interopDefault(import('eslint-plugin-no-only-tests'))
1328
+ ]);
1329
+ return [
1330
+ {
1331
+ name: "curev:test:setup",
1332
+ plugins: {
1333
+ test: {
1334
+ ...pluginVitest,
1335
+ rules: {
1336
+ ...pluginVitest.rules,
1337
+ // extend `test/no-only-tests` rule
1338
+ ...pluginNoOnlyTests.rules
1339
+ }
1340
+ }
1341
+ }
1342
+ },
1343
+ {
1344
+ files,
1345
+ name: "curev:test:rules",
1346
+ rules: {
1347
+ "node/prefer-global/process": "off",
1348
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1349
+ "test/no-identical-title": "error",
1350
+ "test/no-import-node-test": "error",
1351
+ "test/no-only-tests": isInEditor ? "off" : "error",
1352
+ "test/prefer-hooks-in-order": "error",
1353
+ "test/prefer-lowercase-title": "error",
1354
+ ...overrides
1355
+ }
1356
+ }
1357
+ ];
1358
+ }
1359
+
1360
+ async function typescript(options = {}) {
1361
+ const {
1362
+ componentExts = [],
1363
+ overrides = {},
1364
+ parserOptions = {}
1365
+ } = options;
1366
+ const files = options.files ?? [
1367
+ GLOB_SRC,
1368
+ ...componentExts.map((ext) => `**/*.${ext}`)
1369
+ ];
1370
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1371
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1372
+ const isTypeAware = !!tsconfigPath;
1373
+ const typeAwareRules = {
1374
+ "dot-notation": "off",
1375
+ "no-implied-eval": "off",
1376
+ "no-throw-literal": "off",
1377
+ "ts/await-thenable": "error",
1378
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1379
+ "ts/no-floating-promises": "error",
1380
+ "ts/no-for-in-array": "error",
1381
+ "ts/no-implied-eval": "error",
1382
+ "ts/no-misused-promises": "error",
1383
+ "ts/no-throw-literal": "error",
1384
+ "ts/no-unnecessary-type-assertion": "error",
1385
+ "ts/no-unsafe-argument": "error",
1386
+ "ts/no-unsafe-assignment": "error",
1387
+ "ts/no-unsafe-call": "error",
1388
+ "ts/no-unsafe-member-access": "error",
1389
+ "ts/no-unsafe-return": "error",
1390
+ "ts/restrict-plus-operands": "error",
1391
+ "ts/restrict-template-expressions": "error",
1392
+ "ts/unbound-method": "error"
1393
+ };
1394
+ const [
1395
+ pluginTs,
1396
+ parserTs
1397
+ ] = await Promise.all([
1398
+ interopDefault(import('@typescript-eslint/eslint-plugin')),
1399
+ interopDefault(import('@typescript-eslint/parser'))
1400
+ ]);
1401
+ function makeParser(typeAware, files2, ignores) {
1402
+ return {
1403
+ files: files2,
1404
+ ...ignores ? { ignores } : {},
1405
+ languageOptions: {
1406
+ parser: parserTs,
1407
+ parserOptions: {
1408
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1409
+ sourceType: "module",
1410
+ ...typeAware ? {
1411
+ project: tsconfigPath,
1412
+ tsconfigRootDir: process.cwd()
1413
+ } : {},
1414
+ ...parserOptions
1415
+ }
1416
+ },
1417
+ name: `curev:typescript:${typeAware ? "type-aware-parser" : "parser"}`
1418
+ };
1419
+ }
1420
+ return [
1421
+ {
1422
+ // Install the plugins without globs, so they can be configured separately.
1423
+ name: "curev:typescript:setup",
1424
+ plugins: {
1425
+ curev: pluginCurev,
1426
+ ts: pluginTs
1427
+ }
1428
+ },
1429
+ // assign type-aware parser for type-aware files and type-unaware parser for the rest
1430
+ ...isTypeAware ? [
1431
+ makeParser(true, filesTypeAware),
1432
+ makeParser(false, files, filesTypeAware)
1433
+ ] : [makeParser(false, files)],
1434
+ {
1435
+ files,
1436
+ name: "curev:typescript:rules",
1437
+ rules: {
1438
+ ...renameRules(
1439
+ pluginTs.configs["eslint-recommended"].overrides[0].rules,
1440
+ "@typescript-eslint/",
1441
+ "ts/"
1442
+ ),
1443
+ ...renameRules(
1444
+ pluginTs.configs.strict.rules,
1445
+ "@typescript-eslint/",
1446
+ "ts/"
1447
+ ),
1448
+ "no-dupe-class-members": "off",
1449
+ "no-loss-of-precision": "off",
1450
+ "no-redeclare": "off",
1451
+ "no-use-before-define": "off",
1452
+ "no-useless-constructor": "off",
1453
+ "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1454
+ "ts/ban-types": ["error", { types: { Function: false } }],
1455
+ "ts/consistent-type-definitions": ["error", "interface"],
1456
+ "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1457
+ "ts/no-dupe-class-members": "error",
1458
+ "ts/no-dynamic-delete": "off",
1459
+ "ts/no-explicit-any": "off",
1460
+ "ts/no-extraneous-class": "off",
1461
+ "ts/no-import-type-side-effects": "error",
1462
+ "ts/no-invalid-void-type": "off",
1463
+ "ts/no-loss-of-precision": "error",
1464
+ "ts/no-non-null-assertion": "off",
1465
+ "ts/no-redeclare": "error",
1466
+ "ts/no-require-imports": "error",
1467
+ "ts/no-unused-vars": "off",
1468
+ "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1469
+ "ts/no-useless-constructor": "off",
1470
+ "ts/prefer-ts-expect-error": "error",
1471
+ "ts/triple-slash-reference": "off",
1472
+ "ts/unified-signatures": "off",
1473
+ ...overrides
1474
+ }
1475
+ },
1476
+ {
1477
+ files: filesTypeAware,
1478
+ name: "curev:typescript:rules-type-aware",
1479
+ rules: {
1480
+ ...tsconfigPath ? typeAwareRules : {},
1481
+ ...overrides
1482
+ }
1483
+ },
1484
+ {
1485
+ files: ["**/*.d.ts"],
1486
+ name: "curev:typescript:dts-overrides",
1487
+ rules: {
1488
+ "eslint-comments/no-unlimited-disable": "off",
1489
+ "import/no-duplicates": "off",
1490
+ "no-restricted-syntax": "off",
1491
+ "unused-imports/no-unused-vars": "off"
1492
+ }
1493
+ },
1494
+ {
1495
+ files: ["**/*.{test,spec}.ts?(x)"],
1496
+ name: "curev:typescript:tests-overrides",
1497
+ rules: {
1498
+ "no-unused-expressions": "off"
1499
+ }
1500
+ },
1501
+ {
1502
+ files: ["**/*.js", "**/*.cjs"],
1503
+ name: "curev:typescript:javascript-overrides",
1504
+ rules: {
1505
+ "ts/no-require-imports": "off",
1506
+ "ts/no-var-requires": "off"
1507
+ }
1508
+ }
1509
+ ];
1510
+ }
1511
+
1512
+ async function unicorn() {
1513
+ return [
1514
+ {
1515
+ name: "curev:unicorn",
1516
+ plugins: {
1517
+ unicorn: pluginUnicorn
1518
+ },
1519
+ rules: {
1520
+ // Pass error message when throwing errors
1521
+ "unicorn/error-message": "error",
1522
+ // Uppercase regex escapes
1523
+ "unicorn/escape-case": "error",
1524
+ // Array.isArray instead of instanceof
1525
+ "unicorn/no-instanceof-array": "error",
1526
+ // Ban `new Array` as `Array` constructor's params are ambiguous
1527
+ "unicorn/no-new-array": "error",
1528
+ // Prevent deprecated `new Buffer()`
1529
+ "unicorn/no-new-buffer": "error",
1530
+ // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1531
+ "unicorn/number-literal-case": "error",
1532
+ // textContent instead of innerText
1533
+ "unicorn/prefer-dom-node-text-content": "error",
1534
+ // includes over indexOf when checking for existence
1535
+ "unicorn/prefer-includes": "error",
1536
+ // Prefer using the node: protocol
1537
+ "unicorn/prefer-node-protocol": "error",
1538
+ // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1539
+ "unicorn/prefer-number-properties": "error",
1540
+ // String methods startsWith/endsWith instead of more complicated stuff
1541
+ "unicorn/prefer-string-starts-ends-with": "error",
1542
+ // Enforce throwing type error when throwing error while checking typeof
1543
+ "unicorn/prefer-type-error": "error",
1544
+ // Use new when throwing error
1545
+ "unicorn/throw-new-error": "error"
1546
+ }
1547
+ }
1548
+ ];
1549
+ }
1550
+
1551
+ async function unocss(options = {}) {
1552
+ const {
1553
+ attributify = true,
1554
+ strict = false
1555
+ } = options;
1556
+ await ensurePackages([
1557
+ "@unocss/eslint-plugin"
1558
+ ]);
1559
+ const [
1560
+ pluginUnoCSS
1561
+ ] = await Promise.all([
1562
+ interopDefault(import('@unocss/eslint-plugin'))
1563
+ ]);
1564
+ return [
1565
+ {
1566
+ name: "curev:unocss",
1567
+ plugins: {
1568
+ unocss: pluginUnoCSS
1569
+ },
1570
+ rules: {
1571
+ "unocss/order": "warn",
1572
+ ...attributify ? {
1573
+ "unocss/order-attributify": "warn"
1574
+ } : {},
1575
+ ...strict ? {
1576
+ "unocss/blocklist": "error"
1577
+ } : {}
1578
+ }
1579
+ }
1580
+ ];
1581
+ }
1582
+
1583
+ async function vue(options = {}) {
1584
+ const {
1585
+ files = [GLOB_VUE],
1586
+ overrides = {},
1587
+ stylistic = true,
1588
+ vueVersion = 3
1589
+ } = options;
1590
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1591
+ const {
1592
+ indent = 2
1593
+ } = typeof stylistic === "boolean" ? {} : stylistic;
1594
+ const [
1595
+ pluginVue,
1596
+ parserVue,
1597
+ processorVueBlocks
1598
+ ] = await Promise.all([
1599
+ // @ts-expect-error missing types
1600
+ interopDefault(import('eslint-plugin-vue')),
1601
+ interopDefault(import('vue-eslint-parser')),
1602
+ interopDefault(import('eslint-processor-vue-blocks'))
1603
+ ]);
1604
+ return [
1605
+ {
1606
+ name: "curev:vue:setup",
1607
+ plugins: {
1608
+ vue: pluginVue
1609
+ }
1610
+ },
1611
+ {
1612
+ files,
1613
+ languageOptions: {
1614
+ parser: parserVue,
1615
+ parserOptions: {
1616
+ ecmaFeatures: {
1617
+ jsx: true
1618
+ },
1619
+ extraFileExtensions: [".vue"],
1620
+ parser: options.typescript ? await interopDefault(import('@typescript-eslint/parser')) : null,
1621
+ sourceType: "module"
1622
+ }
1623
+ },
1624
+ name: "curev:vue:rules",
1625
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([
1626
+ pluginVue.processors[".vue"],
1627
+ processorVueBlocks({
1628
+ ...sfcBlocks,
1629
+ blocks: {
1630
+ styles: true,
1631
+ ...sfcBlocks.blocks
1632
+ }
1633
+ })
1634
+ ]),
1635
+ rules: {
1636
+ ...pluginVue.configs.base.rules,
1637
+ ...vueVersion === 2 ? {
1638
+ ...pluginVue.configs.essential.rules,
1639
+ ...pluginVue.configs["strongly-recommended"].rules,
1640
+ ...pluginVue.configs.recommended.rules
1641
+ } : {
1642
+ ...pluginVue.configs["vue3-essential"].rules,
1643
+ ...pluginVue.configs["vue3-strongly-recommended"].rules,
1644
+ ...pluginVue.configs["vue3-recommended"].rules
1645
+ },
1646
+ "node/prefer-global/process": "off",
1647
+ "vue/block-order": ["error", {
1648
+ order: ["script", "template", "style"]
1649
+ }],
1650
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1651
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1652
+ // this is deprecated
1653
+ "vue/component-tags-order": "off",
1654
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1655
+ "vue/define-macros-order": ["error", {
1656
+ order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1657
+ }],
1658
+ "vue/dot-location": ["error", "property"],
1659
+ "vue/dot-notation": ["error", { allowKeywords: true }],
1660
+ "vue/eqeqeq": ["error", "smart"],
1661
+ "vue/html-indent": ["error", indent],
1662
+ "vue/html-quotes": ["error", "double"],
1663
+ "vue/max-attributes-per-line": "off",
1664
+ "vue/multi-word-component-names": "off",
1665
+ "vue/no-dupe-keys": "off",
1666
+ "vue/no-empty-pattern": "error",
1667
+ "vue/no-irregular-whitespace": "error",
1668
+ "vue/no-loss-of-precision": "error",
1669
+ "vue/no-restricted-syntax": [
1670
+ "error",
1671
+ "DebuggerStatement",
1672
+ "LabeledStatement",
1673
+ "WithStatement"
1674
+ ],
1675
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1676
+ "vue/no-setup-props-reactivity-loss": "off",
1677
+ "vue/no-sparse-arrays": "error",
1678
+ "vue/no-unused-refs": "error",
1679
+ "vue/no-useless-v-bind": "error",
1680
+ "vue/no-v-html": "off",
1681
+ "vue/object-shorthand": [
1682
+ "error",
1683
+ "always",
1684
+ {
1685
+ avoidQuotes: true,
1686
+ ignoreConstructors: false
1687
+ }
1688
+ ],
1689
+ "vue/prefer-separate-static-class": "error",
1690
+ "vue/prefer-template": "error",
1691
+ "vue/prop-name-casing": ["error", "camelCase"],
1692
+ "vue/require-default-prop": "off",
1693
+ "vue/require-prop-types": "off",
1694
+ "vue/space-infix-ops": "error",
1695
+ "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1696
+ ...stylistic ? {
1697
+ "vue/array-bracket-spacing": ["error", "never"],
1698
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
1699
+ "vue/block-spacing": ["error", "always"],
1700
+ "vue/block-tag-newline": ["error", {
1701
+ multiline: "always",
1702
+ singleline: "always"
1703
+ }],
1704
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1705
+ "vue/comma-dangle": ["error", "always-multiline"],
1706
+ "vue/comma-spacing": ["error", { after: true, before: false }],
1707
+ "vue/comma-style": ["error", "last"],
1708
+ "vue/html-comment-content-spacing": ["error", "always", {
1709
+ exceptions: ["-"]
1710
+ }],
1711
+ "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1712
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
1713
+ "vue/object-curly-newline": "off",
1714
+ "vue/object-curly-spacing": ["error", "always"],
1715
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1716
+ "vue/operator-linebreak": ["error", "before"],
1717
+ "vue/padding-line-between-blocks": ["error", "always"],
1718
+ "vue/quote-props": ["error", "consistent-as-needed"],
1719
+ "vue/space-in-parens": ["error", "never"],
1720
+ "vue/template-curly-spacing": "error"
1721
+ } : {},
1722
+ ...overrides
1723
+ }
1724
+ }
1725
+ ];
1726
+ }
1727
+
1728
+ async function yaml(options = {}) {
1729
+ const {
1730
+ files = [GLOB_YAML],
1731
+ overrides = {},
1732
+ stylistic = true
1733
+ } = options;
1734
+ const {
1735
+ indent = 2,
1736
+ quotes = "single"
1737
+ } = typeof stylistic === "boolean" ? {} : stylistic;
1738
+ const [
1739
+ pluginYaml,
1740
+ parserYaml
1741
+ ] = await Promise.all([
1742
+ interopDefault(import('eslint-plugin-yml')),
1743
+ interopDefault(import('yaml-eslint-parser'))
1744
+ ]);
1745
+ return [
1746
+ {
1747
+ name: "curev:yaml:setup",
1748
+ plugins: {
1749
+ yaml: pluginYaml
1750
+ }
1751
+ },
1752
+ {
1753
+ files,
1754
+ languageOptions: {
1755
+ parser: parserYaml
1756
+ },
1757
+ name: "curev:yaml:rules",
1758
+ rules: {
1759
+ "style/spaced-comment": "off",
1760
+ "yaml/block-mapping": "error",
1761
+ "yaml/block-sequence": "error",
1762
+ "yaml/no-empty-key": "error",
1763
+ "yaml/no-empty-sequence-entry": "error",
1764
+ "yaml/no-irregular-whitespace": "error",
1765
+ "yaml/plain-scalar": "error",
1766
+ "yaml/vue-custom-block/no-parsing-error": "error",
1767
+ ...stylistic ? {
1768
+ "yaml/block-mapping-question-indicator-newline": "error",
1769
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1770
+ "yaml/flow-mapping-curly-newline": "error",
1771
+ "yaml/flow-mapping-curly-spacing": "error",
1772
+ "yaml/flow-sequence-bracket-newline": "error",
1773
+ "yaml/flow-sequence-bracket-spacing": "error",
1774
+ "yaml/indent": ["error", indent === "tab" ? 2 : indent],
1775
+ "yaml/key-spacing": "error",
1776
+ "yaml/no-tab-indent": "error",
1777
+ "yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
1778
+ "yaml/spaced-comment": "error"
1779
+ } : {},
1780
+ ...overrides
1781
+ }
1782
+ }
1783
+ ];
1784
+ }
1785
+
1786
+ async function toml(options = {}) {
1787
+ const {
1788
+ files = [GLOB_TOML],
1789
+ overrides = {},
1790
+ stylistic = true
1791
+ } = options;
1792
+ const {
1793
+ indent = 2
1794
+ } = typeof stylistic === "boolean" ? {} : stylistic;
1795
+ const [
1796
+ pluginToml,
1797
+ parserToml
1798
+ ] = await Promise.all([
1799
+ interopDefault(import('eslint-plugin-toml')),
1800
+ interopDefault(import('toml-eslint-parser'))
1801
+ ]);
1802
+ return [
1803
+ {
1804
+ name: "curev:toml:setup",
1805
+ plugins: {
1806
+ toml: pluginToml
1807
+ }
1808
+ },
1809
+ {
1810
+ files,
1811
+ languageOptions: {
1812
+ parser: parserToml
1813
+ },
1814
+ name: "curev:toml:rules",
1815
+ rules: {
1816
+ "style/spaced-comment": "off",
1817
+ "toml/comma-style": "error",
1818
+ "toml/keys-order": "error",
1819
+ "toml/no-space-dots": "error",
1820
+ "toml/no-unreadable-number-separator": "error",
1821
+ "toml/precision-of-fractional-seconds": "error",
1822
+ "toml/precision-of-integer": "error",
1823
+ "toml/tables-order": "error",
1824
+ "toml/vue-custom-block/no-parsing-error": "error",
1825
+ ...stylistic ? {
1826
+ "toml/array-bracket-newline": "error",
1827
+ "toml/array-bracket-spacing": "error",
1828
+ "toml/array-element-newline": "error",
1829
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1830
+ "toml/inline-table-curly-spacing": "error",
1831
+ "toml/key-spacing": "error",
1832
+ "toml/padding-line-between-pairs": "error",
1833
+ "toml/padding-line-between-tables": "error",
1834
+ "toml/quoted-keys": "error",
1835
+ "toml/spaced-comment": "error",
1836
+ "toml/table-bracket-spacing": "error"
1837
+ } : {},
1838
+ ...overrides
1839
+ }
1840
+ }
1841
+ ];
1842
+ }
1843
+
1844
+ const flatConfigProps = [
1845
+ "name",
1846
+ "files",
1847
+ "ignores",
1848
+ "languageOptions",
1849
+ "linterOptions",
1850
+ "processor",
1851
+ "plugins",
1852
+ "rules",
1853
+ "settings"
1854
+ ];
1855
+ const VuePackages = [
1856
+ "vue",
1857
+ "nuxt",
1858
+ "vitepress",
1859
+ "@slidev/cli"
1860
+ ];
1861
+ async function curev(options = {}, ...userConfigs) {
1862
+ const {
1863
+ componentExts = [],
1864
+ gitignore: enableGitignore = true,
1865
+ isInEditor = !!((process.env.VSCODE_PID || process.env.JETBRAINS_IDE || process.env.VIM) && !process.env.CI),
1866
+ react: enableReact = false,
1867
+ svelte: enableSvelte = false,
1868
+ typescript: enableTypeScript = isPackageExists("typescript"),
1869
+ unocss: enableUnoCSS = false,
1870
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i))
1871
+ } = options;
1872
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1873
+ if (stylisticOptions && !("jsx" in stylisticOptions)) {
1874
+ stylisticOptions.jsx = options.jsx ?? true;
1875
+ }
1876
+ const configs = [];
1877
+ if (enableGitignore) {
1878
+ if (typeof enableGitignore !== "boolean") {
1879
+ configs.push(interopDefault(import('eslint-config-flat-gitignore')).then((r) => [r(enableGitignore)]));
1880
+ } else {
1881
+ if (fs.existsSync(".gitignore")) {
1882
+ configs.push(interopDefault(import('eslint-config-flat-gitignore')).then((r) => [r()]));
1883
+ }
1884
+ }
1885
+ }
1886
+ configs.push(
1887
+ ignores(),
1888
+ javascript({
1889
+ isInEditor,
1890
+ overrides: getOverrides(options, "javascript")
1891
+ }),
1892
+ comments(),
1893
+ node(),
1894
+ jsdoc({
1895
+ stylistic: stylisticOptions
1896
+ }),
1897
+ imports({
1898
+ stylistic: stylisticOptions
1899
+ }),
1900
+ unicorn(),
1901
+ // Optional plugins (installed but not enabled by default)
1902
+ perfectionist()
1903
+ );
1904
+ if (enableVue) {
1905
+ componentExts.push("vue");
1906
+ }
1907
+ if (enableTypeScript) {
1908
+ configs.push(typescript({
1909
+ ...resolveSubOptions(options, "typescript"),
1910
+ componentExts,
1911
+ overrides: getOverrides(options, "typescript")
1912
+ }));
1913
+ }
1914
+ if (stylisticOptions) {
1915
+ configs.push(stylistic({
1916
+ ...stylisticOptions,
1917
+ overrides: getOverrides(options, "stylistic")
1918
+ }));
1919
+ }
1920
+ if (options.test ?? true) {
1921
+ configs.push(test({
1922
+ isInEditor,
1923
+ overrides: getOverrides(options, "test")
1924
+ }));
1925
+ }
1926
+ if (enableVue) {
1927
+ configs.push(vue({
1928
+ ...resolveSubOptions(options, "vue"),
1929
+ overrides: getOverrides(options, "vue"),
1930
+ stylistic: stylisticOptions,
1931
+ typescript: !!enableTypeScript
1932
+ }));
1933
+ }
1934
+ if (enableReact) {
1935
+ configs.push(react({
1936
+ overrides: getOverrides(options, "react"),
1937
+ typescript: !!enableTypeScript
1938
+ }));
1939
+ }
1940
+ if (enableSvelte) {
1941
+ configs.push(svelte({
1942
+ overrides: getOverrides(options, "svelte"),
1943
+ stylistic: stylisticOptions,
1944
+ typescript: !!enableTypeScript
1945
+ }));
1946
+ }
1947
+ if (enableUnoCSS) {
1948
+ configs.push(unocss({
1949
+ ...resolveSubOptions(options, "unocss"),
1950
+ overrides: getOverrides(options, "unocss")
1951
+ }));
1952
+ }
1953
+ if (options.jsonc ?? true) {
1954
+ configs.push(
1955
+ jsonc({
1956
+ overrides: getOverrides(options, "jsonc"),
1957
+ stylistic: stylisticOptions
1958
+ }),
1959
+ sortPackageJson(),
1960
+ sortTsconfig()
1961
+ );
1962
+ }
1963
+ if (options.yaml ?? true) {
1964
+ configs.push(yaml({
1965
+ overrides: getOverrides(options, "yaml"),
1966
+ stylistic: stylisticOptions
1967
+ }));
1968
+ }
1969
+ if (options.toml ?? true) {
1970
+ configs.push(toml({
1971
+ overrides: getOverrides(options, "toml"),
1972
+ stylistic: stylisticOptions
1973
+ }));
1974
+ }
1975
+ if (options.markdown ?? true) {
1976
+ configs.push(
1977
+ markdown(
1978
+ {
1979
+ componentExts,
1980
+ overrides: getOverrides(options, "markdown")
1981
+ }
1982
+ )
1983
+ );
1984
+ }
1985
+ if (options.formatters) {
1986
+ configs.push(formatters(
1987
+ options.formatters,
1988
+ typeof stylisticOptions === "boolean" ? {} : stylisticOptions
1989
+ ));
1990
+ }
1991
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
1992
+ if (key in options) {
1993
+ acc[key] = options[key];
1994
+ }
1995
+ return acc;
1996
+ }, {});
1997
+ if (Object.keys(fusedConfig).length) {
1998
+ configs.push([fusedConfig]);
1999
+ }
2000
+ const merged = combine(
2001
+ ...configs,
2002
+ ...userConfigs
2003
+ );
2004
+ return merged;
2005
+ }
2006
+ function resolveSubOptions(options, key) {
2007
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
2008
+ }
2009
+ function getOverrides(options, key) {
2010
+ const sub = resolveSubOptions(options, key);
2011
+ return {
2012
+ ...options.overrides?.[key],
2013
+ ..."overrides" in sub ? sub.overrides : {}
2014
+ };
2015
+ }
2016
+
2017
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, 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_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, StylisticConfigDefaults, combine, comments, curev, curev as default, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };