@coderwyd/eslint-config 2.6.4 → 2.7.1

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.cjs CHANGED
@@ -37,6 +37,9 @@ __export(src_exports, {
37
37
  getOverrides: () => getOverrides,
38
38
  getVueVersion: () => getVueVersion,
39
39
  interopDefault: () => interopDefault,
40
+ isInEditorEnv: () => isInEditorEnv,
41
+ isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
42
+ isPackageInScope: () => isPackageInScope,
40
43
  parserPlain: () => parserPlain,
41
44
  renamePluginInConfigs: () => renamePluginInConfigs,
42
45
  renameRules: () => renameRules,
@@ -45,14 +48,29 @@ __export(src_exports, {
45
48
  });
46
49
  module.exports = __toCommonJS(src_exports);
47
50
 
51
+ // node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.39_tsx@4.19.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
52
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
53
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
54
+
55
+ // src/configs/command.ts
56
+ var import_config = __toESM(require("eslint-plugin-command/config"), 1);
57
+ function command() {
58
+ return [
59
+ {
60
+ ...(0, import_config.default)(),
61
+ name: "coderwyd/command/rules"
62
+ }
63
+ ];
64
+ }
65
+
48
66
  // src/plugins/index.ts
67
+ var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
49
68
  var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
50
- var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
51
69
  var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
52
70
  var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
71
+ var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
53
72
  var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
54
73
  var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
55
- var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
56
74
 
57
75
  // src/configs/comments.ts
58
76
  function comments() {
@@ -136,117 +154,428 @@ var GLOB_EXCLUDE = [
136
154
  "**/components.d.ts"
137
155
  ];
138
156
 
139
- // src/configs/ignores.ts
140
- function ignores() {
157
+ // src/configs/disables.ts
158
+ function disables() {
141
159
  return [
142
160
  {
143
- ignores: GLOB_EXCLUDE
144
- }
145
- ];
146
- }
147
-
148
- // src/configs/imports.ts
149
- function imports(options = {}) {
150
- const { stylistic: stylistic2 = true } = options;
151
- return [
161
+ files: [`scripts/${GLOB_SRC}`],
162
+ name: "coderwyd/disables/scripts",
163
+ rules: {
164
+ "no-console": "off",
165
+ "ts/explicit-function-return-type": "off",
166
+ "unicorn/consistent-function-scoping": "off"
167
+ }
168
+ },
152
169
  {
153
- name: "coderwyd/imports/rules",
154
- plugins: {
155
- antfu: import_eslint_plugin_antfu.default,
156
- import: pluginImport
157
- },
170
+ files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
171
+ name: "coderwyd/disables/cli",
158
172
  rules: {
159
- "antfu/import-dedupe": "error",
160
- "antfu/no-import-dist": "error",
161
- "antfu/no-import-node-modules-by-path": "error",
162
- "import/first": "error",
163
- "import/no-duplicates": "error",
164
- "import/no-mutable-exports": "error",
165
- "import/no-named-default": "error",
166
- "import/no-self-import": "error",
167
- "import/no-webpack-loader-syntax": "error",
168
- ...stylistic2 ? {
169
- "import/newline-after-import": ["error", { count: 1 }]
170
- } : {}
173
+ "no-console": "off"
171
174
  }
172
175
  },
173
176
  {
174
177
  files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
175
- name: "coderwyd/imports/disables/bin",
178
+ name: "coderwyd/disables/bin",
176
179
  rules: {
177
180
  "antfu/no-import-dist": "off",
178
181
  "antfu/no-import-node-modules-by-path": "off"
179
182
  }
183
+ },
184
+ {
185
+ files: [GLOB_DTS],
186
+ name: "coderwyd/disables/dts",
187
+ rules: {
188
+ "eslint-comments/no-unlimited-disable": "off",
189
+ "import/no-duplicates": "off",
190
+ "no-restricted-syntax": "off",
191
+ "unused-imports/no-unused-vars": "off"
192
+ }
193
+ },
194
+ {
195
+ files: ["**/*.{test,spec}.([tj])s?(x)"],
196
+ name: "coderwyd/disables/test",
197
+ rules: {
198
+ "no-unused-expressions": "off"
199
+ }
200
+ },
201
+ {
202
+ files: ["**/*.js", "**/*.cjs"],
203
+ name: "coderwyd/disables/cjs",
204
+ rules: {
205
+ "ts/no-require-imports": "off"
206
+ }
180
207
  }
181
208
  ];
182
209
  }
183
210
 
184
- // src/configs/javascript.ts
185
- var import_globals = __toESM(require("globals"), 1);
186
- function javascript(options = {}) {
187
- const { isInEditor: isInEditor2 = false, overrides = {} } = options;
188
- return [
189
- {
190
- languageOptions: {
191
- ecmaVersion: 2022,
192
- globals: {
193
- ...import_globals.default.browser,
194
- ...import_globals.default.es2021,
195
- ...import_globals.default.node,
196
- document: "readonly",
197
- navigator: "readonly",
198
- window: "readonly"
199
- },
200
- parserOptions: {
201
- ecmaFeatures: {
202
- jsx: true
203
- },
204
- ecmaVersion: 2022,
205
- sourceType: "module"
206
- },
207
- sourceType: "module"
208
- },
209
- linterOptions: {
210
- reportUnusedDisableDirectives: true
211
- },
212
- name: "coderwyd/javascript/setup"
211
+ // src/shared/index.ts
212
+ var import_node_process = __toESM(require("process"), 1);
213
+ var import_node_url = require("url");
214
+ var import_local_pkg = require("local-pkg");
215
+ var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
216
+ var isCwdInScope = (0, import_local_pkg.isPackageExists)("@coderwyd/eslint-config");
217
+ var parserPlain = {
218
+ meta: {
219
+ name: "parser-plain"
220
+ },
221
+ parseForESLint: (code) => ({
222
+ ast: {
223
+ body: [],
224
+ comments: [],
225
+ loc: { end: code.length, start: 0 },
226
+ range: [0, code.length],
227
+ tokens: [],
228
+ type: "Program"
213
229
  },
230
+ scopeManager: null,
231
+ services: { isPlain: true },
232
+ visitorKeys: {
233
+ Program: []
234
+ }
235
+ })
236
+ };
237
+ async function combine(...configs2) {
238
+ const resolved = await Promise.all(configs2);
239
+ return resolved.flat();
240
+ }
241
+ function renameRules(rules, map) {
242
+ return Object.fromEntries(
243
+ Object.entries(rules).map(([key, value]) => {
244
+ for (const [from, to] of Object.entries(map)) {
245
+ if (key.startsWith(`${from}/`))
246
+ return [to + key.slice(from.length), value];
247
+ }
248
+ return [key, value];
249
+ })
250
+ );
251
+ }
252
+ function renamePluginInConfigs(configs2, map) {
253
+ return configs2.map((i) => {
254
+ const clone = { ...i };
255
+ if (clone.rules)
256
+ clone.rules = renameRules(clone.rules, map);
257
+ if (clone.plugins) {
258
+ clone.plugins = Object.fromEntries(
259
+ Object.entries(clone.plugins).map(([key, value]) => {
260
+ if (key in map)
261
+ return [map[key], value];
262
+ return [key, value];
263
+ })
264
+ );
265
+ }
266
+ return clone;
267
+ });
268
+ }
269
+ function getVueVersion() {
270
+ const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
271
+ if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
272
+ return +pkg.version[0];
273
+ return 3;
274
+ }
275
+ function toArray(value) {
276
+ return Array.isArray(value) ? value : [value];
277
+ }
278
+ async function interopDefault(m) {
279
+ const resolved = await m;
280
+ return resolved.default || resolved;
281
+ }
282
+ function isPackageInScope(name) {
283
+ return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
284
+ }
285
+ async function ensurePackages(packages) {
286
+ if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
287
+ return;
288
+ const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
289
+ if (nonExistingPackages.length === 0)
290
+ return;
291
+ const { default: prompts } = await import("prompts");
292
+ const { result } = await prompts([
214
293
  {
215
- name: "coderwyd/javascript/rules",
294
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
295
+ name: "result",
296
+ type: "confirm"
297
+ }
298
+ ]);
299
+ if (result) {
300
+ await import("@antfu/install-pkg").then(
301
+ (i) => i.installPackage(nonExistingPackages, { dev: true })
302
+ );
303
+ }
304
+ }
305
+ function resolveSubOptions(options, key) {
306
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
307
+ }
308
+ function getOverrides(options, key) {
309
+ const sub = resolveSubOptions(options, key);
310
+ return {
311
+ ..."overrides" in sub ? sub.overrides || {} : {}
312
+ };
313
+ }
314
+ function isInEditorEnv() {
315
+ if (import_node_process.default.env.CI)
316
+ return false;
317
+ if (isInGitHooksOrLintStaged())
318
+ return false;
319
+ return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM || false);
320
+ }
321
+ function isInGitHooksOrLintStaged() {
322
+ return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged") || import_node_process.default.env.npm_lifecycle_script?.startsWith("nano-staged") || false);
323
+ }
324
+
325
+ // src/configs/stylistic.ts
326
+ var StylisticConfigDefaults = {
327
+ indent: 2,
328
+ jsx: true,
329
+ quotes: "single",
330
+ semi: false
331
+ };
332
+ async function stylistic(options = {}) {
333
+ const {
334
+ indent,
335
+ jsx: jsx2,
336
+ overrides = {},
337
+ quotes,
338
+ semi
339
+ } = {
340
+ ...StylisticConfigDefaults,
341
+ ...options
342
+ };
343
+ const pluginStylistic = await interopDefault(
344
+ import("@stylistic/eslint-plugin")
345
+ );
346
+ const config = pluginStylistic.configs.customize({
347
+ flat: true,
348
+ indent,
349
+ jsx: jsx2,
350
+ pluginName: "style",
351
+ quotes,
352
+ semi
353
+ });
354
+ return [
355
+ {
356
+ name: "coderwyd/stylistic/rules",
216
357
  plugins: {
217
- "unused-imports": import_eslint_plugin_unused_imports.default
358
+ antfu: import_eslint_plugin_antfu.default,
359
+ style: pluginStylistic
218
360
  },
219
361
  rules: {
220
- "accessor-pairs": [
221
- "error",
222
- { enforceForClassMembers: true, setWithoutGet: true }
223
- ],
224
- "array-callback-return": "error",
225
- "block-scoped-var": "error",
226
- "constructor-super": "error",
227
- "default-case-last": "error",
228
- "dot-notation": ["error", { allowKeywords: true }],
229
- "eqeqeq": ["error", "smart"],
230
- "for-direction": "error",
231
- "getter-return": "error",
232
- "new-cap": [
233
- "error",
234
- { capIsNew: false, newIsCap: true, properties: true }
235
- ],
236
- "no-alert": "error",
237
- "no-array-constructor": "error",
238
- "no-async-promise-executor": "error",
239
- "no-caller": "error",
240
- "no-case-declarations": "error",
241
- "no-class-assign": "error",
242
- "no-compare-neg-zero": "error",
243
- "no-cond-assign": ["error", "always"],
244
- "no-console": ["error", { allow: ["warn", "error"] }],
245
- "no-const-assign": "error",
246
- "no-constant-binary-expression": "error",
247
- "no-constant-condition": "error",
248
- "no-control-regex": "error",
249
- "no-debugger": "error",
362
+ ...config.rules,
363
+ "antfu/consistent-chaining": "error",
364
+ "antfu/consistent-list-newline": "error",
365
+ "antfu/curly": "error",
366
+ "antfu/if-newline": "warn",
367
+ "antfu/top-level-function": "warn",
368
+ ...overrides
369
+ }
370
+ }
371
+ ];
372
+ }
373
+
374
+ // src/configs/formatter.ts
375
+ async function formatter(options = {}, stylistic2 = {}) {
376
+ const { css, graphql, html, markdown, toml, yaml } = options === true ? {
377
+ css: true,
378
+ graphql: true,
379
+ html: true,
380
+ markdown: true,
381
+ toml: true,
382
+ yaml: true
383
+ } : options;
384
+ const { indent, quotes, semi } = {
385
+ ...StylisticConfigDefaults,
386
+ ...stylistic2
387
+ };
388
+ const prettierOptions = Object.assign(
389
+ {
390
+ endOfLine: "auto",
391
+ printWidth: 80,
392
+ semi,
393
+ singleQuote: quotes === "single",
394
+ tabWidth: typeof indent === "number" ? indent : 2,
395
+ trailingComma: "all",
396
+ useTabs: indent === "tab"
397
+ },
398
+ typeof options === "boolean" ? {} : options.prettierOptions || {}
399
+ );
400
+ await ensurePackages(["eslint-plugin-format"]);
401
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
402
+ function createPrettierFormatter(files, parser, plugins) {
403
+ const rules = {
404
+ ...prettierOptions,
405
+ parser
406
+ };
407
+ const markdownRules = {
408
+ printWidth: 120,
409
+ ...rules,
410
+ embeddedLanguageFormatting: "off"
411
+ };
412
+ if (plugins?.length)
413
+ rules.plugins = [...rules.plugins || [], ...plugins];
414
+ const config = {
415
+ files,
416
+ languageOptions: {
417
+ parser: parserPlain
418
+ },
419
+ name: `coderwyd/formatter/${parser}`,
420
+ plugins: {
421
+ format: pluginFormat
422
+ },
423
+ rules: {
424
+ "format/prettier": [
425
+ "warn",
426
+ parser === "markdown" ? markdownRules : rules
427
+ ]
428
+ }
429
+ };
430
+ return config;
431
+ }
432
+ const configs2 = [
433
+ {
434
+ name: "coderwyd/formatter/setup",
435
+ plugins: {
436
+ format: pluginFormat
437
+ }
438
+ }
439
+ ];
440
+ if (html) {
441
+ const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
442
+ configs2.push(htmlConfig);
443
+ }
444
+ if (css) {
445
+ const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
446
+ const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
447
+ const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
448
+ configs2.push(cssConfig, scssConfig, lessConfig);
449
+ }
450
+ if (markdown) {
451
+ const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
452
+ configs2.push(markdownConfig);
453
+ }
454
+ if (graphql) {
455
+ const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
456
+ configs2.push(graphqlConfig);
457
+ }
458
+ if (yaml) {
459
+ const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
460
+ configs2.push(yamlConfig);
461
+ }
462
+ if (toml) {
463
+ await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
464
+ const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
465
+ "prettier-plugin-toml"
466
+ ]);
467
+ configs2.push(tomlConfig);
468
+ }
469
+ return configs2;
470
+ }
471
+
472
+ // src/configs/ignores.ts
473
+ function ignores(userIgnores = []) {
474
+ return [
475
+ {
476
+ ignores: [
477
+ ...GLOB_EXCLUDE,
478
+ ...userIgnores
479
+ ],
480
+ name: "coderwyd/ignores"
481
+ }
482
+ ];
483
+ }
484
+
485
+ // src/configs/imports.ts
486
+ function imports(options = {}) {
487
+ const { stylistic: stylistic2 = true } = options;
488
+ return [
489
+ {
490
+ name: "coderwyd/imports/rules",
491
+ plugins: {
492
+ antfu: import_eslint_plugin_antfu.default,
493
+ import: pluginImport
494
+ },
495
+ rules: {
496
+ "antfu/import-dedupe": "error",
497
+ "antfu/no-import-dist": "error",
498
+ "antfu/no-import-node-modules-by-path": "error",
499
+ "import/first": "error",
500
+ "import/no-duplicates": "error",
501
+ "import/no-mutable-exports": "error",
502
+ "import/no-named-default": "error",
503
+ "import/no-self-import": "error",
504
+ "import/no-webpack-loader-syntax": "error",
505
+ ...stylistic2 ? {
506
+ "import/newline-after-import": ["error", { count: 1 }]
507
+ } : {}
508
+ }
509
+ }
510
+ ];
511
+ }
512
+
513
+ // src/configs/javascript.ts
514
+ var import_globals = __toESM(require("globals"), 1);
515
+ function javascript(options = {}) {
516
+ const { isInEditor: isInEditor2 = false, overrides = {} } = options;
517
+ return [
518
+ {
519
+ languageOptions: {
520
+ ecmaVersion: 2022,
521
+ globals: {
522
+ ...import_globals.default.browser,
523
+ ...import_globals.default.es2021,
524
+ ...import_globals.default.node,
525
+ document: "readonly",
526
+ navigator: "readonly",
527
+ window: "readonly"
528
+ },
529
+ parserOptions: {
530
+ ecmaFeatures: {
531
+ jsx: true
532
+ },
533
+ ecmaVersion: 2022,
534
+ sourceType: "module"
535
+ },
536
+ sourceType: "module"
537
+ },
538
+ linterOptions: {
539
+ reportUnusedDisableDirectives: true
540
+ },
541
+ name: "coderwyd/javascript/setup"
542
+ },
543
+ {
544
+ name: "coderwyd/javascript/rules",
545
+ plugins: {
546
+ "unused-imports": import_eslint_plugin_unused_imports.default
547
+ },
548
+ rules: {
549
+ "accessor-pairs": [
550
+ "error",
551
+ { enforceForClassMembers: true, setWithoutGet: true }
552
+ ],
553
+ "array-callback-return": "error",
554
+ "block-scoped-var": "error",
555
+ "constructor-super": "error",
556
+ "default-case-last": "error",
557
+ "dot-notation": ["error", { allowKeywords: true }],
558
+ "eqeqeq": ["error", "smart"],
559
+ "for-direction": "error",
560
+ "getter-return": "error",
561
+ "new-cap": [
562
+ "error",
563
+ { capIsNew: false, newIsCap: true, properties: true }
564
+ ],
565
+ "no-alert": "error",
566
+ "no-array-constructor": "error",
567
+ "no-async-promise-executor": "error",
568
+ "no-caller": "error",
569
+ "no-case-declarations": "error",
570
+ "no-class-assign": "error",
571
+ "no-compare-neg-zero": "error",
572
+ "no-cond-assign": ["error", "always"],
573
+ "no-console": ["error", { allow: ["warn", "error"] }],
574
+ "no-const-assign": "error",
575
+ "no-constant-binary-expression": "error",
576
+ "no-constant-condition": "error",
577
+ "no-control-regex": "error",
578
+ "no-debugger": "error",
250
579
  "no-delete-var": "error",
251
580
  "no-dupe-args": "error",
252
581
  "no-dupe-class-members": "error",
@@ -315,9 +644,6 @@ function javascript(options = {}) {
315
644
  ],
316
645
  "no-restricted-syntax": [
317
646
  "error",
318
- "DebuggerStatement",
319
- "LabeledStatement",
320
- "WithStatement",
321
647
  "TSEnumDeclaration[const=true]",
322
648
  "TSExportAssignment"
323
649
  ],
@@ -413,151 +739,39 @@ function javascript(options = {}) {
413
739
  "yoda": ["error", "never"],
414
740
  ...overrides
415
741
  }
416
- },
417
- {
418
- files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
419
- name: "coderwyd/javascript/disables/cli",
420
- rules: {
421
- "no-console": "off"
422
- }
423
- },
742
+ }
743
+ ];
744
+ }
745
+
746
+ // src/configs/jsdoc.ts
747
+ async function jsdoc(options = {}) {
748
+ const { stylistic: stylistic2 = true } = options;
749
+ return [
424
750
  {
425
- files: ["**/*.{test,spec}.js?(x)"],
426
- name: "coderwyd/javascript/disables/test",
751
+ name: "coderwyd/jsdoc/rules",
752
+ plugins: {
753
+ jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
754
+ },
427
755
  rules: {
428
- "no-unused-expressions": "off"
429
- }
430
- }
431
- ];
432
- }
433
-
434
- // src/shared/index.ts
435
- var import_node_process = __toESM(require("process"), 1);
436
- var import_local_pkg = require("local-pkg");
437
- var parserPlain = {
438
- meta: {
439
- name: "parser-plain"
440
- },
441
- parseForESLint: (code) => ({
442
- ast: {
443
- body: [],
444
- comments: [],
445
- loc: { end: code.length, start: 0 },
446
- range: [0, code.length],
447
- tokens: [],
448
- type: "Program"
449
- },
450
- scopeManager: null,
451
- services: { isPlain: true },
452
- visitorKeys: {
453
- Program: []
454
- }
455
- })
456
- };
457
- async function combine(...configs2) {
458
- const resolved = await Promise.all(configs2);
459
- return resolved.flat();
460
- }
461
- function renameRules(rules, map) {
462
- return Object.fromEntries(
463
- Object.entries(rules).map(([key, value]) => {
464
- for (const [from, to] of Object.entries(map)) {
465
- if (key.startsWith(`${from}/`))
466
- return [to + key.slice(from.length), value];
467
- }
468
- return [key, value];
469
- })
470
- );
471
- }
472
- function renamePluginInConfigs(configs2, map) {
473
- return configs2.map((i) => {
474
- const clone = { ...i };
475
- if (clone.rules)
476
- clone.rules = renameRules(clone.rules, map);
477
- if (clone.plugins) {
478
- clone.plugins = Object.fromEntries(
479
- Object.entries(clone.plugins).map(([key, value]) => {
480
- if (key in map)
481
- return [map[key], value];
482
- return [key, value];
483
- })
484
- );
485
- }
486
- return clone;
487
- });
488
- }
489
- function getVueVersion() {
490
- const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
491
- if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
492
- return +pkg.version[0];
493
- return 3;
494
- }
495
- function toArray(value) {
496
- return Array.isArray(value) ? value : [value];
497
- }
498
- async function interopDefault(m) {
499
- const resolved = await m;
500
- return resolved.default || resolved;
501
- }
502
- async function ensurePackages(packages) {
503
- if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false)
504
- return;
505
- const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i));
506
- if (nonExistingPackages.length === 0)
507
- return;
508
- const { default: prompts } = await import("prompts");
509
- const { result } = await prompts([
510
- {
511
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
512
- name: "result",
513
- type: "confirm"
514
- }
515
- ]);
516
- if (result) {
517
- await import("@antfu/install-pkg").then(
518
- (i) => i.installPackage(nonExistingPackages, { dev: true })
519
- );
520
- }
521
- }
522
- function resolveSubOptions(options, key) {
523
- return typeof options[key] === "boolean" ? {} : options[key] || {};
524
- }
525
- function getOverrides(options, key) {
526
- const sub = resolveSubOptions(options, key);
527
- return {
528
- ..."overrides" in sub ? sub.overrides || {} : {}
529
- };
530
- }
531
-
532
- // src/configs/jsdoc.ts
533
- async function jsdoc(options = {}) {
534
- const { stylistic: stylistic2 = true } = options;
535
- return [
536
- {
537
- name: "coderwyd/jsdoc/rules",
538
- plugins: {
539
- jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
540
- },
541
- rules: {
542
- "jsdoc/check-access": "warn",
543
- "jsdoc/check-param-names": "warn",
544
- "jsdoc/check-property-names": "warn",
545
- "jsdoc/check-types": "warn",
546
- "jsdoc/empty-tags": "warn",
547
- "jsdoc/implements-on-classes": "warn",
548
- "jsdoc/no-defaults": "warn",
549
- "jsdoc/no-multi-asterisks": "warn",
550
- "jsdoc/require-param-name": "warn",
551
- "jsdoc/require-property": "warn",
552
- "jsdoc/require-property-description": "warn",
553
- "jsdoc/require-property-name": "warn",
554
- "jsdoc/require-returns-check": "warn",
555
- "jsdoc/require-returns-description": "warn",
556
- "jsdoc/require-yields-check": "warn",
557
- ...stylistic2 ? {
558
- "jsdoc/check-alignment": "warn",
559
- "jsdoc/multiline-blocks": "warn"
560
- } : {}
756
+ "jsdoc/check-access": "warn",
757
+ "jsdoc/check-param-names": "warn",
758
+ "jsdoc/check-property-names": "warn",
759
+ "jsdoc/check-types": "warn",
760
+ "jsdoc/empty-tags": "warn",
761
+ "jsdoc/implements-on-classes": "warn",
762
+ "jsdoc/no-defaults": "warn",
763
+ "jsdoc/no-multi-asterisks": "warn",
764
+ "jsdoc/require-param-name": "warn",
765
+ "jsdoc/require-property": "warn",
766
+ "jsdoc/require-property-description": "warn",
767
+ "jsdoc/require-property-name": "warn",
768
+ "jsdoc/require-returns-check": "warn",
769
+ "jsdoc/require-returns-description": "warn",
770
+ "jsdoc/require-yields-check": "warn",
771
+ ...stylistic2 ? {
772
+ "jsdoc/check-alignment": "warn",
773
+ "jsdoc/multiline-blocks": "warn"
774
+ } : {}
561
775
  }
562
776
  }
563
777
  ];
@@ -644,6 +858,23 @@ async function jsonc(options = {}) {
644
858
  ];
645
859
  }
646
860
 
861
+ // src/configs/jsx.ts
862
+ function jsx() {
863
+ return [
864
+ {
865
+ files: [GLOB_JSX, GLOB_TSX],
866
+ languageOptions: {
867
+ parserOptions: {
868
+ ecmaFeatures: {
869
+ jsx: true
870
+ }
871
+ }
872
+ },
873
+ name: "coderwyd/jsx/setup"
874
+ }
875
+ ];
876
+ }
877
+
647
878
  // src/configs/node.ts
648
879
  function node() {
649
880
  return [
@@ -667,1303 +898,1103 @@ function node() {
667
898
  ];
668
899
  }
669
900
 
670
- // src/configs/sort.ts
671
- function sortPackageJson() {
901
+ // src/configs/perfectionist.ts
902
+ function perfectionist() {
672
903
  return [
673
904
  {
674
- files: ["**/package.json"],
675
- name: "coderwyd/sort/package-json",
905
+ name: "coderwyd/perfectionist/rules",
906
+ plugins: {
907
+ perfectionist: import_eslint_plugin_perfectionist.default
908
+ },
676
909
  rules: {
677
- "jsonc/sort-array-values": [
678
- "error",
679
- {
680
- order: { type: "asc" },
681
- pathPattern: "^files$"
682
- }
683
- ],
684
- "jsonc/sort-keys": [
685
- "error",
910
+ "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
911
+ "perfectionist/sort-imports": [
912
+ "warn",
686
913
  {
687
- order: [
688
- "publisher",
689
- "name",
690
- "displayName",
914
+ groups: [
915
+ "builtin",
916
+ "external",
691
917
  "type",
692
- "version",
693
- "private",
694
- "packageManager",
695
- "description",
696
- "author",
697
- "license",
698
- "funding",
699
- "homepage",
700
- "repository",
701
- "bugs",
702
- "keywords",
703
- "categories",
704
- "sideEffects",
705
- "exports",
706
- "main",
707
- "module",
708
- "unpkg",
709
- "jsdelivr",
710
- "types",
711
- "typesVersions",
712
- "bin",
713
- "icon",
714
- "files",
715
- "engines",
716
- "activationEvents",
717
- "contributes",
718
- "scripts",
719
- "peerDependencies",
720
- "peerDependenciesMeta",
721
- "dependencies",
722
- "optionalDependencies",
723
- "devDependencies",
724
- "pnpm",
725
- "overrides",
726
- "resolutions",
727
- "husky",
728
- "simple-git-hooks",
729
- "lint-staged",
730
- "eslintConfig"
731
- ],
732
- pathPattern: "^$"
733
- },
734
- {
735
- order: { type: "asc" },
736
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
737
- },
738
- {
739
- order: { type: "asc" },
740
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
741
- },
742
- {
743
- order: ["types", "import", "require", "default"],
744
- pathPattern: "^exports.*$"
745
- },
746
- {
747
- order: [
748
- // client hooks only
749
- "pre-commit",
750
- "prepare-commit-msg",
751
- "commit-msg",
752
- "post-commit",
753
- "pre-rebase",
754
- "post-rewrite",
755
- "post-checkout",
756
- "post-merge",
757
- "pre-push",
758
- "pre-auto-gc"
918
+ ["internal", "internal-type"],
919
+ ["parent", "sibling", "index"],
920
+ ["parent-type", "sibling-type", "index-type"],
921
+ "object",
922
+ "side-effect",
923
+ "side-effect-style",
924
+ "style",
925
+ "unknown"
759
926
  ],
760
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
761
- }
762
- ]
763
- }
764
- }
765
- ];
766
- }
767
- function sortTsconfig() {
768
- return [
769
- {
770
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
771
- name: "coderwyd/sort/tsconfig-json",
772
- rules: {
773
- "jsonc/sort-keys": [
774
- "error",
775
- {
776
- order: [
777
- "extends",
778
- "compilerOptions",
779
- "references",
780
- "files",
781
- "include",
782
- "exclude"
783
- ],
784
- pathPattern: "^$"
785
- },
786
- {
787
- order: [
788
- /* Projects */
789
- "incremental",
790
- "composite",
791
- "tsBuildInfoFile",
792
- "disableSourceOfProjectReferenceRedirect",
793
- "disableSolutionSearching",
794
- "disableReferencedProjectLoad",
795
- /* Language and Environment */
796
- "target",
797
- "jsx",
798
- "jsxFactory",
799
- "jsxFragmentFactory",
800
- "jsxImportSource",
801
- "lib",
802
- "moduleDetection",
803
- "noLib",
804
- "reactNamespace",
805
- "useDefineForClassFields",
806
- "emitDecoratorMetadata",
807
- "experimentalDecorators",
808
- /* Modules */
809
- "baseUrl",
810
- "rootDir",
811
- "rootDirs",
812
- "customConditions",
813
- "module",
814
- "moduleResolution",
815
- "moduleSuffixes",
816
- "noResolve",
817
- "paths",
818
- "resolveJsonModule",
819
- "resolvePackageJsonExports",
820
- "resolvePackageJsonImports",
821
- "typeRoots",
822
- "types",
823
- "allowArbitraryExtensions",
824
- "allowImportingTsExtensions",
825
- "allowUmdGlobalAccess",
826
- /* JavaScript Support */
827
- "allowJs",
828
- "checkJs",
829
- "maxNodeModuleJsDepth",
830
- /* Type Checking */
831
- "strict",
832
- "strictBindCallApply",
833
- "strictFunctionTypes",
834
- "strictNullChecks",
835
- "strictPropertyInitialization",
836
- "allowUnreachableCode",
837
- "allowUnusedLabels",
838
- "alwaysStrict",
839
- "exactOptionalPropertyTypes",
840
- "noFallthroughCasesInSwitch",
841
- "noImplicitAny",
842
- "noImplicitOverride",
843
- "noImplicitReturns",
844
- "noImplicitThis",
845
- "noPropertyAccessFromIndexSignature",
846
- "noUncheckedIndexedAccess",
847
- "noUnusedLocals",
848
- "noUnusedParameters",
849
- "useUnknownInCatchVariables",
850
- /* Emit */
851
- "declaration",
852
- "declarationDir",
853
- "declarationMap",
854
- "downlevelIteration",
855
- "emitBOM",
856
- "emitDeclarationOnly",
857
- "importHelpers",
858
- "importsNotUsedAsValues",
859
- "inlineSourceMap",
860
- "inlineSources",
861
- "mapRoot",
862
- "newLine",
863
- "noEmit",
864
- "noEmitHelpers",
865
- "noEmitOnError",
866
- "outDir",
867
- "outFile",
868
- "preserveConstEnums",
869
- "preserveValueImports",
870
- "removeComments",
871
- "sourceMap",
872
- "sourceRoot",
873
- "stripInternal",
874
- /* Interop Constraints */
875
- "allowSyntheticDefaultImports",
876
- "esModuleInterop",
877
- "forceConsistentCasingInFileNames",
878
- "isolatedDeclarations",
879
- "isolatedModules",
880
- "preserveSymlinks",
881
- "verbatimModuleSyntax",
882
- /* Completeness */
883
- "skipDefaultLibCheck",
884
- "skipLibCheck"
885
- ],
886
- pathPattern: "^compilerOptions$"
927
+ internalPattern: ["~/**", "@/**", "#**"],
928
+ newlinesBetween: "ignore",
929
+ order: "asc",
930
+ type: "natural"
887
931
  }
932
+ ],
933
+ "perfectionist/sort-named-exports": [
934
+ "warn",
935
+ { groupKind: "values-first", order: "asc", type: "natural" }
936
+ ],
937
+ "perfectionist/sort-named-imports": [
938
+ "warn",
939
+ { groupKind: "values-first", order: "asc", type: "natural" }
888
940
  ]
889
941
  }
890
942
  }
891
943
  ];
892
944
  }
893
945
 
894
- // src/configs/stylistic.ts
895
- var StylisticConfigDefaults = {
896
- indent: 2,
897
- jsx: true,
898
- quotes: "single",
899
- semi: false
900
- };
901
- async function stylistic(options = {}) {
902
- const {
903
- indent,
904
- jsx: jsx2,
905
- overrides = {},
906
- quotes,
907
- semi
908
- } = {
909
- ...StylisticConfigDefaults,
910
- ...options
911
- };
912
- const pluginStylistic = await interopDefault(
913
- import("@stylistic/eslint-plugin")
914
- );
915
- const config = pluginStylistic.configs.customize({
916
- flat: true,
917
- indent,
918
- jsx: jsx2,
919
- pluginName: "style",
920
- quotes,
921
- semi
922
- });
923
- return [
924
- {
925
- name: "coderwyd/stylistic/rules",
926
- plugins: {
927
- antfu: import_eslint_plugin_antfu.default,
928
- style: pluginStylistic
929
- },
930
- rules: {
931
- ...config.rules,
932
- "antfu/consistent-list-newline": "error",
933
- "antfu/curly": "error",
934
- "antfu/if-newline": "warn",
935
- "antfu/top-level-function": "warn",
936
- ...overrides
937
- }
938
- }
939
- ];
940
- }
941
-
942
- // src/configs/typescript.ts
943
- var import_node_process2 = __toESM(require("process"), 1);
944
- async function typescript(options = {}) {
945
- const { componentExts = [], overrides = {}, parserOptions = {} } = options;
946
- const files = options.files ?? [
947
- GLOB_TS,
948
- GLOB_TSX,
949
- ...componentExts.map((ext) => `**/*.${ext}`)
950
- ];
951
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
952
- const ignoresTypeAware = options.ignoresTypeAware ?? [
953
- `${GLOB_MARKDOWN}/**`,
954
- GLOB_ASTRO_TS
955
- ];
956
- const tsconfigPath = options.tsconfigPath;
957
- const isTypeAware = !!tsconfigPath;
958
- const typeAwareRules = {
959
- "dot-notation": "off",
960
- "no-implied-eval": "off",
961
- "ts/await-thenable": "error",
962
- "ts/dot-notation": ["error", { allowKeywords: true }],
963
- "ts/no-floating-promises": "error",
964
- "ts/no-for-in-array": "error",
965
- "ts/no-implied-eval": "error",
966
- "ts/no-misused-promises": "error",
967
- "ts/no-unnecessary-type-assertion": "error",
968
- "ts/no-unsafe-argument": "error",
969
- "ts/no-unsafe-assignment": "error",
970
- "ts/no-unsafe-call": "error",
971
- "ts/no-unsafe-member-access": "error",
972
- "ts/no-unsafe-return": "error",
973
- "ts/promise-function-async": "error",
974
- "ts/restrict-plus-operands": "error",
975
- "ts/restrict-template-expressions": "error",
976
- "ts/return-await": "error",
977
- "ts/strict-boolean-expressions": "error",
978
- "ts/switch-exhaustiveness-check": "error",
979
- "ts/unbound-method": "error"
980
- };
981
- const [pluginTs, parserTs] = await Promise.all([
982
- interopDefault(import("@typescript-eslint/eslint-plugin")),
983
- interopDefault(import("@typescript-eslint/parser"))
984
- ]);
985
- function makeParser(typeAware, files2, ignores2) {
986
- return {
987
- files: files2,
988
- ...ignores2 ? { ignores: ignores2 } : {},
989
- languageOptions: {
990
- parser: parserTs,
991
- parserOptions: {
992
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
993
- sourceType: "module",
994
- ...typeAware ? {
995
- projectService: {
996
- allowDefaultProject: ["./*.js"],
997
- defaultProject: tsconfigPath
998
- },
999
- tsconfigRootDir: import_node_process2.default.cwd()
1000
- } : {},
1001
- ...parserOptions
1002
- }
1003
- },
1004
- name: `coderwyd/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1005
- };
1006
- }
1007
- return [
1008
- {
1009
- // Install the plugins without globs, so they can be configured separately.
1010
- name: "coderwyd/typescript/setup",
1011
- plugins: {
1012
- antfu: import_eslint_plugin_antfu.default,
1013
- ts: pluginTs
1014
- }
1015
- },
1016
- // assign type-aware parser for type-aware files and type-unaware parser for the rest
1017
- ...isTypeAware ? [
1018
- makeParser(true, filesTypeAware, ignoresTypeAware),
1019
- makeParser(false, files, filesTypeAware)
1020
- ] : [makeParser(false, files)],
1021
- {
1022
- files,
1023
- name: "coderwyd/typescript/rules",
1024
- rules: {
1025
- ...renameRules(
1026
- pluginTs.configs["eslint-recommended"].overrides[0].rules,
1027
- { "@typescript-eslint": "ts" }
1028
- ),
1029
- ...renameRules(pluginTs.configs.strict.rules, {
1030
- "@typescript-eslint": "ts"
1031
- }),
1032
- "no-dupe-class-members": "off",
1033
- "no-loss-of-precision": "off",
1034
- "no-redeclare": "off",
1035
- "no-use-before-define": "off",
1036
- "no-useless-constructor": "off",
1037
- "ts/ban-ts-comment": [
1038
- "error",
1039
- { "ts-expect-error": "allow-with-description" }
1040
- ],
1041
- "ts/consistent-type-definitions": ["error", "interface"],
1042
- "ts/consistent-type-imports": [
1043
- "error",
1044
- { disallowTypeAnnotations: false, prefer: "type-imports" }
1045
- ],
1046
- "ts/method-signature-style": ["error", "property"],
1047
- // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
1048
- "ts/no-dupe-class-members": "error",
1049
- "ts/no-dynamic-delete": "off",
1050
- "ts/no-empty-object-type": [
1051
- "error",
1052
- {
1053
- allowInterfaces: "with-single-extends",
1054
- // interface Derived extends Base {}
1055
- allowObjectTypes: "never",
1056
- allowWithName: "Props$"
1057
- }
1058
- ],
1059
- "ts/no-explicit-any": "off",
1060
- "ts/no-extraneous-class": "off",
1061
- "ts/no-import-type-side-effects": "error",
1062
- "ts/no-invalid-void-type": "off",
1063
- // this is deprecated
1064
- "ts/no-loss-of-precision": "off",
1065
- "ts/no-non-null-assertion": "off",
1066
- "ts/no-redeclare": "error",
1067
- "ts/no-require-imports": "error",
1068
- "ts/no-unused-vars": "off",
1069
- "ts/no-use-before-define": [
1070
- "error",
1071
- { classes: false, functions: false, variables: true }
1072
- ],
1073
- "ts/no-useless-constructor": "off",
1074
- "ts/no-wrapper-object-types": "error",
1075
- "ts/triple-slash-reference": "off",
1076
- "ts/unified-signatures": "off",
1077
- ...overrides
1078
- }
1079
- },
1080
- ...isTypeAware ? [
1081
- {
1082
- files: filesTypeAware,
1083
- ignores: ignoresTypeAware,
1084
- name: "coderwyd/typescript/rules-type-aware",
1085
- rules: {
1086
- ...tsconfigPath ? typeAwareRules : {},
1087
- ...overrides
1088
- }
1089
- }
1090
- ] : [],
1091
- {
1092
- files: [GLOB_DTS],
1093
- name: "coderwyd/typescript/disables/dts",
1094
- rules: {
1095
- "eslint-comments/no-unlimited-disable": "off",
1096
- "import/no-duplicates": "off",
1097
- "no-restricted-syntax": "off",
1098
- "unused-imports/no-unused-vars": "off"
1099
- }
1100
- },
1101
- {
1102
- files: ["**/*.{test,spec}.ts?(x)"],
1103
- name: "coderwyd/typescript/disables/test",
1104
- rules: {
1105
- "no-unused-expressions": "off"
1106
- }
1107
- },
1108
- {
1109
- files: ["**/*.js", "**/*.cjs"],
1110
- name: "coderwyd/typescript/disables/cjs",
1111
- rules: {
1112
- "ts/no-require-imports": "off",
1113
- "ts/no-var-requires": "off"
1114
- }
1115
- }
1116
- ];
1117
- }
946
+ // src/configs/react.ts
947
+ var import_local_pkg3 = require("local-pkg");
1118
948
 
1119
- // src/configs/unicorn.ts
1120
- function unicorn() {
1121
- return [
1122
- {
1123
- name: "coderwyd/unicorn/rules",
1124
- plugins: {
1125
- unicorn: import_eslint_plugin_unicorn.default
1126
- },
1127
- rules: {
1128
- // 'unicorn/better-regex': 'error',
1129
- "unicorn/catch-error-name": "error",
1130
- "unicorn/consistent-empty-array-spread": "error",
1131
- "unicorn/custom-error-definition": "error",
1132
- "unicorn/error-message": "error",
1133
- // 'unicorn/explicit-length-check': 'error',
1134
- // 'unicorn/filename-case': [
1135
- // 'error',
1136
- // {
1137
- // cases: { kebabCase: true, pascalCase: true },
1138
- // ignore: [/^[A-Z]+\..*$/],
1139
- // },
1140
- "unicorn/escape-case": "error",
1141
- // ],
1142
- "unicorn/new-for-builtins": "error",
1143
- // 'unicorn/no-array-callback-reference': 'error',
1144
- "unicorn/no-array-method-this-argument": "error",
1145
- "unicorn/no-array-push-push": "error",
1146
- "unicorn/no-await-in-promise-methods": "error",
1147
- "unicorn/no-console-spaces": "error",
1148
- "unicorn/no-for-loop": "error",
1149
- "unicorn/no-hex-escape": "error",
1150
- "unicorn/no-instanceof-array": "error",
1151
- "unicorn/no-invalid-remove-event-listener": "error",
1152
- "unicorn/no-length-as-slice-end": "error",
1153
- "unicorn/no-lonely-if": "error",
1154
- "unicorn/no-new-array": "error",
1155
- "unicorn/no-new-buffer": "error",
1156
- "unicorn/no-single-promise-in-promise-methods": "error",
1157
- "unicorn/no-static-only-class": "error",
1158
- "unicorn/no-unnecessary-await": "error",
1159
- "unicorn/no-zero-fractions": `error`,
1160
- "unicorn/prefer-add-event-listener": "error",
1161
- "unicorn/prefer-array-find": "error",
1162
- "unicorn/prefer-array-flat-map": "error",
1163
- "unicorn/prefer-array-index-of": "error",
1164
- "unicorn/prefer-array-some": "error",
1165
- "unicorn/prefer-at": "error",
1166
- "unicorn/prefer-blob-reading-methods": "error",
1167
- "unicorn/prefer-date-now": "error",
1168
- "unicorn/prefer-dom-node-append": "error",
1169
- "unicorn/prefer-dom-node-dataset": "error",
1170
- "unicorn/prefer-dom-node-remove": "error",
1171
- "unicorn/prefer-dom-node-text-content": "error",
1172
- "unicorn/prefer-includes": "error",
1173
- "unicorn/prefer-keyboard-event-key": "error",
1174
- "unicorn/prefer-math-trunc": "error",
1175
- "unicorn/prefer-modern-dom-apis": "error",
1176
- "unicorn/prefer-modern-math-apis": "error",
1177
- "unicorn/prefer-negative-index": "error",
1178
- "unicorn/prefer-node-protocol": "error",
1179
- "unicorn/prefer-number-properties": "error",
1180
- "unicorn/prefer-optional-catch-binding": "error",
1181
- "unicorn/prefer-prototype-methods": "error",
1182
- "unicorn/prefer-query-selector": "error",
1183
- "unicorn/prefer-reflect-apply": "error",
1184
- // 'unicorn/prefer-regexp-test': 'error',
1185
- "unicorn/prefer-string-replace-all": "error",
1186
- "unicorn/prefer-string-slice": "error",
1187
- "unicorn/prefer-string-starts-ends-with": "error",
1188
- "unicorn/prefer-string-trim-start-end": "error",
1189
- // top level await is not supported in all environments
1190
- // 'unicorn/prefer-top-level-await': 'error',
1191
- "unicorn/prefer-type-error": "error",
1192
- "unicorn/throw-new-error": "error"
1193
- }
1194
- }
1195
- ];
949
+ // src/env.ts
950
+ var import_node_process2 = __toESM(require("process"), 1);
951
+ var import_local_pkg2 = require("local-pkg");
952
+ var isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.VSCODE_CWD || import_node_process2.default.env.JETBRAINS_IDE || import_node_process2.default.env.VIM || import_node_process2.default.env.NVIM) && !import_node_process2.default.env.CI);
953
+ var hasTypeScript = (0, import_local_pkg2.isPackageExists)("typescript");
954
+ var VueJsPackages = [
955
+ "vue",
956
+ "nuxt",
957
+ "vitepress",
958
+ "@slidev/cli"
959
+ ];
960
+ var hasVue = hasPackages(VueJsPackages);
961
+ var RemixPackages = [
962
+ "@remix-run/node",
963
+ "@remix-run/react",
964
+ "@remix-run/serve",
965
+ "@remix-run/dev"
966
+ ];
967
+ var NextJsPackages = ["next"];
968
+ var isUsingRemix = hasPackages(RemixPackages);
969
+ var isUsingNext = hasPackages(NextJsPackages);
970
+ function hasPackages(packages) {
971
+ return packages.some((name) => (0, import_local_pkg2.isPackageExists)(name));
1196
972
  }
1197
973
 
1198
- // src/configs/vue.ts
1199
- var import_eslint_merge_processors = require("eslint-merge-processors");
1200
- async function vue(options = {}) {
1201
- const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic2 = true } = options;
1202
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1203
- const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1204
- const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1205
- interopDefault(import("eslint-plugin-vue")),
1206
- interopDefault(import("vue-eslint-parser")),
1207
- interopDefault(import("eslint-processor-vue-blocks"))
974
+ // src/configs/react.ts
975
+ var ReactRefreshAllowConstantExportPackages = ["vite"];
976
+ async function react(options = {}) {
977
+ const { files = [GLOB_SRC], overrides = {} } = options;
978
+ await ensurePackages([
979
+ "@eslint-react/eslint-plugin",
980
+ "eslint-plugin-react-hooks",
981
+ "eslint-plugin-react-refresh"
1208
982
  ]);
1209
- const isVue3 = getVueVersion() === 3;
1210
- const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
1211
- const vueRules = configKeys.reduce((preRules, key) => {
1212
- const config = pluginVue.configs[key];
1213
- return {
1214
- ...preRules,
1215
- ...config.rules
1216
- };
1217
- }, {});
983
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
984
+ const isTypeAware = !!tsconfigPath;
985
+ const [pluginReact, pluginReactHooks, pluginReactRefresh, parserTs] = await Promise.all([
986
+ interopDefault(import("@eslint-react/eslint-plugin")),
987
+ interopDefault(import("eslint-plugin-react-hooks")),
988
+ interopDefault(import("eslint-plugin-react-refresh")),
989
+ interopDefault(import("@typescript-eslint/parser"))
990
+ ]);
991
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
992
+ (i) => (0, import_local_pkg3.isPackageExists)(i)
993
+ );
994
+ const plugins = pluginReact.configs.all.plugins;
1218
995
  return [
1219
996
  {
1220
- // This allows Vue plugin to work with auto imports
1221
- // https://github.com/vuejs/eslint-plugin-vue/pull/2422
1222
- languageOptions: {
1223
- globals: {
1224
- computed: "readonly",
1225
- defineEmits: "readonly",
1226
- defineExpose: "readonly",
1227
- defineProps: "readonly",
1228
- onMounted: "readonly",
1229
- onUnmounted: "readonly",
1230
- reactive: "readonly",
1231
- ref: "readonly",
1232
- shallowReactive: "readonly",
1233
- shallowRef: "readonly",
1234
- toRef: "readonly",
1235
- toRefs: "readonly",
1236
- watch: "readonly",
1237
- watchEffect: "readonly"
1238
- }
1239
- },
1240
- name: "coderwyd/vue/setup",
997
+ name: "coderwyd/react/setup",
1241
998
  plugins: {
1242
- vue: pluginVue
999
+ "react": plugins["@eslint-react"],
1000
+ "react-dom": plugins["@eslint-react/dom"],
1001
+ "react-hooks": pluginReactHooks,
1002
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1003
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
1004
+ "react-refresh": pluginReactRefresh
1243
1005
  }
1244
1006
  },
1245
1007
  {
1246
1008
  files,
1247
1009
  languageOptions: {
1248
- parser: parserVue,
1010
+ parser: parserTs,
1249
1011
  parserOptions: {
1250
1012
  ecmaFeatures: {
1251
- jsx: true
1252
- },
1253
- extraFileExtensions: [".vue"],
1254
- parser: options.typescript ? await interopDefault(
1255
- import("@typescript-eslint/parser")
1256
- ) : null,
1257
- sourceType: "module"
1258
- }
1259
- },
1260
- name: "coderwyd/vue/rules",
1261
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors.mergeProcessors)([
1262
- pluginVue.processors[".vue"],
1263
- processorVueBlocks({
1264
- ...sfcBlocks,
1265
- blocks: {
1266
- styles: true,
1267
- ...sfcBlocks.blocks
1268
- }
1269
- })
1270
- ]),
1271
- rules: {
1272
- ...pluginVue.configs.base.rules,
1273
- ...vueRules,
1274
- "node/prefer-global/process": "off",
1275
- "vue/block-order": [
1276
- "error",
1277
- {
1278
- order: isVue3 ? ["script", "template", "style"] : ["template", "script", "style"]
1279
- }
1280
- ],
1281
- // 'vue/component-api-style': ['warn', ['script-setup', 'composition']],
1282
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
1283
- "vue/component-options-name-casing": ["error", "PascalCase"],
1284
- // this is deprecated
1285
- "vue/component-tags-order": "off",
1286
- "vue/custom-event-name-casing": ["error", "camelCase"],
1287
- // 'vue/define-emits-declaration': ['warn', 'type-based'],
1288
- "vue/define-macros-order": [
1289
- "error",
1290
- {
1291
- order: [
1292
- "defineOptions",
1293
- "defineProps",
1294
- "defineEmits",
1295
- "defineSlots"
1296
- ]
1297
- }
1298
- ],
1299
- // 'vue/define-props-declaration': ['warn', 'type-based'],
1300
- "vue/dot-location": ["error", "property"],
1301
- "vue/dot-notation": ["error", { allowKeywords: true }],
1302
- "vue/eqeqeq": ["error", "smart"],
1303
- "vue/html-indent": ["error", indent],
1304
- "vue/html-quotes": ["error", "double"],
1305
- "vue/html-self-closing": [
1306
- "error",
1307
- {
1308
- html: {
1309
- component: "always",
1310
- normal: "always",
1311
- void: "any"
1312
- },
1313
- math: "always",
1314
- svg: "always"
1315
- }
1316
- ],
1317
- "vue/max-attributes-per-line": "off",
1318
- "vue/multi-word-component-names": "off",
1319
- // 'vue/next-tick-style': ['warn', 'promise'],
1320
- "vue/no-constant-condition": "warn",
1321
- "vue/no-dupe-keys": "off",
1322
- "vue/no-duplicate-attr-inheritance": "warn",
1323
- "vue/no-empty-pattern": "error",
1324
- "vue/no-extra-parens": ["error", "functions"],
1325
- "vue/no-irregular-whitespace": "error",
1326
- "vue/no-loss-of-precision": "error",
1327
- "vue/no-required-prop-with-default": "warn",
1328
- "vue/no-restricted-syntax": [
1329
- "error",
1330
- "DebuggerStatement",
1331
- "LabeledStatement",
1332
- "WithStatement"
1333
- ],
1334
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
1335
- "vue/no-setup-props-reactivity-loss": "off",
1336
- "vue/no-sparse-arrays": "error",
1337
- "vue/no-unsupported-features": "warn",
1338
- "vue/no-unused-emit-declarations": "warn",
1339
- "vue/no-unused-refs": "error",
1340
- "vue/no-use-v-else-with-v-for": "error",
1341
- "vue/no-useless-mustaches": "warn",
1342
- "vue/no-useless-v-bind": "error",
1343
- "vue/no-v-html": "off",
1344
- "vue/no-v-text": "warn",
1345
- "vue/object-shorthand": [
1346
- "error",
1347
- "always",
1348
- {
1349
- avoidQuotes: true,
1350
- ignoreConstructors: false
1351
- }
1352
- ],
1353
- "vue/prefer-define-options": "warn",
1354
- "vue/prefer-separate-static-class": "error",
1355
- "vue/prefer-template": "error",
1356
- "vue/prop-name-casing": ["error", "camelCase"],
1357
- "vue/require-default-prop": "off",
1358
- "vue/require-macro-variable-name": [
1359
- "warn",
1360
- {
1361
- defineEmits: "emit",
1362
- defineProps: "props",
1363
- defineSlots: "slots",
1364
- useAttrs: "attrs",
1365
- useSlots: "slots"
1366
- }
1367
- ],
1368
- "vue/require-prop-types": "off",
1369
- // 'vue/singleline-html-element-content-newline': 'off',
1370
- "vue/space-infix-ops": "error",
1371
- "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1372
- "vue/valid-define-options": "warn",
1373
- ...stylistic2 ? {
1374
- "vue/array-bracket-spacing": ["error", "never"],
1375
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1376
- "vue/block-spacing": ["error", "always"],
1377
- "vue/block-tag-newline": [
1378
- "error",
1379
- {
1380
- multiline: "always",
1381
- singleline: "always"
1382
- }
1383
- ],
1384
- "vue/brace-style": [
1385
- "error",
1386
- "stroustrup",
1387
- { allowSingleLine: true }
1388
- ],
1389
- "vue/comma-dangle": ["error", "always-multiline"],
1390
- "vue/comma-spacing": ["error", { after: true, before: false }],
1391
- "vue/comma-style": ["error", "last"],
1392
- "vue/html-comment-content-newline": "warn",
1393
- "vue/html-comment-content-spacing": [
1394
- "error",
1395
- "always",
1396
- {
1397
- exceptions: ["-"]
1398
- }
1399
- ],
1400
- "vue/key-spacing": [
1401
- "error",
1402
- { afterColon: true, beforeColon: false }
1403
- ],
1404
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1405
- "vue/object-curly-newline": "off",
1406
- "vue/object-curly-spacing": ["error", "always"],
1407
- "vue/object-property-newline": [
1408
- "error",
1409
- { allowMultiplePropertiesPerLine: true }
1410
- ],
1411
- "vue/operator-linebreak": ["error", "before"],
1412
- "vue/padding-line-between-blocks": ["error", "always"],
1413
- "vue/quote-props": ["error", "consistent-as-needed"],
1414
- "vue/space-in-parens": ["error", "never"],
1415
- "vue/template-curly-spacing": "error"
1013
+ jsx: true
1014
+ },
1015
+ ...isTypeAware ? { project: tsconfigPath } : {}
1016
+ },
1017
+ sourceType: "module"
1018
+ },
1019
+ name: "coderwyd/react/rules",
1020
+ rules: {
1021
+ // recommended rules from @eslint-react/dom
1022
+ "react-dom/no-children-in-void-dom-elements": "warn",
1023
+ "react-dom/no-dangerously-set-innerhtml": "warn",
1024
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1025
+ "react-dom/no-find-dom-node": "error",
1026
+ "react-dom/no-missing-button-type": "warn",
1027
+ "react-dom/no-missing-iframe-sandbox": "warn",
1028
+ "react-dom/no-namespace": "error",
1029
+ "react-dom/no-render-return-value": "error",
1030
+ "react-dom/no-script-url": "warn",
1031
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
1032
+ "react-dom/no-unsafe-target-blank": "warn",
1033
+ // recommended rules react-hooks
1034
+ "react-hooks/exhaustive-deps": "warn",
1035
+ "react-hooks/rules-of-hooks": "error",
1036
+ // react refresh
1037
+ "react-refresh/only-export-components": [
1038
+ "warn",
1039
+ {
1040
+ allowConstantExport: isAllowConstantExport,
1041
+ allowExportNames: [
1042
+ ...isUsingNext ? [
1043
+ "config",
1044
+ "generateStaticParams",
1045
+ "metadata",
1046
+ "generateMetadata",
1047
+ "viewport",
1048
+ "generateViewport"
1049
+ ] : [],
1050
+ ...isUsingRemix ? ["meta", "links", "headers", "loader", "action"] : []
1051
+ ]
1052
+ }
1053
+ ],
1054
+ // recommended rules from @eslint-react
1055
+ "react/ensure-forward-ref-using-ref": "warn",
1056
+ "react/no-access-state-in-setstate": "error",
1057
+ "react/no-array-index-key": "warn",
1058
+ "react/no-children-count": "warn",
1059
+ "react/no-children-for-each": "warn",
1060
+ "react/no-children-map": "warn",
1061
+ "react/no-children-only": "warn",
1062
+ "react/no-children-prop": "warn",
1063
+ "react/no-children-to-array": "warn",
1064
+ "react/no-clone-element": "warn",
1065
+ "react/no-comment-textnodes": "warn",
1066
+ "react/no-component-will-mount": "error",
1067
+ "react/no-component-will-receive-props": "error",
1068
+ "react/no-component-will-update": "error",
1069
+ "react/no-create-ref": "error",
1070
+ "react/no-direct-mutation-state": "error",
1071
+ "react/no-duplicate-key": "error",
1072
+ "react/no-implicit-key": "error",
1073
+ "react/no-missing-key": "error",
1074
+ "react/no-nested-components": "warn",
1075
+ "react/no-redundant-should-component-update": "error",
1076
+ "react/no-set-state-in-component-did-mount": "warn",
1077
+ "react/no-set-state-in-component-did-update": "warn",
1078
+ "react/no-set-state-in-component-will-update": "warn",
1079
+ "react/no-string-refs": "error",
1080
+ "react/no-unsafe-component-will-mount": "warn",
1081
+ "react/no-unsafe-component-will-receive-props": "warn",
1082
+ "react/no-unsafe-component-will-update": "warn",
1083
+ "react/no-unstable-context-value": "error",
1084
+ "react/no-unstable-default-props": "error",
1085
+ "react/no-unused-class-component-members": "warn",
1086
+ "react/no-unused-state": "warn",
1087
+ "react/no-useless-fragment": "warn",
1088
+ "react/prefer-destructuring-assignment": "warn",
1089
+ "react/prefer-shorthand-boolean": "warn",
1090
+ "react/prefer-shorthand-fragment": "warn",
1091
+ ...isTypeAware ? {
1092
+ "react/no-leaked-conditional-rendering": "warn"
1416
1093
  } : {},
1094
+ // overrides
1417
1095
  ...overrides
1418
1096
  }
1419
1097
  }
1420
1098
  ];
1421
1099
  }
1422
1100
 
1423
- // src/configs/test.ts
1424
- var _pluginTest;
1425
- async function test(options = {}) {
1426
- const { files = GLOB_TESTS, isInEditor: isInEditor2 = false, overrides = {} } = options;
1427
- const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
1428
- interopDefault(import("@vitest/eslint-plugin")),
1429
- // @ts-expect-error missing types
1430
- interopDefault(import("eslint-plugin-no-only-tests"))
1431
- ]);
1432
- _pluginTest = _pluginTest || {
1433
- ...pluginVitest,
1434
- rules: {
1435
- ...pluginVitest.rules,
1436
- // extend `test/no-only-tests` rule
1437
- ...pluginNoOnlyTests.rules
1438
- }
1101
+ // src/configs/regexp.ts
1102
+ var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
1103
+ function regexp(options = {}) {
1104
+ const config = import_eslint_plugin_regexp.configs["flat/recommended"];
1105
+ const rules = {
1106
+ ...config.rules
1439
1107
  };
1108
+ if (options.level === "warn") {
1109
+ Object.keys(rules).forEach((key) => {
1110
+ if (rules[key] === "error")
1111
+ rules[key] = "warn";
1112
+ });
1113
+ }
1440
1114
  return [
1441
1115
  {
1442
- name: "coderwyd/test/setup",
1443
- plugins: {
1444
- test: _pluginTest
1116
+ ...config,
1117
+ name: "coderwyd/regexp/rules",
1118
+ rules: {
1119
+ ...rules,
1120
+ ...options.overrides
1445
1121
  }
1446
- },
1122
+ }
1123
+ ];
1124
+ }
1125
+
1126
+ // src/configs/sort.ts
1127
+ function sortPackageJson() {
1128
+ return [
1447
1129
  {
1448
- files,
1449
- name: "coderwyd/test/rules",
1130
+ files: ["**/package.json"],
1131
+ name: "coderwyd/sort/package-json",
1450
1132
  rules: {
1451
- "node/prefer-global/process": "off",
1452
- "test/consistent-test-it": [
1133
+ "jsonc/sort-array-values": [
1453
1134
  "error",
1454
- { fn: "it", withinDescribe: "it" }
1135
+ {
1136
+ order: { type: "asc" },
1137
+ pathPattern: "^files$"
1138
+ }
1455
1139
  ],
1456
- "test/no-identical-title": "error",
1457
- "test/no-import-node-test": "error",
1458
- "test/no-only-tests": isInEditor2 ? "off" : "error",
1459
- "test/prefer-hooks-in-order": "error",
1460
- "test/prefer-lowercase-title": "error",
1461
- "ts/explicit-function-return-type": "off",
1462
- ...overrides
1140
+ "jsonc/sort-keys": [
1141
+ "error",
1142
+ {
1143
+ order: [
1144
+ "publisher",
1145
+ "name",
1146
+ "displayName",
1147
+ "type",
1148
+ "version",
1149
+ "private",
1150
+ "packageManager",
1151
+ "description",
1152
+ "author",
1153
+ "license",
1154
+ "funding",
1155
+ "homepage",
1156
+ "repository",
1157
+ "bugs",
1158
+ "keywords",
1159
+ "categories",
1160
+ "sideEffects",
1161
+ "exports",
1162
+ "main",
1163
+ "module",
1164
+ "unpkg",
1165
+ "jsdelivr",
1166
+ "types",
1167
+ "typesVersions",
1168
+ "bin",
1169
+ "icon",
1170
+ "files",
1171
+ "engines",
1172
+ "activationEvents",
1173
+ "contributes",
1174
+ "scripts",
1175
+ "peerDependencies",
1176
+ "peerDependenciesMeta",
1177
+ "dependencies",
1178
+ "optionalDependencies",
1179
+ "devDependencies",
1180
+ "pnpm",
1181
+ "overrides",
1182
+ "resolutions",
1183
+ "husky",
1184
+ "simple-git-hooks",
1185
+ "lint-staged",
1186
+ "eslintConfig"
1187
+ ],
1188
+ pathPattern: "^$"
1189
+ },
1190
+ {
1191
+ order: { type: "asc" },
1192
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1193
+ },
1194
+ {
1195
+ order: { type: "asc" },
1196
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1197
+ },
1198
+ {
1199
+ order: ["types", "import", "require", "default"],
1200
+ pathPattern: "^exports.*$"
1201
+ },
1202
+ {
1203
+ order: [
1204
+ // client hooks only
1205
+ "pre-commit",
1206
+ "prepare-commit-msg",
1207
+ "commit-msg",
1208
+ "post-commit",
1209
+ "pre-rebase",
1210
+ "post-rewrite",
1211
+ "post-checkout",
1212
+ "post-merge",
1213
+ "pre-push",
1214
+ "pre-auto-gc"
1215
+ ],
1216
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1217
+ }
1218
+ ]
1463
1219
  }
1464
1220
  }
1465
1221
  ];
1466
1222
  }
1467
-
1468
- // src/configs/perfectionist.ts
1469
- function perfectionist() {
1223
+ function sortTsconfig() {
1470
1224
  return [
1471
1225
  {
1472
- name: "coderwyd/perfectionist/rules",
1473
- plugins: {
1474
- perfectionist: import_eslint_plugin_perfectionist.default
1475
- },
1226
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1227
+ name: "coderwyd/sort/tsconfig-json",
1476
1228
  rules: {
1477
- "perfectionist/sort-imports": [
1478
- "warn",
1229
+ "jsonc/sort-keys": [
1230
+ "error",
1479
1231
  {
1480
- groups: [
1481
- "builtin",
1482
- "external",
1483
- "internal",
1484
- "internal-type",
1485
- "parent",
1486
- "parent-type",
1487
- "sibling",
1488
- "sibling-type",
1489
- "index",
1490
- "index-type",
1491
- "object",
1492
- "type",
1493
- "side-effect",
1494
- "side-effect-style"
1232
+ order: [
1233
+ "extends",
1234
+ "compilerOptions",
1235
+ "references",
1236
+ "files",
1237
+ "include",
1238
+ "exclude"
1239
+ ],
1240
+ pathPattern: "^$"
1241
+ },
1242
+ {
1243
+ order: [
1244
+ /* Projects */
1245
+ "incremental",
1246
+ "composite",
1247
+ "tsBuildInfoFile",
1248
+ "disableSourceOfProjectReferenceRedirect",
1249
+ "disableSolutionSearching",
1250
+ "disableReferencedProjectLoad",
1251
+ /* Language and Environment */
1252
+ "target",
1253
+ "jsx",
1254
+ "jsxFactory",
1255
+ "jsxFragmentFactory",
1256
+ "jsxImportSource",
1257
+ "lib",
1258
+ "moduleDetection",
1259
+ "noLib",
1260
+ "reactNamespace",
1261
+ "useDefineForClassFields",
1262
+ "emitDecoratorMetadata",
1263
+ "experimentalDecorators",
1264
+ /* Modules */
1265
+ "baseUrl",
1266
+ "rootDir",
1267
+ "rootDirs",
1268
+ "customConditions",
1269
+ "module",
1270
+ "moduleResolution",
1271
+ "moduleSuffixes",
1272
+ "noResolve",
1273
+ "paths",
1274
+ "resolveJsonModule",
1275
+ "resolvePackageJsonExports",
1276
+ "resolvePackageJsonImports",
1277
+ "typeRoots",
1278
+ "types",
1279
+ "allowArbitraryExtensions",
1280
+ "allowImportingTsExtensions",
1281
+ "allowUmdGlobalAccess",
1282
+ /* JavaScript Support */
1283
+ "allowJs",
1284
+ "checkJs",
1285
+ "maxNodeModuleJsDepth",
1286
+ /* Type Checking */
1287
+ "strict",
1288
+ "strictBindCallApply",
1289
+ "strictFunctionTypes",
1290
+ "strictNullChecks",
1291
+ "strictPropertyInitialization",
1292
+ "allowUnreachableCode",
1293
+ "allowUnusedLabels",
1294
+ "alwaysStrict",
1295
+ "exactOptionalPropertyTypes",
1296
+ "noFallthroughCasesInSwitch",
1297
+ "noImplicitAny",
1298
+ "noImplicitOverride",
1299
+ "noImplicitReturns",
1300
+ "noImplicitThis",
1301
+ "noPropertyAccessFromIndexSignature",
1302
+ "noUncheckedIndexedAccess",
1303
+ "noUnusedLocals",
1304
+ "noUnusedParameters",
1305
+ "useUnknownInCatchVariables",
1306
+ /* Emit */
1307
+ "declaration",
1308
+ "declarationDir",
1309
+ "declarationMap",
1310
+ "downlevelIteration",
1311
+ "emitBOM",
1312
+ "emitDeclarationOnly",
1313
+ "importHelpers",
1314
+ "importsNotUsedAsValues",
1315
+ "inlineSourceMap",
1316
+ "inlineSources",
1317
+ "mapRoot",
1318
+ "newLine",
1319
+ "noEmit",
1320
+ "noEmitHelpers",
1321
+ "noEmitOnError",
1322
+ "outDir",
1323
+ "outFile",
1324
+ "preserveConstEnums",
1325
+ "preserveValueImports",
1326
+ "removeComments",
1327
+ "sourceMap",
1328
+ "sourceRoot",
1329
+ "stripInternal",
1330
+ /* Interop Constraints */
1331
+ "allowSyntheticDefaultImports",
1332
+ "esModuleInterop",
1333
+ "forceConsistentCasingInFileNames",
1334
+ "isolatedDeclarations",
1335
+ "isolatedModules",
1336
+ "preserveSymlinks",
1337
+ "verbatimModuleSyntax",
1338
+ /* Completeness */
1339
+ "skipDefaultLibCheck",
1340
+ "skipLibCheck"
1495
1341
  ],
1496
- internalPattern: ["~/**", "@/**", "#**"],
1497
- newlinesBetween: "ignore"
1342
+ pathPattern: "^compilerOptions$"
1498
1343
  }
1499
- ],
1500
- "perfectionist/sort-named-exports": [
1501
- "warn",
1502
- { groupKind: "values-first" }
1503
- ],
1504
- "perfectionist/sort-named-imports": [
1505
- "warn",
1506
- { groupKind: "values-first" }
1507
1344
  ]
1508
1345
  }
1509
1346
  }
1510
1347
  ];
1511
1348
  }
1512
1349
 
1513
- // src/configs/react.ts
1514
- var import_local_pkg3 = require("local-pkg");
1515
-
1516
- // src/env.ts
1517
- var import_node_process3 = __toESM(require("process"), 1);
1518
- var import_local_pkg2 = require("local-pkg");
1519
- var isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.VSCODE_CWD || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM || import_node_process3.default.env.NVIM) && !import_node_process3.default.env.CI);
1520
- var hasTypeScript = (0, import_local_pkg2.isPackageExists)("typescript");
1521
- var VueJsPackages = [
1522
- "vue",
1523
- "nuxt",
1524
- "vitepress",
1525
- "@slidev/cli"
1526
- ];
1527
- var hasVue = hasPackages(VueJsPackages);
1528
- var RemixPackages = [
1529
- "@remix-run/node",
1530
- "@remix-run/react",
1531
- "@remix-run/serve",
1532
- "@remix-run/dev"
1533
- ];
1534
- var NextJsPackages = ["next"];
1535
- var isUsingRemix = hasPackages(RemixPackages);
1536
- var isUsingNext = hasPackages(NextJsPackages);
1537
- function hasPackages(packages) {
1538
- return packages.some((name) => (0, import_local_pkg2.isPackageExists)(name));
1539
- }
1540
-
1541
- // src/configs/react.ts
1542
- var ReactRefreshAllowConstantExportPackages = ["vite"];
1543
- async function react(options = {}) {
1544
- const { files = [GLOB_SRC], overrides = {} } = options;
1545
- await ensurePackages([
1546
- "@eslint-react/eslint-plugin",
1547
- "eslint-plugin-react-hooks",
1548
- "eslint-plugin-react-refresh"
1549
- ]);
1550
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1551
- const isTypeAware = !!tsconfigPath;
1552
- const [pluginReact, pluginReactHooks, pluginReactRefresh, parserTs] = await Promise.all([
1553
- interopDefault(import("@eslint-react/eslint-plugin")),
1554
- interopDefault(import("eslint-plugin-react-hooks")),
1555
- interopDefault(import("eslint-plugin-react-refresh")),
1556
- interopDefault(import("@typescript-eslint/parser"))
1350
+ // src/configs/svelte.ts
1351
+ async function svelte(options = {}) {
1352
+ const { files = [GLOB_SVELTE], overrides = {}, stylistic: stylistic2 = true } = options;
1353
+ const {
1354
+ indent = 2,
1355
+ quotes = "single"
1356
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1357
+ await ensurePackages(["eslint-plugin-svelte"]);
1358
+ const [pluginSvelte, parserSvelte] = await Promise.all([
1359
+ interopDefault(import("eslint-plugin-svelte")),
1360
+ interopDefault(import("svelte-eslint-parser"))
1557
1361
  ]);
1558
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1559
- (i) => (0, import_local_pkg3.isPackageExists)(i)
1560
- );
1561
- const plugins = pluginReact.configs.all.plugins;
1562
1362
  return [
1563
1363
  {
1564
- name: "coderwyd/react/setup",
1364
+ name: "coderwyd/svelte/setup",
1565
1365
  plugins: {
1566
- "react": plugins["@eslint-react"],
1567
- "react-dom": plugins["@eslint-react/dom"],
1568
- "react-hooks": pluginReactHooks,
1569
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1570
- "react-naming-convention": plugins["@eslint-react/naming-convention"],
1571
- "react-refresh": pluginReactRefresh
1366
+ svelte: pluginSvelte
1572
1367
  }
1573
1368
  },
1574
1369
  {
1575
1370
  files,
1576
1371
  languageOptions: {
1577
- parser: parserTs,
1372
+ parser: parserSvelte,
1578
1373
  parserOptions: {
1579
- ecmaFeatures: {
1580
- jsx: true
1581
- },
1582
- ...isTypeAware ? { project: tsconfigPath } : {}
1583
- },
1584
- sourceType: "module"
1374
+ extraFileExtensions: [".svelte"],
1375
+ parser: options.typescript ? await interopDefault(
1376
+ import("@typescript-eslint/parser")
1377
+ ) : null
1378
+ }
1585
1379
  },
1586
- name: "coderwyd/react/rules",
1380
+ name: "coderwyd/svelte/rules",
1381
+ processor: pluginSvelte.processors[".svelte"],
1587
1382
  rules: {
1588
- // recommended rules from @eslint-react/dom
1589
- "react-dom/no-children-in-void-dom-elements": "warn",
1590
- "react-dom/no-dangerously-set-innerhtml": "warn",
1591
- "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1592
- "react-dom/no-find-dom-node": "error",
1593
- "react-dom/no-missing-button-type": "warn",
1594
- "react-dom/no-missing-iframe-sandbox": "warn",
1595
- "react-dom/no-namespace": "error",
1596
- "react-dom/no-render-return-value": "error",
1597
- "react-dom/no-script-url": "warn",
1598
- "react-dom/no-unsafe-iframe-sandbox": "warn",
1599
- "react-dom/no-unsafe-target-blank": "warn",
1600
- // recommended rules react-hooks
1601
- "react-hooks/exhaustive-deps": "warn",
1602
- "react-hooks/rules-of-hooks": "error",
1603
- // react refresh
1604
- "react-refresh/only-export-components": [
1605
- "warn",
1383
+ "import/no-mutable-exports": "off",
1384
+ "no-undef": "off",
1385
+ // incompatible with most recent (attribute-form) generic types RFC
1386
+ "no-unused-vars": [
1387
+ "error",
1606
1388
  {
1607
- allowConstantExport: isAllowConstantExport,
1608
- allowExportNames: [
1609
- ...isUsingNext ? [
1610
- "config",
1611
- "generateStaticParams",
1612
- "metadata",
1613
- "generateMetadata",
1614
- "viewport",
1615
- "generateViewport"
1616
- ] : [],
1617
- ...isUsingRemix ? ["meta", "links", "headers", "loader", "action"] : []
1618
- ]
1389
+ args: "none",
1390
+ caughtErrors: "none",
1391
+ ignoreRestSiblings: true,
1392
+ vars: "all",
1393
+ varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1394
+ }
1395
+ ],
1396
+ "svelte/comment-directive": "error",
1397
+ "svelte/no-at-debug-tags": "warn",
1398
+ "svelte/no-at-html-tags": "error",
1399
+ "svelte/no-dupe-else-if-blocks": "error",
1400
+ "svelte/no-dupe-style-properties": "error",
1401
+ "svelte/no-dupe-use-directives": "error",
1402
+ "svelte/no-dynamic-slot-name": "error",
1403
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1404
+ "svelte/no-inner-declarations": "error",
1405
+ "svelte/no-not-function-handler": "error",
1406
+ "svelte/no-object-in-text-mustaches": "error",
1407
+ "svelte/no-reactive-functions": "error",
1408
+ "svelte/no-reactive-literals": "error",
1409
+ "svelte/no-shorthand-style-property-overrides": "error",
1410
+ "svelte/no-unknown-style-directive-property": "error",
1411
+ "svelte/no-unused-svelte-ignore": "error",
1412
+ "svelte/no-useless-mustaches": "error",
1413
+ "svelte/require-store-callbacks-use-set-param": "error",
1414
+ "svelte/system": "error",
1415
+ "svelte/valid-each-key": "error",
1416
+ "unused-imports/no-unused-vars": [
1417
+ "error",
1418
+ {
1419
+ args: "after-used",
1420
+ argsIgnorePattern: "^_",
1421
+ vars: "all",
1422
+ varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1619
1423
  }
1620
1424
  ],
1621
- // recommended rules from @eslint-react
1622
- "react/ensure-forward-ref-using-ref": "warn",
1623
- "react/no-access-state-in-setstate": "error",
1624
- "react/no-array-index-key": "warn",
1625
- "react/no-children-count": "warn",
1626
- "react/no-children-for-each": "warn",
1627
- "react/no-children-map": "warn",
1628
- "react/no-children-only": "warn",
1629
- "react/no-children-prop": "warn",
1630
- "react/no-children-to-array": "warn",
1631
- "react/no-clone-element": "warn",
1632
- "react/no-comment-textnodes": "warn",
1633
- "react/no-component-will-mount": "error",
1634
- "react/no-component-will-receive-props": "error",
1635
- "react/no-component-will-update": "error",
1636
- "react/no-create-ref": "error",
1637
- "react/no-direct-mutation-state": "error",
1638
- "react/no-duplicate-key": "error",
1639
- "react/no-implicit-key": "error",
1640
- "react/no-missing-key": "error",
1641
- "react/no-nested-components": "warn",
1642
- "react/no-redundant-should-component-update": "error",
1643
- "react/no-set-state-in-component-did-mount": "warn",
1644
- "react/no-set-state-in-component-did-update": "warn",
1645
- "react/no-set-state-in-component-will-update": "warn",
1646
- "react/no-string-refs": "error",
1647
- "react/no-unsafe-component-will-mount": "warn",
1648
- "react/no-unsafe-component-will-receive-props": "warn",
1649
- "react/no-unsafe-component-will-update": "warn",
1650
- "react/no-unstable-context-value": "error",
1651
- "react/no-unstable-default-props": "error",
1652
- "react/no-unused-class-component-members": "warn",
1653
- "react/no-unused-state": "warn",
1654
- "react/no-useless-fragment": "warn",
1655
- "react/prefer-destructuring-assignment": "warn",
1656
- "react/prefer-shorthand-boolean": "warn",
1657
- "react/prefer-shorthand-fragment": "warn",
1658
- ...isTypeAware ? {
1659
- "react/no-leaked-conditional-rendering": "warn"
1425
+ ...stylistic2 ? {
1426
+ "style/indent": "off",
1427
+ // superseded by svelte/indent
1428
+ "style/no-trailing-spaces": "off",
1429
+ // superseded by svelte/no-trailing-spaces
1430
+ "svelte/derived-has-same-inputs-outputs": "error",
1431
+ "svelte/html-closing-bracket-spacing": "error",
1432
+ "svelte/html-quotes": ["error", { prefer: quotes }],
1433
+ "svelte/indent": [
1434
+ "error",
1435
+ { alignAttributesVertically: true, indent }
1436
+ ],
1437
+ "svelte/mustache-spacing": "error",
1438
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1439
+ "svelte/no-trailing-spaces": "error",
1440
+ "svelte/spaced-html-comment": "error"
1660
1441
  } : {},
1661
- // overrides
1662
1442
  ...overrides
1663
1443
  }
1664
1444
  }
1665
1445
  ];
1666
1446
  }
1667
1447
 
1668
- // src/configs/unocss.ts
1669
- async function unocss(options = {}) {
1670
- const { attributify = true, strict = false } = options;
1671
- await ensurePackages(["@unocss/eslint-plugin"]);
1672
- const [pluginUnoCSS] = await Promise.all([
1673
- interopDefault(import("@unocss/eslint-plugin"))
1674
- ]);
1448
+ // src/configs/tailwindcss.ts
1449
+ async function tailwindcss(options = {}) {
1450
+ const { overrides } = options;
1451
+ await ensurePackages(["eslint-plugin-tailwindcss"]);
1452
+ const pluginTailwindcss = await interopDefault(
1453
+ import("eslint-plugin-tailwindcss")
1454
+ );
1675
1455
  return [
1676
1456
  {
1677
- name: "coderwyd/unocss/rules",
1457
+ name: "coderwyd/tailwindcss/rules",
1678
1458
  plugins: {
1679
- unocss: pluginUnoCSS
1459
+ tailwindcss: pluginTailwindcss
1680
1460
  },
1681
1461
  rules: {
1682
- "unocss/order": "warn",
1683
- ...attributify ? {
1684
- "unocss/order-attributify": "warn"
1685
- } : {},
1686
- ...strict ? {
1687
- "unocss/blocklist": "error"
1688
- } : {}
1462
+ "tailwindcss/classnames-order": "warn",
1463
+ "tailwindcss/enforces-negative-arbitrary-values": "warn",
1464
+ "tailwindcss/enforces-shorthand": "warn",
1465
+ "tailwindcss/migration-from-tailwind-2": "warn",
1466
+ "tailwindcss/no-arbitrary-value": "off",
1467
+ "tailwindcss/no-contradicting-classname": "warn",
1468
+ "tailwindcss/no-custom-classname": "off",
1469
+ "tailwindcss/no-unnecessary-arbitrary-value": "warn",
1470
+ ...overrides
1689
1471
  }
1690
1472
  }
1691
1473
  ];
1692
1474
  }
1693
1475
 
1694
- // src/configs/formatter.ts
1695
- async function formatter(options = {}, stylistic2 = {}) {
1696
- const { css, graphql, html, markdown, toml, yaml } = options === true ? {
1697
- css: true,
1698
- graphql: true,
1699
- html: true,
1700
- markdown: true,
1701
- toml: true,
1702
- yaml: true
1703
- } : options;
1704
- const { indent, quotes, semi } = {
1705
- ...StylisticConfigDefaults,
1706
- ...stylistic2
1476
+ // src/configs/test.ts
1477
+ var _pluginTest;
1478
+ async function test(options = {}) {
1479
+ const { files = GLOB_TESTS, isInEditor: isInEditor2 = false, overrides = {} } = options;
1480
+ const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
1481
+ interopDefault(import("@vitest/eslint-plugin")),
1482
+ // @ts-expect-error missing types
1483
+ interopDefault(import("eslint-plugin-no-only-tests"))
1484
+ ]);
1485
+ _pluginTest = _pluginTest || {
1486
+ ...pluginVitest,
1487
+ rules: {
1488
+ ...pluginVitest.rules,
1489
+ // extend `test/no-only-tests` rule
1490
+ ...pluginNoOnlyTests.rules
1491
+ }
1707
1492
  };
1708
- const prettierOptions = Object.assign(
1493
+ return [
1709
1494
  {
1710
- endOfLine: "auto",
1711
- printWidth: 80,
1712
- semi,
1713
- singleQuote: quotes === "single",
1714
- tabWidth: typeof indent === "number" ? indent : 2,
1715
- trailingComma: "all",
1716
- useTabs: indent === "tab"
1717
- },
1718
- typeof options === "boolean" ? {} : options.prettierOptions || {}
1719
- );
1720
- await ensurePackages(["eslint-plugin-format"]);
1721
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
1722
- function createPrettierFormatter(files, parser, plugins) {
1723
- const rules = {
1724
- ...prettierOptions,
1725
- parser
1726
- };
1727
- const markdownRules = {
1728
- printWidth: 120,
1729
- ...rules,
1730
- embeddedLanguageFormatting: "off"
1731
- };
1732
- if (plugins?.length)
1733
- rules.plugins = [...rules.plugins || [], ...plugins];
1734
- const config = {
1735
- files,
1736
- languageOptions: {
1737
- parser: parserPlain
1738
- },
1739
- name: `coderwyd/formatter/${parser}`,
1495
+ name: "coderwyd/test/setup",
1740
1496
  plugins: {
1741
- format: pluginFormat
1742
- },
1743
- rules: {
1744
- "format/prettier": [
1745
- "warn",
1746
- parser === "markdown" ? markdownRules : rules
1747
- ]
1497
+ test: _pluginTest
1748
1498
  }
1749
- };
1750
- return config;
1751
- }
1752
- const configs2 = [
1499
+ },
1753
1500
  {
1754
- name: "coderwyd/formatter/setup",
1755
- plugins: {
1756
- format: pluginFormat
1501
+ files,
1502
+ name: "coderwyd/test/rules",
1503
+ rules: {
1504
+ "node/prefer-global/process": "off",
1505
+ "test/consistent-test-it": [
1506
+ "error",
1507
+ { fn: "it", withinDescribe: "it" }
1508
+ ],
1509
+ "test/no-identical-title": "error",
1510
+ "test/no-import-node-test": "error",
1511
+ "test/no-only-tests": isInEditor2 ? "off" : "error",
1512
+ "test/prefer-hooks-in-order": "error",
1513
+ "test/prefer-lowercase-title": "error",
1514
+ "ts/explicit-function-return-type": "off",
1515
+ "unicorn/consistent-function-scoping": "off",
1516
+ ...overrides
1757
1517
  }
1758
1518
  }
1759
1519
  ];
1760
- if (html) {
1761
- const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1762
- configs2.push(htmlConfig);
1763
- }
1764
- if (css) {
1765
- const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
1766
- const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
1767
- const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
1768
- configs2.push(cssConfig, scssConfig, lessConfig);
1769
- }
1770
- if (markdown) {
1771
- const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
1772
- configs2.push(markdownConfig);
1773
- }
1774
- if (graphql) {
1775
- const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
1776
- configs2.push(graphqlConfig);
1777
- }
1778
- if (yaml) {
1779
- const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
1780
- configs2.push(yamlConfig);
1781
- }
1782
- if (toml) {
1783
- await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1784
- const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1785
- "prettier-plugin-toml"
1786
- ]);
1787
- configs2.push(tomlConfig);
1788
- }
1789
- return configs2;
1790
1520
  }
1791
1521
 
1792
- // src/configs/svelte.ts
1793
- async function svelte(options = {}) {
1794
- const { files = [GLOB_SVELTE], overrides = {}, stylistic: stylistic2 = true } = options;
1795
- const {
1796
- indent = 2,
1797
- quotes = "single"
1798
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1799
- await ensurePackages(["eslint-plugin-svelte"]);
1800
- const [pluginSvelte, parserSvelte] = await Promise.all([
1801
- interopDefault(import("eslint-plugin-svelte")),
1802
- interopDefault(import("svelte-eslint-parser"))
1522
+ // src/configs/typescript.ts
1523
+ var import_node_process3 = __toESM(require("process"), 1);
1524
+ async function typescript(options = {}) {
1525
+ const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {} } = options;
1526
+ const files = options.files ?? [
1527
+ GLOB_TS,
1528
+ GLOB_TSX,
1529
+ ...componentExts.map((ext) => `**/*.${ext}`)
1530
+ ];
1531
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1532
+ const ignoresTypeAware = options.ignoresTypeAware ?? [
1533
+ `${GLOB_MARKDOWN}/**`,
1534
+ GLOB_ASTRO_TS
1535
+ ];
1536
+ const tsconfigPath = options.tsconfigPath;
1537
+ const isTypeAware = !!tsconfigPath;
1538
+ const typeAwareRules = {
1539
+ "dot-notation": "off",
1540
+ "no-implied-eval": "off",
1541
+ "ts/await-thenable": "error",
1542
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1543
+ "ts/no-floating-promises": "error",
1544
+ "ts/no-for-in-array": "error",
1545
+ "ts/no-implied-eval": "error",
1546
+ "ts/no-misused-promises": "error",
1547
+ "ts/no-unnecessary-type-assertion": "error",
1548
+ "ts/no-unsafe-argument": "error",
1549
+ "ts/no-unsafe-assignment": "error",
1550
+ "ts/no-unsafe-call": "error",
1551
+ "ts/no-unsafe-member-access": "error",
1552
+ "ts/no-unsafe-return": "error",
1553
+ "ts/promise-function-async": "error",
1554
+ "ts/restrict-plus-operands": "error",
1555
+ "ts/restrict-template-expressions": "error",
1556
+ "ts/return-await": "error",
1557
+ "ts/strict-boolean-expressions": "error",
1558
+ "ts/switch-exhaustiveness-check": "error",
1559
+ "ts/unbound-method": "error"
1560
+ };
1561
+ const [pluginTs, parserTs] = await Promise.all([
1562
+ interopDefault(import("@typescript-eslint/eslint-plugin")),
1563
+ interopDefault(import("@typescript-eslint/parser"))
1803
1564
  ]);
1565
+ function makeParser(typeAware, files2, ignores2) {
1566
+ return {
1567
+ files: files2,
1568
+ ...ignores2 ? { ignores: ignores2 } : {},
1569
+ languageOptions: {
1570
+ parser: parserTs,
1571
+ parserOptions: {
1572
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1573
+ sourceType: "module",
1574
+ ...typeAware ? {
1575
+ projectService: {
1576
+ allowDefaultProject: ["./*.js"],
1577
+ defaultProject: tsconfigPath
1578
+ },
1579
+ tsconfigRootDir: import_node_process3.default.cwd()
1580
+ } : {},
1581
+ ...parserOptions
1582
+ }
1583
+ },
1584
+ name: `coderwyd/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1585
+ };
1586
+ }
1804
1587
  return [
1805
1588
  {
1806
- name: "coderwyd/svelte/setup",
1589
+ // Install the plugins without globs, so they can be configured separately.
1590
+ name: "coderwyd/typescript/setup",
1807
1591
  plugins: {
1808
- svelte: pluginSvelte
1592
+ antfu: import_eslint_plugin_antfu.default,
1593
+ ts: pluginTs
1809
1594
  }
1810
1595
  },
1596
+ // assign type-aware parser for type-aware files and type-unaware parser for the rest
1597
+ ...isTypeAware ? [
1598
+ makeParser(false, files),
1599
+ makeParser(true, filesTypeAware, ignoresTypeAware)
1600
+ ] : [makeParser(false, files)],
1811
1601
  {
1812
1602
  files,
1813
- languageOptions: {
1814
- parser: parserSvelte,
1815
- parserOptions: {
1816
- extraFileExtensions: [".svelte"],
1817
- parser: options.typescript ? await interopDefault(
1818
- import("@typescript-eslint/parser")
1819
- ) : null
1820
- }
1821
- },
1822
- name: "coderwyd/svelte/rules",
1823
- processor: pluginSvelte.processors[".svelte"],
1603
+ name: "coderwyd/typescript/rules",
1824
1604
  rules: {
1825
- "import/no-mutable-exports": "off",
1826
- "no-undef": "off",
1827
- // incompatible with most recent (attribute-form) generic types RFC
1828
- "no-unused-vars": [
1605
+ ...renameRules(
1606
+ pluginTs.configs["eslint-recommended"].overrides[0].rules,
1607
+ { "@typescript-eslint": "ts" }
1608
+ ),
1609
+ ...renameRules(pluginTs.configs.strict.rules, {
1610
+ "@typescript-eslint": "ts"
1611
+ }),
1612
+ "no-dupe-class-members": "off",
1613
+ "no-redeclare": "off",
1614
+ "no-use-before-define": "off",
1615
+ "no-useless-constructor": "off",
1616
+ "ts/ban-ts-comment": [
1829
1617
  "error",
1830
- {
1831
- args: "none",
1832
- caughtErrors: "none",
1833
- ignoreRestSiblings: true,
1834
- vars: "all",
1835
- varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1836
- }
1618
+ { "ts-expect-error": "allow-with-description" }
1837
1619
  ],
1838
- "svelte/comment-directive": "error",
1839
- "svelte/no-at-debug-tags": "warn",
1840
- "svelte/no-at-html-tags": "error",
1841
- "svelte/no-dupe-else-if-blocks": "error",
1842
- "svelte/no-dupe-style-properties": "error",
1843
- "svelte/no-dupe-use-directives": "error",
1844
- "svelte/no-dynamic-slot-name": "error",
1845
- "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1846
- "svelte/no-inner-declarations": "error",
1847
- "svelte/no-not-function-handler": "error",
1848
- "svelte/no-object-in-text-mustaches": "error",
1849
- "svelte/no-reactive-functions": "error",
1850
- "svelte/no-reactive-literals": "error",
1851
- "svelte/no-shorthand-style-property-overrides": "error",
1852
- "svelte/no-unknown-style-directive-property": "error",
1853
- "svelte/no-unused-svelte-ignore": "error",
1854
- "svelte/no-useless-mustaches": "error",
1855
- "svelte/require-store-callbacks-use-set-param": "error",
1856
- "svelte/system": "error",
1857
- "svelte/valid-each-key": "error",
1858
- "unused-imports/no-unused-vars": [
1620
+ "ts/consistent-type-definitions": ["error", "interface"],
1621
+ "ts/consistent-type-imports": [
1622
+ "error",
1623
+ { disallowTypeAnnotations: false, prefer: "type-imports" }
1624
+ ],
1625
+ "ts/method-signature-style": ["error", "property"],
1626
+ // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
1627
+ "ts/no-dupe-class-members": "error",
1628
+ "ts/no-dynamic-delete": "off",
1629
+ "ts/no-empty-object-type": [
1859
1630
  "error",
1860
1631
  {
1861
- args: "after-used",
1862
- argsIgnorePattern: "^_",
1863
- vars: "all",
1864
- varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1632
+ allowInterfaces: "with-single-extends",
1633
+ // interface Derived extends Base {}
1634
+ allowObjectTypes: "never",
1635
+ allowWithName: "Props$"
1865
1636
  }
1866
1637
  ],
1867
- ...stylistic2 ? {
1868
- "style/indent": "off",
1869
- // superseded by svelte/indent
1870
- "style/no-trailing-spaces": "off",
1871
- // superseded by svelte/no-trailing-spaces
1872
- "svelte/derived-has-same-inputs-outputs": "error",
1873
- "svelte/html-closing-bracket-spacing": "error",
1874
- "svelte/html-quotes": ["error", { prefer: quotes }],
1875
- "svelte/indent": [
1876
- "error",
1877
- { alignAttributesVertically: true, indent }
1878
- ],
1879
- "svelte/mustache-spacing": "error",
1880
- "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1881
- "svelte/no-trailing-spaces": "error",
1882
- "svelte/spaced-html-comment": "error"
1883
- } : {},
1638
+ "ts/no-explicit-any": "off",
1639
+ "ts/no-extraneous-class": "off",
1640
+ "ts/no-import-type-side-effects": "error",
1641
+ "ts/no-invalid-void-type": "off",
1642
+ "ts/no-non-null-assertion": "off",
1643
+ "ts/no-redeclare": "error",
1644
+ "ts/no-require-imports": "error",
1645
+ "ts/no-unused-vars": "off",
1646
+ "ts/no-use-before-define": [
1647
+ "error",
1648
+ { classes: false, functions: false, variables: true }
1649
+ ],
1650
+ "ts/no-useless-constructor": "off",
1651
+ "ts/no-wrapper-object-types": "error",
1652
+ "ts/triple-slash-reference": "off",
1653
+ "ts/unified-signatures": "off",
1884
1654
  ...overrides
1885
1655
  }
1886
- }
1656
+ },
1657
+ ...isTypeAware ? [
1658
+ {
1659
+ files: filesTypeAware,
1660
+ ignores: ignoresTypeAware,
1661
+ name: "coderwyd/typescript/rules-type-aware",
1662
+ rules: {
1663
+ ...typeAwareRules,
1664
+ ...overridesTypeAware
1665
+ }
1666
+ }
1667
+ ] : []
1887
1668
  ];
1888
1669
  }
1889
1670
 
1890
- // src/configs/tailwindcss.ts
1891
- async function tailwindcss(options = {}) {
1892
- const { overrides } = options;
1893
- await ensurePackages(["eslint-plugin-tailwindcss"]);
1894
- const pluginTailwindcss = await interopDefault(
1895
- import("eslint-plugin-tailwindcss")
1896
- );
1671
+ // src/configs/unicorn.ts
1672
+ function unicorn() {
1897
1673
  return [
1898
1674
  {
1899
- name: "coderwyd/tailwindcss/rules",
1675
+ name: "coderwyd/unicorn/rules",
1900
1676
  plugins: {
1901
- tailwindcss: pluginTailwindcss
1677
+ unicorn: import_eslint_plugin_unicorn.default
1902
1678
  },
1903
1679
  rules: {
1904
- "tailwindcss/classnames-order": "warn",
1905
- "tailwindcss/enforces-negative-arbitrary-values": "warn",
1906
- "tailwindcss/enforces-shorthand": "warn",
1907
- "tailwindcss/migration-from-tailwind-2": "warn",
1908
- "tailwindcss/no-arbitrary-value": "off",
1909
- "tailwindcss/no-contradicting-classname": "warn",
1910
- "tailwindcss/no-custom-classname": "off",
1911
- "tailwindcss/no-unnecessary-arbitrary-value": "warn",
1912
- ...overrides
1913
- }
1914
- }
1915
- ];
1916
- }
1917
-
1918
- // src/configs/command.ts
1919
- var import_config = __toESM(require("eslint-plugin-command/config"), 1);
1920
- function command() {
1921
- return [
1922
- {
1923
- ...(0, import_config.default)(),
1924
- name: "coderwyd/command/rules"
1680
+ // 'unicorn/better-regex': 'error',
1681
+ "unicorn/catch-error-name": "error",
1682
+ "unicorn/consistent-empty-array-spread": "error",
1683
+ "unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: false }],
1684
+ "unicorn/custom-error-definition": "error",
1685
+ "unicorn/error-message": "error",
1686
+ // 'unicorn/explicit-length-check': 'error',
1687
+ // 'unicorn/filename-case': [
1688
+ // 'error',
1689
+ // {
1690
+ // cases: { kebabCase: true, pascalCase: true },
1691
+ // ignore: [/^[A-Z]+\..*$/],
1692
+ // },
1693
+ "unicorn/escape-case": "error",
1694
+ // ],
1695
+ "unicorn/new-for-builtins": "error",
1696
+ // 'unicorn/no-array-callback-reference': 'error',
1697
+ "unicorn/no-array-method-this-argument": "error",
1698
+ "unicorn/no-array-push-push": "error",
1699
+ "unicorn/no-await-in-promise-methods": "error",
1700
+ "unicorn/no-console-spaces": "error",
1701
+ "unicorn/no-for-loop": "error",
1702
+ "unicorn/no-hex-escape": "error",
1703
+ "unicorn/no-instanceof-array": "error",
1704
+ "unicorn/no-invalid-remove-event-listener": "error",
1705
+ "unicorn/no-length-as-slice-end": "error",
1706
+ "unicorn/no-lonely-if": "error",
1707
+ "unicorn/no-new-array": "error",
1708
+ "unicorn/no-new-buffer": "error",
1709
+ "unicorn/no-single-promise-in-promise-methods": "error",
1710
+ "unicorn/no-static-only-class": "error",
1711
+ "unicorn/no-unnecessary-await": "error",
1712
+ "unicorn/no-zero-fractions": `error`,
1713
+ "unicorn/prefer-add-event-listener": "error",
1714
+ "unicorn/prefer-array-find": "error",
1715
+ "unicorn/prefer-array-flat-map": "error",
1716
+ "unicorn/prefer-array-index-of": "error",
1717
+ "unicorn/prefer-array-some": "error",
1718
+ "unicorn/prefer-at": "error",
1719
+ "unicorn/prefer-blob-reading-methods": "error",
1720
+ "unicorn/prefer-date-now": "error",
1721
+ "unicorn/prefer-dom-node-append": "error",
1722
+ "unicorn/prefer-dom-node-dataset": "error",
1723
+ "unicorn/prefer-dom-node-remove": "error",
1724
+ "unicorn/prefer-dom-node-text-content": "error",
1725
+ "unicorn/prefer-includes": "error",
1726
+ "unicorn/prefer-keyboard-event-key": "error",
1727
+ "unicorn/prefer-math-trunc": "error",
1728
+ "unicorn/prefer-modern-dom-apis": "error",
1729
+ "unicorn/prefer-modern-math-apis": "error",
1730
+ "unicorn/prefer-negative-index": "error",
1731
+ "unicorn/prefer-node-protocol": "error",
1732
+ "unicorn/prefer-number-properties": "error",
1733
+ "unicorn/prefer-optional-catch-binding": "error",
1734
+ "unicorn/prefer-prototype-methods": "error",
1735
+ "unicorn/prefer-query-selector": "error",
1736
+ "unicorn/prefer-reflect-apply": "error",
1737
+ // 'unicorn/prefer-regexp-test': 'error',
1738
+ "unicorn/prefer-string-replace-all": "error",
1739
+ "unicorn/prefer-string-slice": "error",
1740
+ "unicorn/prefer-string-starts-ends-with": "error",
1741
+ "unicorn/prefer-string-trim-start-end": "error",
1742
+ // top level await is not supported in all environments
1743
+ // 'unicorn/prefer-top-level-await': 'error',
1744
+ "unicorn/prefer-type-error": "error",
1745
+ "unicorn/throw-new-error": "error"
1746
+ }
1925
1747
  }
1926
1748
  ];
1927
1749
  }
1928
1750
 
1929
- // src/configs/regexp.ts
1930
- var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
1931
- function regexp(options = {}) {
1932
- const config = import_eslint_plugin_regexp.configs["flat/recommended"];
1933
- const rules = {
1934
- ...config.rules
1935
- };
1936
- if (options.level === "warn") {
1937
- Object.keys(rules).forEach((key) => {
1938
- if (rules[key] === "error")
1939
- rules[key] = "warn";
1940
- });
1941
- }
1751
+ // src/configs/unocss.ts
1752
+ async function unocss(options = {}) {
1753
+ const { attributify = true, strict = false } = options;
1754
+ await ensurePackages(["@unocss/eslint-plugin"]);
1755
+ const [pluginUnoCSS] = await Promise.all([
1756
+ interopDefault(import("@unocss/eslint-plugin"))
1757
+ ]);
1942
1758
  return [
1943
1759
  {
1944
- ...config,
1945
- name: "coderwyd/regexp/rules",
1760
+ name: "coderwyd/unocss/rules",
1761
+ plugins: {
1762
+ unocss: pluginUnoCSS
1763
+ },
1946
1764
  rules: {
1947
- ...rules,
1948
- ...options.overrides
1765
+ "unocss/order": "warn",
1766
+ ...attributify ? {
1767
+ "unocss/order-attributify": "warn"
1768
+ } : {},
1769
+ ...strict ? {
1770
+ "unocss/blocklist": "error"
1771
+ } : {}
1949
1772
  }
1950
1773
  }
1951
1774
  ];
1952
1775
  }
1953
1776
 
1954
- // src/configs/jsx.ts
1955
- function jsx() {
1777
+ // src/configs/vue.ts
1778
+ var import_eslint_merge_processors = require("eslint-merge-processors");
1779
+ async function vue(options = {}) {
1780
+ const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic2 = true } = options;
1781
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1782
+ const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1783
+ const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1784
+ interopDefault(import("eslint-plugin-vue")),
1785
+ interopDefault(import("vue-eslint-parser")),
1786
+ interopDefault(import("eslint-processor-vue-blocks"))
1787
+ ]);
1788
+ const isVue3 = getVueVersion() === 3;
1789
+ const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
1790
+ const vueRules = configKeys.reduce((preRules, key) => {
1791
+ const config = pluginVue.configs[key];
1792
+ return {
1793
+ ...preRules,
1794
+ ...config.rules
1795
+ };
1796
+ }, {});
1956
1797
  return [
1957
1798
  {
1958
- files: [GLOB_JSX, GLOB_TSX],
1799
+ // This allows Vue plugin to work with auto imports
1800
+ // https://github.com/vuejs/eslint-plugin-vue/pull/2422
1801
+ languageOptions: {
1802
+ globals: {
1803
+ computed: "readonly",
1804
+ defineEmits: "readonly",
1805
+ defineExpose: "readonly",
1806
+ defineProps: "readonly",
1807
+ onMounted: "readonly",
1808
+ onUnmounted: "readonly",
1809
+ reactive: "readonly",
1810
+ ref: "readonly",
1811
+ shallowReactive: "readonly",
1812
+ shallowRef: "readonly",
1813
+ toRef: "readonly",
1814
+ toRefs: "readonly",
1815
+ watch: "readonly",
1816
+ watchEffect: "readonly"
1817
+ }
1818
+ },
1819
+ name: "coderwyd/vue/setup",
1820
+ plugins: {
1821
+ vue: pluginVue
1822
+ }
1823
+ },
1824
+ {
1825
+ files,
1959
1826
  languageOptions: {
1827
+ parser: parserVue,
1960
1828
  parserOptions: {
1961
1829
  ecmaFeatures: {
1962
1830
  jsx: true
1963
- }
1831
+ },
1832
+ extraFileExtensions: [".vue"],
1833
+ parser: options.typescript ? await interopDefault(
1834
+ import("@typescript-eslint/parser")
1835
+ ) : null,
1836
+ sourceType: "module"
1964
1837
  }
1965
1838
  },
1966
- name: "coderwyd/jsx/setup"
1839
+ name: "coderwyd/vue/rules",
1840
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors.mergeProcessors)([
1841
+ pluginVue.processors[".vue"],
1842
+ processorVueBlocks({
1843
+ ...sfcBlocks,
1844
+ blocks: {
1845
+ styles: true,
1846
+ ...sfcBlocks.blocks
1847
+ }
1848
+ })
1849
+ ]),
1850
+ rules: {
1851
+ ...pluginVue.configs.base.rules,
1852
+ ...vueRules,
1853
+ "node/prefer-global/process": "off",
1854
+ "vue/block-order": [
1855
+ "error",
1856
+ {
1857
+ order: isVue3 ? ["script", "template", "style"] : ["template", "script", "style"]
1858
+ }
1859
+ ],
1860
+ // 'vue/component-api-style': ['warn', ['script-setup', 'composition']],
1861
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1862
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1863
+ // this is deprecated
1864
+ "vue/component-tags-order": "off",
1865
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1866
+ // 'vue/define-emits-declaration': ['warn', 'type-based'],
1867
+ "vue/define-macros-order": [
1868
+ "error",
1869
+ {
1870
+ order: [
1871
+ "defineOptions",
1872
+ "defineProps",
1873
+ "defineEmits",
1874
+ "defineSlots"
1875
+ ]
1876
+ }
1877
+ ],
1878
+ // 'vue/define-props-declaration': ['warn', 'type-based'],
1879
+ "vue/dot-location": ["error", "property"],
1880
+ "vue/dot-notation": ["error", { allowKeywords: true }],
1881
+ "vue/eqeqeq": ["error", "smart"],
1882
+ "vue/html-indent": ["error", indent],
1883
+ "vue/html-quotes": ["error", "double"],
1884
+ "vue/html-self-closing": [
1885
+ "error",
1886
+ {
1887
+ html: {
1888
+ component: "always",
1889
+ normal: "always",
1890
+ void: "any"
1891
+ },
1892
+ math: "always",
1893
+ svg: "always"
1894
+ }
1895
+ ],
1896
+ "vue/max-attributes-per-line": "off",
1897
+ "vue/multi-word-component-names": "off",
1898
+ // 'vue/next-tick-style': ['warn', 'promise'],
1899
+ "vue/no-constant-condition": "warn",
1900
+ "vue/no-dupe-keys": "off",
1901
+ "vue/no-duplicate-attr-inheritance": "warn",
1902
+ "vue/no-empty-pattern": "error",
1903
+ "vue/no-extra-parens": ["error", "functions"],
1904
+ "vue/no-irregular-whitespace": "error",
1905
+ "vue/no-loss-of-precision": "error",
1906
+ "vue/no-required-prop-with-default": "warn",
1907
+ "vue/no-restricted-syntax": [
1908
+ "error",
1909
+ "DebuggerStatement",
1910
+ "LabeledStatement",
1911
+ "WithStatement"
1912
+ ],
1913
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1914
+ "vue/no-setup-props-reactivity-loss": "off",
1915
+ "vue/no-sparse-arrays": "error",
1916
+ "vue/no-unsupported-features": "warn",
1917
+ "vue/no-unused-emit-declarations": "warn",
1918
+ "vue/no-unused-refs": "error",
1919
+ "vue/no-use-v-else-with-v-for": "error",
1920
+ "vue/no-useless-mustaches": "warn",
1921
+ "vue/no-useless-v-bind": "error",
1922
+ "vue/no-v-html": "off",
1923
+ "vue/no-v-text": "warn",
1924
+ "vue/object-shorthand": [
1925
+ "error",
1926
+ "always",
1927
+ {
1928
+ avoidQuotes: true,
1929
+ ignoreConstructors: false
1930
+ }
1931
+ ],
1932
+ "vue/prefer-define-options": "warn",
1933
+ "vue/prefer-separate-static-class": "error",
1934
+ "vue/prefer-template": "error",
1935
+ "vue/prop-name-casing": ["error", "camelCase"],
1936
+ "vue/require-default-prop": "off",
1937
+ "vue/require-macro-variable-name": [
1938
+ "warn",
1939
+ {
1940
+ defineEmits: "emit",
1941
+ defineProps: "props",
1942
+ defineSlots: "slots",
1943
+ useAttrs: "attrs",
1944
+ useSlots: "slots"
1945
+ }
1946
+ ],
1947
+ "vue/require-prop-types": "off",
1948
+ // 'vue/singleline-html-element-content-newline': 'off',
1949
+ "vue/space-infix-ops": "error",
1950
+ "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1951
+ "vue/valid-define-options": "warn",
1952
+ ...stylistic2 ? {
1953
+ "vue/array-bracket-spacing": ["error", "never"],
1954
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
1955
+ "vue/block-spacing": ["error", "always"],
1956
+ "vue/block-tag-newline": [
1957
+ "error",
1958
+ {
1959
+ multiline: "always",
1960
+ singleline: "always"
1961
+ }
1962
+ ],
1963
+ "vue/brace-style": [
1964
+ "error",
1965
+ "stroustrup",
1966
+ { allowSingleLine: true }
1967
+ ],
1968
+ "vue/comma-dangle": ["error", "always-multiline"],
1969
+ "vue/comma-spacing": ["error", { after: true, before: false }],
1970
+ "vue/comma-style": ["error", "last"],
1971
+ "vue/html-comment-content-newline": "warn",
1972
+ "vue/html-comment-content-spacing": [
1973
+ "error",
1974
+ "always",
1975
+ {
1976
+ exceptions: ["-"]
1977
+ }
1978
+ ],
1979
+ "vue/key-spacing": [
1980
+ "error",
1981
+ { afterColon: true, beforeColon: false }
1982
+ ],
1983
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
1984
+ "vue/object-curly-newline": "off",
1985
+ "vue/object-curly-spacing": ["error", "always"],
1986
+ "vue/object-property-newline": [
1987
+ "error",
1988
+ { allowMultiplePropertiesPerLine: true }
1989
+ ],
1990
+ "vue/operator-linebreak": ["error", "before"],
1991
+ "vue/padding-line-between-blocks": ["error", "always"],
1992
+ "vue/quote-props": ["error", "consistent-as-needed"],
1993
+ "vue/space-in-parens": ["error", "never"],
1994
+ "vue/template-curly-spacing": "error"
1995
+ } : {},
1996
+ ...overrides
1997
+ }
1967
1998
  }
1968
1999
  ];
1969
2000
  }
@@ -1971,8 +2002,6 @@ function jsx() {
1971
2002
  // src/index.ts
1972
2003
  var flatConfigProps = [
1973
2004
  "name",
1974
- "files",
1975
- "ignores",
1976
2005
  "languageOptions",
1977
2006
  "linterOptions",
1978
2007
  "processor",
@@ -2001,7 +2030,6 @@ async function defineConfig(options = {}, ...userConfigs) {
2001
2030
  html: true
2002
2031
  },
2003
2032
  gitignore: enableGitignore = true,
2004
- isInEditor: isInEditor2 = isInEditor,
2005
2033
  jsx: enableJsx = true,
2006
2034
  react: enableReact = false,
2007
2035
  regexp: enableRegexp = true,
@@ -2011,6 +2039,12 @@ async function defineConfig(options = {}, ...userConfigs) {
2011
2039
  unocss: enableUnoCSS = false,
2012
2040
  vue: enableVue = hasVue
2013
2041
  } = options;
2042
+ let isInEditor2 = options.isInEditor;
2043
+ if (isInEditor2 == null) {
2044
+ isInEditor2 = isInEditorEnv();
2045
+ if (isInEditor2)
2046
+ console.log("[@coderwyd/eslint-config] Detected running in editor, some rules are disabled.");
2047
+ }
2014
2048
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2015
2049
  if (stylisticOptions && !("jsx" in stylisticOptions))
2016
2050
  stylisticOptions.jsx = enableJsx;
@@ -2019,17 +2053,20 @@ async function defineConfig(options = {}, ...userConfigs) {
2019
2053
  if (typeof enableGitignore !== "boolean") {
2020
2054
  configs2.push(
2021
2055
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
2022
- r(enableGitignore)
2056
+ r({
2057
+ ...enableGitignore,
2058
+ name: "coderwyd/gitignore"
2059
+ })
2023
2060
  ])
2024
2061
  );
2025
2062
  } else {
2026
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
2063
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ name: "coderwyd/gitignore", strict: false })]));
2027
2064
  }
2028
2065
  }
2029
2066
  const typescriptOptions = resolveSubOptions(options, "typescript");
2030
2067
  const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2031
2068
  configs2.push(
2032
- ignores(),
2069
+ ignores(options.ignores),
2033
2070
  javascript({
2034
2071
  isInEditor: isInEditor2,
2035
2072
  overrides: getOverrides(options, "javascript")
@@ -2140,6 +2177,10 @@ async function defineConfig(options = {}, ...userConfigs) {
2140
2177
  )
2141
2178
  );
2142
2179
  }
2180
+ configs2.push(disables());
2181
+ if ("files" in options) {
2182
+ throw new Error('[@coderwyd/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
2183
+ }
2143
2184
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2144
2185
  if (key in options)
2145
2186
  acc[key] = options[key];
@@ -2161,6 +2202,9 @@ async function defineConfig(options = {}, ...userConfigs) {
2161
2202
  getOverrides,
2162
2203
  getVueVersion,
2163
2204
  interopDefault,
2205
+ isInEditorEnv,
2206
+ isInGitHooksOrLintStaged,
2207
+ isPackageInScope,
2164
2208
  parserPlain,
2165
2209
  renamePluginInConfigs,
2166
2210
  renameRules,