@coderwyd/eslint-config 2.7.0 → 2.7.2

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