@so1ve/eslint-config 3.22.2 → 3.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -400,6 +400,11 @@ interface RuleOptions {
400
400
  * @deprecated
401
401
  */
402
402
  'comma-style'?: Linter.RuleEntry<CommaStyle>;
403
+ /**
404
+ * Comment-as-command for one-off codemod with ESLint
405
+ * @see https://github.com/antfu/eslint-plugin-command
406
+ */
407
+ 'command/command'?: Linter.RuleEntry<[]>;
403
408
  /**
404
409
  * Enforce a maximum cyclomatic complexity allowed in a program
405
410
  * @see https://eslint.org/docs/latest/rules/complexity
@@ -16288,7 +16293,7 @@ type Yoda = [] | [("always" | "never")] | [("always" | "never"), {
16288
16293
  onlyEquality?: boolean;
16289
16294
  }];
16290
16295
  // Names of all the configs
16291
- type ConfigNames = 'antfu/astro/setup' | 'antfu/astro/rules' | 'so1ve/comments/setup' | 'so1ve/comments/rules' | 'so1ve/formatting/setup' | 'so1ve/formatting/rules' | 'so1ve/formatting/rules/sort-package-json' | 'so1ve/formatting/rules/sort-tsconfig' | 'so1ve/formatting/rules/test' | 'so1ve/html/setup' | 'so1ve/html/rules' | 'so1ve/ignores' | 'so1ve/imports/setup' | 'so1ve/imports/rules' | 'so1ve/imports/rules/dts' | 'so1ve/javascript/setup' | 'so1ve/javascript/rules' | 'so1ve/javascript/regexp' | 'so1ve/javascript/cli' | 'so1ve/jsonc/setup' | 'so1ve/jsonc/rules' | 'so1ve/mdx/setup' | 'so1ve/mdx/rules' | 'so1ve/node/setup' | 'so1ve/node/rules' | 'so1ve/only-error' | 'so1ve/perfectionist/setup' | 'so1ve/perfectionist/rules' | 'so1ve/pnpm/package-json' | 'so1ve/pnpm/pnpm-workspace-yaml' | 'so1ve/promise/setup' | 'so1ve/promise/rules' | 'so1ve/solid/setup' | 'so1ve/solid/rules' | 'so1ve/sort-imports/setup' | 'so1ve/sort-imports/rules' | 'so1ve/test/setup' | 'so1ve/test/rules' | 'so1ve/toml/setup' | 'so1ve/toml/rules' | 'so1ve/typescript/setup' | 'so1ve/typescript/rules' | 'so1ve/typescript/rules/type-aware' | 'so1ve/typescript/rules/dts' | 'so1ve/typescript/rules/js' | 'so1ve/unicorn/setup' | 'so1ve/unicorn/rules' | 'so1ve/vue/setup' | 'so1ve/vue/rules' | 'so1ve/yaml/setup' | 'so1ve/yaml/rules' | 'so1ve/yaml/pnpm-workspace';
16296
+ type ConfigNames = 'so1ve/ignores' | 'so1ve/javascript/setup' | 'so1ve/javascript/rules' | 'so1ve/javascript/regexp' | 'so1ve/javascript/cli' | 'so1ve/comments/setup' | 'so1ve/comments/rules' | 'so1ve/node/setup' | 'so1ve/node/rules' | 'so1ve/only-error' | 'so1ve/promise/setup' | 'so1ve/promise/rules' | 'so1ve/sort-imports/setup' | 'so1ve/sort-imports/rules' | 'so1ve/imports/setup' | 'so1ve/imports/rules' | 'so1ve/imports/rules/dts' | 'so1ve/unicorn/setup' | 'so1ve/unicorn/rules' | 'so1ve/command/rules' | 'so1ve/pnpm/package-json' | 'so1ve/pnpm/pnpm-workspace-yaml' | 'so1ve/yaml/pnpm-workspace-yaml-sort' | 'so1ve/html/setup' | 'so1ve/html/rules' | 'so1ve/typescript/setup' | 'so1ve/typescript/rules' | 'so1ve/typescript/rules/type-aware' | 'so1ve/typescript/rules/dts' | 'so1ve/typescript/rules/js' | 'so1ve/test/setup' | 'so1ve/test/rules' | 'antfu/astro/setup' | 'antfu/astro/rules' | 'so1ve/vue/setup' | 'so1ve/vue/rules' | 'so1ve/solid/setup' | 'so1ve/solid/rules' | 'so1ve/formatting/setup' | 'so1ve/formatting/rules' | 'so1ve/formatting/rules/sort-package-json' | 'so1ve/formatting/rules/sort-tsconfig' | 'so1ve/formatting/rules/test' | 'so1ve/perfectionist/setup' | 'so1ve/perfectionist/rules' | 'so1ve/jsonc/setup' | 'so1ve/jsonc/rules' | 'so1ve/toml/setup' | 'so1ve/toml/rules' | 'so1ve/yaml/setup' | 'so1ve/yaml/rules' | 'so1ve/mdx/setup' | 'so1ve/mdx/rules';
16292
16297
  //#endregion
16293
16298
  //#region src/types.d.ts
16294
16299
  type MaybePromise<T> = T | Promise<T>;
@@ -16319,6 +16324,24 @@ interface OptionsTypeScriptParserOptions {
16319
16324
  interface OptionsHasTypeScript {
16320
16325
  typescript?: boolean;
16321
16326
  }
16327
+ interface OptionsPnpm {
16328
+ /**
16329
+ * Requires catalogs usage
16330
+ */
16331
+ catalogs?: boolean;
16332
+ /**
16333
+ * Enable linting for package.json
16334
+ *
16335
+ * @default true
16336
+ */
16337
+ json?: boolean;
16338
+ /**
16339
+ * Enable linting for pnpm-workspace.yaml
16340
+ *
16341
+ * @default true
16342
+ */
16343
+ yaml?: boolean;
16344
+ }
16322
16345
  interface OptionsOverrides {
16323
16346
  overrides?: TypedFlatConfigItem["rules"];
16324
16347
  }
@@ -16333,11 +16356,20 @@ interface Options extends OptionsComponentExts {
16333
16356
  */
16334
16357
  gitignore?: boolean | FlatGitignoreOptions;
16335
16358
  /**
16359
+ * Extend the global ignores.
16360
+ *
16361
+ * Passing an array to extends the ignores. Passing a function to modify the
16362
+ * default ignores.
16363
+ *
16364
+ * @default [ ]
16365
+ */
16366
+ ignores?: string[] | ((originals: string[]) => string[]);
16367
+ /**
16336
16368
  * Enable pnpm catalogs support.
16337
16369
  *
16338
16370
  * @default false
16339
16371
  */
16340
- pnpm?: boolean;
16372
+ pnpm?: boolean | OptionsPnpm;
16341
16373
  /**
16342
16374
  * Core rules. Can't be disabled.
16343
16375
  */
@@ -16450,7 +16482,7 @@ declare function formatting(options?: Options): Promise<TypedFlatConfigItem[]>;
16450
16482
  declare function html(): Promise<TypedFlatConfigItem[]>;
16451
16483
  //#endregion
16452
16484
  //#region src/configs/ignores.d.ts
16453
- declare const ignores: () => TypedFlatConfigItem[];
16485
+ declare function ignores(userIgnores?: string[] | ((originals: string[]) => string[])): TypedFlatConfigItem[];
16454
16486
  //#endregion
16455
16487
  //#region src/configs/imports.d.ts
16456
16488
  declare const imports: (options?: Options) => TypedFlatConfigItem[];
@@ -16479,7 +16511,7 @@ declare const onlyError: () => TypedFlatConfigItem[];
16479
16511
  declare function perfectionist(): Promise<TypedFlatConfigItem[]>;
16480
16512
  //#endregion
16481
16513
  //#region src/configs/pnpm.d.ts
16482
- declare function pnpm(): Promise<TypedFlatConfigItem[]>;
16514
+ declare function pnpm(options: OptionsPnpm): Promise<TypedFlatConfigItem[]>;
16483
16515
  //#endregion
16484
16516
  //#region src/configs/promise.d.ts
16485
16517
  declare const promise: () => TypedFlatConfigItem[];
@@ -16596,4 +16628,4 @@ declare function interopDefault<T>(m: MaybePromise<T>): Promise<T extends {
16596
16628
  default: infer U;
16597
16629
  } ? U : T>;
16598
16630
  //#endregion
16599
- export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, MaybeArray, MaybePromise, Options, OptionsComponentExts, OptionsHasTypeScript, OptionsOverrides, OptionsTypeScriptParserOptions, ResolvedOptions, Rules, TypedFlatConfigItem, astro, command, comments, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, perfectionist, pnpm, promise, renameRules, so1ve, solid, sortImports, test, toml, typescript$1 as typescript, unicorn, vue, yaml };
16631
+ export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, MaybeArray, MaybePromise, Options, OptionsComponentExts, OptionsHasTypeScript, OptionsOverrides, OptionsPnpm, OptionsTypeScriptParserOptions, ResolvedOptions, Rules, TypedFlatConfigItem, astro, command, comments, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, perfectionist, pnpm, promise, renameRules, so1ve, solid, sortImports, test, toml, typescript$1 as typescript, unicorn, vue, yaml };
@@ -13,8 +13,12 @@ import * as pluginRegexp from "eslint-plugin-regexp";
13
13
  import pluginUnicorn from "eslint-plugin-unicorn";
14
14
  import pluginUnusedImports from "eslint-plugin-unused-imports";
15
15
  import globals from "globals";
16
- import tseslint from "typescript-eslint";
16
+ import fsPromises from "node:fs/promises";
17
+ import process$1 from "node:process";
18
+ import { fileURLToPath } from "node:url";
17
19
  import fs from "node:fs";
20
+ import path from "node:path";
21
+ import tseslint from "typescript-eslint";
18
22
  import { FlatConfigComposer } from "eslint-flat-config-utils";
19
23
  import { isPackageExists } from "local-pkg";
20
24
 
@@ -242,6 +246,59 @@ async function formatting(options) {
242
246
  files: [GLOB_PACKAGEJSON],
243
247
  rules: { "jsonc/sort-keys": [
244
248
  "error",
249
+ {
250
+ pathPattern: "^$",
251
+ order: [
252
+ "name",
253
+ "displayName",
254
+ "private",
255
+ "preview",
256
+ "version",
257
+ "packageManager",
258
+ "publisher",
259
+ "author",
260
+ "contributors",
261
+ "type",
262
+ "description",
263
+ "keywords",
264
+ "homepage",
265
+ "repository",
266
+ "bugs",
267
+ "funding",
268
+ "categories",
269
+ "license",
270
+ "sideEffects",
271
+ "exports",
272
+ "bin",
273
+ "main",
274
+ "module",
275
+ "browser",
276
+ "unpkg",
277
+ "jsdelivr",
278
+ "types",
279
+ "typesVersions",
280
+ "icon",
281
+ "files",
282
+ "engines",
283
+ "extensionKind",
284
+ "activationEvents",
285
+ "contributes",
286
+ "eslintConfig",
287
+ "publishConfig",
288
+ "scripts",
289
+ "husky",
290
+ "simple-git-hooks",
291
+ "lint-staged",
292
+ "dependencies",
293
+ "devDependencies",
294
+ "optionalDependencies",
295
+ "peerDependencies",
296
+ "peerDependenciesMeta",
297
+ "pnpm",
298
+ "overrides",
299
+ "resolutions"
300
+ ]
301
+ },
245
302
  {
246
303
  pathPattern: "^exports$",
247
304
  order: { type: "asc" }
@@ -254,122 +311,170 @@ async function formatting(options) {
254
311
  "import",
255
312
  "default"
256
313
  ]
257
- }
258
- ] }
259
- }, {
260
- name: "so1ve/formatting/rules/sort-tsconfig",
261
- files: GLOB_TSCONFIG,
262
- rules: { "jsonc/sort-keys": [
263
- "error",
314
+ },
264
315
  {
265
- pathPattern: "^$",
266
- order: [
267
- "extends",
268
- "compilerOptions",
269
- "references",
270
- "files",
271
- "include",
272
- "exclude"
273
- ]
316
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$",
317
+ order: { type: "asc" }
274
318
  },
275
319
  {
276
- pathPattern: "^compilerOptions$",
277
- order: [
278
- "incremental",
279
- "composite",
280
- "tsBuildInfoFile",
281
- "disableSourceOfProjectReferenceRedirect",
282
- "disableSolutionSearching",
283
- "disableReferencedProjectLoad",
284
- "target",
285
- "jsx",
286
- "jsxFactory",
287
- "jsxFragmentFactory",
288
- "jsxImportSource",
289
- "lib",
290
- "moduleDetection",
291
- "noLib",
292
- "reactNamespace",
293
- "useDefineForClassFields",
294
- "emitDecoratorMetadata",
295
- "experimentalDecorators",
296
- "baseUrl",
297
- "rootDir",
298
- "rootDirs",
299
- "customConditions",
300
- "module",
301
- "moduleResolution",
302
- "moduleSuffixes",
303
- "noResolve",
304
- "resolveJsonModule",
305
- "resolvePackageJsonExports",
306
- "resolvePackageJsonImports",
307
- "typeRoots",
308
- "types",
309
- "allowArbitraryExtensions",
310
- "allowImportingTsExtensions",
311
- "allowUmdGlobalAccess",
312
- "allowJs",
313
- "checkJs",
314
- "maxNodeModuleJsDepth",
315
- "strict",
316
- "strictBindCallApply",
317
- "strictFunctionTypes",
318
- "strictNullChecks",
319
- "strictPropertyInitialization",
320
- "allowUnreachableCode",
321
- "allowUnusedLabels",
322
- "alwaysStrict",
323
- "exactOptionalPropertyTypes",
324
- "noFallthroughCasesInSwitch",
325
- "noImplicitAny",
326
- "noImplicitOverride",
327
- "noImplicitReturns",
328
- "noImplicitThis",
329
- "noPropertyAccessFromIndexSignature",
330
- "noUncheckedIndexedAccess",
331
- "noUnusedLocals",
332
- "noUnusedParameters",
333
- "useUnknownInCatchVariables",
334
- "declaration",
335
- "declarationDir",
336
- "declarationMap",
337
- "downlevelIteration",
338
- "emitBOM",
339
- "emitDeclarationOnly",
340
- "importHelpers",
341
- "importsNotUsedAsValues",
342
- "inlineSourceMap",
343
- "inlineSources",
344
- "mapRoot",
345
- "newLine",
346
- "noEmit",
347
- "noEmitHelpers",
348
- "noEmitOnError",
349
- "outDir",
350
- "outFile",
351
- "preserveConstEnums",
352
- "preserveValueImports",
353
- "removeComments",
354
- "sourceMap",
355
- "sourceRoot",
356
- "stripInternal",
357
- "allowSyntheticDefaultImports",
358
- "esModuleInterop",
359
- "forceConsistentCasingInFileNames",
360
- "isolatedModules",
361
- "preserveSymlinks",
362
- "verbatimModuleSyntax",
363
- "skipDefaultLibCheck",
364
- "skipLibCheck",
365
- "paths"
366
- ]
320
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$",
321
+ order: { type: "asc" }
367
322
  },
368
323
  {
369
- pathPattern: "^compilerOptions\\.paths$",
324
+ pathPattern: "^workspaces\\.catalog$",
370
325
  order: { type: "asc" }
326
+ },
327
+ {
328
+ pathPattern: "^workspaces\\.catalogs\\.[^.]+$",
329
+ order: { type: "asc" }
330
+ },
331
+ {
332
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$",
333
+ order: [
334
+ "pre-commit",
335
+ "prepare-commit-msg",
336
+ "commit-msg",
337
+ "post-commit",
338
+ "pre-rebase",
339
+ "post-rewrite",
340
+ "post-checkout",
341
+ "post-merge",
342
+ "pre-push",
343
+ "pre-auto-gc"
344
+ ]
371
345
  }
372
346
  ] }
347
+ }, {
348
+ name: "so1ve/formatting/rules/sort-tsconfig",
349
+ files: GLOB_TSCONFIG,
350
+ rules: {
351
+ "jsonc/sort-array-values": [
352
+ "error",
353
+ {
354
+ pathPattern: "^compilerOptions\\.types$",
355
+ order: { type: "asc" }
356
+ },
357
+ {
358
+ pathPattern: "^include$",
359
+ order: { type: "asc" }
360
+ },
361
+ {
362
+ pathPattern: "^exclude$",
363
+ order: { type: "asc" }
364
+ }
365
+ ],
366
+ "jsonc/sort-keys": [
367
+ "error",
368
+ {
369
+ pathPattern: "^$",
370
+ order: [
371
+ "extends",
372
+ "compilerOptions",
373
+ "references",
374
+ "files",
375
+ "include",
376
+ "exclude"
377
+ ]
378
+ },
379
+ {
380
+ pathPattern: "^compilerOptions$",
381
+ order: [
382
+ "incremental",
383
+ "composite",
384
+ "tsBuildInfoFile",
385
+ "disableSourceOfProjectReferenceRedirect",
386
+ "disableSolutionSearching",
387
+ "disableReferencedProjectLoad",
388
+ "target",
389
+ "jsx",
390
+ "jsxFactory",
391
+ "jsxFragmentFactory",
392
+ "jsxImportSource",
393
+ "lib",
394
+ "moduleDetection",
395
+ "noLib",
396
+ "reactNamespace",
397
+ "useDefineForClassFields",
398
+ "emitDecoratorMetadata",
399
+ "experimentalDecorators",
400
+ "baseUrl",
401
+ "rootDir",
402
+ "rootDirs",
403
+ "customConditions",
404
+ "module",
405
+ "moduleResolution",
406
+ "moduleSuffixes",
407
+ "noResolve",
408
+ "resolveJsonModule",
409
+ "resolvePackageJsonExports",
410
+ "resolvePackageJsonImports",
411
+ "typeRoots",
412
+ "types",
413
+ "allowArbitraryExtensions",
414
+ "allowImportingTsExtensions",
415
+ "allowUmdGlobalAccess",
416
+ "allowJs",
417
+ "checkJs",
418
+ "maxNodeModuleJsDepth",
419
+ "strict",
420
+ "strictBindCallApply",
421
+ "strictFunctionTypes",
422
+ "strictNullChecks",
423
+ "strictPropertyInitialization",
424
+ "allowUnreachableCode",
425
+ "allowUnusedLabels",
426
+ "alwaysStrict",
427
+ "exactOptionalPropertyTypes",
428
+ "noFallthroughCasesInSwitch",
429
+ "noImplicitAny",
430
+ "noImplicitOverride",
431
+ "noImplicitReturns",
432
+ "noImplicitThis",
433
+ "noPropertyAccessFromIndexSignature",
434
+ "noUncheckedIndexedAccess",
435
+ "noUnusedLocals",
436
+ "noUnusedParameters",
437
+ "useUnknownInCatchVariables",
438
+ "declaration",
439
+ "declarationDir",
440
+ "declarationMap",
441
+ "downlevelIteration",
442
+ "emitBOM",
443
+ "emitDeclarationOnly",
444
+ "importHelpers",
445
+ "importsNotUsedAsValues",
446
+ "inlineSourceMap",
447
+ "inlineSources",
448
+ "mapRoot",
449
+ "newLine",
450
+ "noEmit",
451
+ "noEmitHelpers",
452
+ "noEmitOnError",
453
+ "outDir",
454
+ "outFile",
455
+ "preserveConstEnums",
456
+ "preserveValueImports",
457
+ "removeComments",
458
+ "sourceMap",
459
+ "sourceRoot",
460
+ "stripInternal",
461
+ "allowSyntheticDefaultImports",
462
+ "esModuleInterop",
463
+ "forceConsistentCasingInFileNames",
464
+ "isolatedModules",
465
+ "preserveSymlinks",
466
+ "verbatimModuleSyntax",
467
+ "skipDefaultLibCheck",
468
+ "skipLibCheck",
469
+ "paths"
470
+ ]
471
+ },
472
+ {
473
+ pathPattern: "^compilerOptions\\.paths$",
474
+ order: { type: "asc" }
475
+ }
476
+ ]
477
+ }
373
478
  }],
374
479
  (options?.test ?? true) && {
375
480
  name: "so1ve/formatting/rules/test",
@@ -414,10 +519,14 @@ async function html() {
414
519
 
415
520
  //#endregion
416
521
  //#region src/configs/ignores.ts
417
- const ignores = () => [{
418
- name: "so1ve/ignores",
419
- ignores: GLOB_EXCLUDE
420
- }];
522
+ function ignores(userIgnores = []) {
523
+ let ignores$1 = [...GLOB_EXCLUDE];
524
+ ignores$1 = typeof userIgnores === "function" ? userIgnores(ignores$1) : [...ignores$1, ...userIgnores];
525
+ return [{
526
+ name: "so1ve/ignores",
527
+ ignores: ignores$1
528
+ }];
529
+ }
421
530
 
422
531
  //#endregion
423
532
  //#region src/configs/imports.ts
@@ -508,7 +617,7 @@ async function javascript({ overrides } = {}) {
508
617
  {
509
618
  name: "so1ve/javascript/rules",
510
619
  languageOptions: {
511
- ecmaVersion: 2022,
620
+ ecmaVersion: "latest",
512
621
  globals: {
513
622
  ...globals.browser,
514
623
  ...globals.es2021,
@@ -519,7 +628,7 @@ async function javascript({ overrides } = {}) {
519
628
  },
520
629
  parserOptions: {
521
630
  ecmaFeatures: { jsx: true },
522
- ecmaVersion: 2022,
631
+ ecmaVersion: "latest",
523
632
  sourceType: "module"
524
633
  },
525
634
  sourceType: "module"
@@ -935,31 +1044,153 @@ async function perfectionist() {
935
1044
  }];
936
1045
  }
937
1046
 
1047
+ //#endregion
1048
+ //#region ../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
1049
+ const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
1050
+ async function findUp(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
1051
+ let directory = path.resolve(toPath(cwd) ?? "");
1052
+ const { root } = path.parse(directory);
1053
+ stopAt = path.resolve(directory, toPath(stopAt ?? root));
1054
+ const isAbsoluteName = path.isAbsolute(name);
1055
+ while (directory) {
1056
+ const filePath = isAbsoluteName ? name : path.join(directory, name);
1057
+ try {
1058
+ const stats = await fsPromises.stat(filePath);
1059
+ if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
1060
+ } catch {}
1061
+ if (directory === stopAt || directory === root) break;
1062
+ directory = path.dirname(directory);
1063
+ }
1064
+ }
1065
+ function findUpSync(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
1066
+ let directory = path.resolve(toPath(cwd) ?? "");
1067
+ const { root } = path.parse(directory);
1068
+ stopAt = path.resolve(directory, toPath(stopAt) ?? root);
1069
+ const isAbsoluteName = path.isAbsolute(name);
1070
+ while (directory) {
1071
+ const filePath = isAbsoluteName ? name : path.join(directory, name);
1072
+ try {
1073
+ const stats = fs.statSync(filePath, { throwIfNoEntry: false });
1074
+ if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
1075
+ } catch {}
1076
+ if (directory === stopAt || directory === root) break;
1077
+ directory = path.dirname(directory);
1078
+ }
1079
+ }
1080
+
938
1081
  //#endregion
939
1082
  //#region src/configs/pnpm.ts
940
- async function pnpm() {
1083
+ async function detectCatalogUsage() {
1084
+ const workspaceFile = await findUp("pnpm-workspace.yaml");
1085
+ if (!workspaceFile) return false;
1086
+ const yaml$1 = await fsPromises.readFile(workspaceFile, "utf-8");
1087
+ return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
1088
+ }
1089
+ async function pnpm(options) {
1090
+ const { catalogs = await detectCatalogUsage(), json = true, yaml: yaml$1 = true } = options;
941
1091
  const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
942
1092
  interopDefault(import("eslint-plugin-pnpm")),
943
- interopDefault(import("yaml-eslint-parser")),
944
- interopDefault(import("jsonc-eslint-parser"))
1093
+ yaml$1 ? interopDefault(import("yaml-eslint-parser")) : void 0,
1094
+ json ? interopDefault(import("jsonc-eslint-parser")) : void 0
945
1095
  ]);
946
- return [{
1096
+ const configs = [];
1097
+ if (json) configs.push({
947
1098
  files: ["package.json", "**/package.json"],
948
1099
  languageOptions: { parser: jsoncParser },
949
1100
  name: "so1ve/pnpm/package-json",
950
1101
  plugins: { pnpm: pluginPnpm },
951
1102
  rules: {
952
- "pnpm/json-enforce-catalog": "error",
1103
+ ...catalogs && { "pnpm/json-enforce-catalog": ["error", { ignores: ["@types/vscode"] }] },
953
1104
  "pnpm/json-prefer-workspace-settings": "error",
954
1105
  "pnpm/json-valid-catalog": "error"
955
1106
  }
956
- }, {
1107
+ });
1108
+ if (yaml$1) configs.push({
957
1109
  files: ["pnpm-workspace.yaml"],
958
1110
  languageOptions: { parser: yamlParser },
959
1111
  name: "so1ve/pnpm/pnpm-workspace-yaml",
960
1112
  plugins: { pnpm: pluginPnpm },
961
- rules: { "pnpm/yaml-no-unused-catalog-item": "error" }
962
- }];
1113
+ rules: {
1114
+ "pnpm/yaml-enforce-settings": ["error", { settings: { shellEmulator: true } }],
1115
+ "pnpm/yaml-no-unused-catalog-item": "error"
1116
+ }
1117
+ }, {
1118
+ files: ["pnpm-workspace.yaml"],
1119
+ name: "so1ve/yaml/pnpm-workspace-yaml-sort",
1120
+ rules: { "yaml/sort-keys": [
1121
+ "error",
1122
+ {
1123
+ order: [
1124
+ ...[
1125
+ "cacheDir",
1126
+ "catalogMode",
1127
+ "cleanupUnusedCatalogs",
1128
+ "dedupeDirectDeps",
1129
+ "deployAllFiles",
1130
+ "enablePrePostScripts",
1131
+ "engineStrict",
1132
+ "extendNodePath",
1133
+ "hoist",
1134
+ "hoistPattern",
1135
+ "hoistWorkspacePackages",
1136
+ "ignoreCompatibilityDb",
1137
+ "ignoreDepScripts",
1138
+ "ignoreScripts",
1139
+ "ignoreWorkspaceRootCheck",
1140
+ "managePackageManagerVersions",
1141
+ "minimumReleaseAge",
1142
+ "minimumReleaseAgeExclude",
1143
+ "modulesDir",
1144
+ "nodeLinker",
1145
+ "nodeVersion",
1146
+ "optimisticRepeatInstall",
1147
+ "packageManagerStrict",
1148
+ "packageManagerStrictVersion",
1149
+ "preferSymlinkedExecutables",
1150
+ "preferWorkspacePackages",
1151
+ "publicHoistPattern",
1152
+ "registrySupportsTimeField",
1153
+ "requiredScripts",
1154
+ "resolutionMode",
1155
+ "savePrefix",
1156
+ "scriptShell",
1157
+ "shamefullyHoist",
1158
+ "shellEmulator",
1159
+ "stateDir",
1160
+ "supportedArchitectures",
1161
+ "symlink",
1162
+ "tag",
1163
+ "trustPolicy",
1164
+ "trustPolicyExclude",
1165
+ "updateNotifier"
1166
+ ],
1167
+ "packages",
1168
+ "overrides",
1169
+ "patchedDependencies",
1170
+ ...[
1171
+ "allowedDeprecatedVersions",
1172
+ "allowNonAppliedPatches",
1173
+ "configDependencies",
1174
+ "ignoredBuiltDependencies",
1175
+ "ignoredOptionalDependencies",
1176
+ "neverBuiltDependencies",
1177
+ "onlyBuiltDependencies",
1178
+ "onlyBuiltDependenciesFile",
1179
+ "packageExtensions",
1180
+ "peerDependencyRules"
1181
+ ],
1182
+ "catalog",
1183
+ "catalogs"
1184
+ ],
1185
+ pathPattern: "^$"
1186
+ },
1187
+ {
1188
+ order: { type: "asc" },
1189
+ pathPattern: ".*"
1190
+ }
1191
+ ] }
1192
+ });
1193
+ return configs;
963
1194
  }
964
1195
 
965
1196
  //#endregion
@@ -1549,57 +1780,21 @@ async function vue({ overrides, typescript: typescript$1 } = {}) {
1549
1780
  //#region src/configs/yaml.ts
1550
1781
  async function yaml({ overrides } = {}) {
1551
1782
  const [parserYaml, pluginYaml] = await Promise.all([interopDefault(import("yaml-eslint-parser")), interopDefault(import("eslint-plugin-yml"))]);
1552
- return [
1553
- {
1554
- name: "so1ve/yaml/setup",
1555
- plugins: { yaml: pluginYaml }
1556
- },
1557
- {
1558
- name: "so1ve/yaml/rules",
1559
- languageOptions: { parser: parserYaml },
1560
- files: [GLOB_YAML],
1561
- rules: {
1562
- ...renameRules(pluginYaml.configs.prettier.rules, { yml: "yaml" }),
1563
- ...renameRules(pluginYaml.configs.recommended.rules, { yml: "yaml" }),
1564
- "style/spaced-comment": "off",
1565
- "yaml/no-empty-document": "off",
1566
- ...overrides
1567
- }
1568
- },
1569
- {
1570
- files: ["pnpm-workspace.yaml"],
1571
- name: "so1ve/yaml/pnpm-workspace",
1572
- rules: { "yaml/sort-keys": [
1573
- "error",
1574
- {
1575
- order: [
1576
- "packages",
1577
- "overrides",
1578
- "patchedDependencies",
1579
- "hoistPattern",
1580
- "allowedDeprecatedVersions",
1581
- "allowNonAppliedPatches",
1582
- "configDependencies",
1583
- "ignoredBuiltDependencies",
1584
- "ignoredOptionalDependencies",
1585
- "neverBuiltDependencies",
1586
- "onlyBuiltDependencies",
1587
- "onlyBuiltDependenciesFile",
1588
- "packageExtensions",
1589
- "peerDependencyRules",
1590
- "supportedArchitectures",
1591
- "catalog",
1592
- "catalogs"
1593
- ],
1594
- pathPattern: "^$"
1595
- },
1596
- {
1597
- order: { type: "asc" },
1598
- pathPattern: ".*"
1599
- }
1600
- ] }
1783
+ return [{
1784
+ name: "so1ve/yaml/setup",
1785
+ plugins: { yaml: pluginYaml }
1786
+ }, {
1787
+ name: "so1ve/yaml/rules",
1788
+ languageOptions: { parser: parserYaml },
1789
+ files: [GLOB_YAML],
1790
+ rules: {
1791
+ ...renameRules(pluginYaml.configs.prettier.rules, { yml: "yaml" }),
1792
+ ...renameRules(pluginYaml.configs.recommended.rules, { yml: "yaml" }),
1793
+ "style/spaced-comment": "off",
1794
+ "yaml/no-empty-document": "off",
1795
+ ...overrides
1601
1796
  }
1602
- ];
1797
+ }];
1603
1798
  }
1604
1799
 
1605
1800
  //#endregion
@@ -1632,13 +1827,17 @@ const defaultPluginRenaming = {
1632
1827
  * Construct an array of ESLint flat config items.
1633
1828
  */
1634
1829
  function so1ve(options = {}, ...userConfigs) {
1635
- const { astro: enableAstro = isPackageExists("astro"), componentExts = [], gitignore: enableGitignore = true, pnpm: enableCatalogs = false, solid: enableSolid = isPackageExists("solid-js"), typescript: enableTypeScript = isPackageExists("typescript"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
1830
+ const { astro: enableAstro = isPackageExists("astro"), componentExts = [], gitignore: enableGitignore = true, ignores: userIgnores = [], pnpm: enablePnpm = !!findUpSync("pnpm-workspace.yaml"), solid: enableSolid = isPackageExists("solid-js"), typescript: enableTypeScript = isPackageExists("typescript"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
1636
1831
  const configs = [];
1637
1832
  if (enableGitignore) if (typeof enableGitignore === "boolean") {
1638
1833
  if (fs.existsSync(".gitignore")) configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1639
1834
  } else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1640
- configs.push(ignores(), javascript({ overrides: getOverrides(options, "javascript") }), comments(), node(), onlyError(), promise(), sortImports(), imports(), unicorn(), command());
1641
- if (enableCatalogs) configs.push(pnpm());
1835
+ configs.push(ignores(userIgnores), javascript({ overrides: getOverrides(options, "javascript") }), comments(), node(), onlyError(), promise(), sortImports(), imports(), unicorn(), command());
1836
+ if (enablePnpm) configs.push(pnpm({
1837
+ json: options.jsonc !== false,
1838
+ yaml: options.yaml !== false,
1839
+ ...typeof enablePnpm === "boolean" ? {} : enablePnpm
1840
+ }));
1642
1841
  if (enableVue) componentExts.push("vue");
1643
1842
  if (options.html ?? true) configs.push(html());
1644
1843
  if (enableTypeScript) configs.push(typescript({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-config",
3
- "version": "3.22.2",
3
+ "version": "3.24.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "type": "module",
6
6
  "description": "Ray's eslint config.",
@@ -18,13 +18,12 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "exports": {
21
- ".": {
22
- "types": "./dist/index.d.ts",
23
- "import": "./dist/index.js"
24
- }
21
+ ".": "./dist/index.mjs",
22
+ "./package.json": "./package.json"
25
23
  },
26
- "module": "./dist/index.js",
27
- "types": "./dist/index.d.ts",
24
+ "main": "./dist/index.mjs",
25
+ "module": "./dist/index.mjs",
26
+ "types": "./dist/index.d.mts",
28
27
  "files": [
29
28
  "dist"
30
29
  ],
@@ -77,8 +76,11 @@
77
76
  "typescript-eslint": "^8.50.1",
78
77
  "vue-eslint-parser": "^10.2.0",
79
78
  "yaml-eslint-parser": "^1.3.2",
80
- "@so1ve/eslint-plugin": "3.22.2",
81
- "@so1ve/eslint-plugin-sort-imports": "3.22.2"
79
+ "@so1ve/eslint-plugin": "3.24.0",
80
+ "@so1ve/eslint-plugin-sort-imports": "3.24.0"
81
+ },
82
+ "devDependencies": {
83
+ "find-up-simple": "^1.0.1"
82
84
  },
83
85
  "peerDependencies": {
84
86
  "eslint": "^9.39.2",