@coderwyd/eslint-config 4.7.2 → 4.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- import process from "node:process";
2
1
  import createCommand from "eslint-plugin-command/config";
3
2
  import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
4
3
  import pluginAntfu from "eslint-plugin-antfu";
@@ -7,6 +6,7 @@ import pluginNode from "eslint-plugin-n";
7
6
  import pluginPerfectionist from "eslint-plugin-perfectionist";
8
7
  import pluginUnicorn from "eslint-plugin-unicorn";
9
8
  import pluginUnusedImports from "eslint-plugin-unused-imports";
9
+ import process from "node:process";
10
10
  import { fileURLToPath } from "node:url";
11
11
  import { getPackageInfoSync, isPackageExists } from "local-pkg";
12
12
  import globals from "globals";
@@ -246,10 +246,10 @@ function javascript(options = {}) {
246
246
  const { isInEditor: isInEditor$1 = false, overrides = {} } = options;
247
247
  return [{
248
248
  languageOptions: {
249
- ecmaVersion: 2022,
249
+ ecmaVersion: "latest",
250
250
  globals: {
251
251
  ...globals.browser,
252
- ...globals.es2021,
252
+ ...globals.es2026,
253
253
  ...globals.node,
254
254
  document: "readonly",
255
255
  navigator: "readonly",
@@ -257,7 +257,7 @@ function javascript(options = {}) {
257
257
  },
258
258
  parserOptions: {
259
259
  ecmaFeatures: { jsx: true },
260
- ecmaVersion: 2022,
260
+ ecmaVersion: "latest",
261
261
  sourceType: "module"
262
262
  },
263
263
  sourceType: "module"
@@ -602,19 +602,51 @@ function perfectionist() {
602
602
  type: "natural"
603
603
  }],
604
604
  "perfectionist/sort-named-exports": ["warn", {
605
- groupKind: "values-first",
606
- order: "asc",
605
+ groups: ["value-export", "type-export"],
607
606
  type: "natural"
608
607
  }],
609
608
  "perfectionist/sort-named-imports": ["warn", {
610
- groupKind: "values-first",
611
- order: "asc",
609
+ groups: ["value-import", "type-import"],
612
610
  type: "natural"
613
611
  }]
614
612
  }
615
613
  }];
616
614
  }
617
615
 
616
+ //#endregion
617
+ //#region src/configs/pnpm.ts
618
+ async function pnpm() {
619
+ const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
620
+ interopDefault(import("eslint-plugin-pnpm")),
621
+ interopDefault(import("yaml-eslint-parser")),
622
+ interopDefault(import("jsonc-eslint-parser"))
623
+ ]);
624
+ return [{
625
+ files: ["package.json", "**/package.json"],
626
+ languageOptions: { parser: jsoncParser },
627
+ name: "coderwyd/pnpm/package-json",
628
+ plugins: { pnpm: pluginPnpm },
629
+ rules: {
630
+ "pnpm/json-enforce-catalog": "error",
631
+ "pnpm/json-prefer-workspace-settings": "error",
632
+ "pnpm/json-valid-catalog": "error"
633
+ }
634
+ }, {
635
+ files: ["pnpm-workspace.yaml"],
636
+ languageOptions: { parser: yamlParser },
637
+ name: "coderwyd/pnpm/pnpm-workspace-yaml",
638
+ plugins: { pnpm: pluginPnpm },
639
+ rules: {
640
+ "pnpm/yaml-enforce-settings": ["error", { settings: {
641
+ shellEmulator: true,
642
+ trustPolicy: "no-downgrade"
643
+ } }],
644
+ "pnpm/yaml-no-duplicate-catalog-item": "error",
645
+ "pnpm/yaml-no-unused-catalog-item": "error"
646
+ }
647
+ }];
648
+ }
649
+
618
650
  //#endregion
619
651
  //#region src/configs/prettier.ts
620
652
  const { rules: eslintRules } = prettierRules;
@@ -848,6 +880,7 @@ function sortPackageJson() {
848
880
  "packageManager",
849
881
  "description",
850
882
  "author",
883
+ "contributors",
851
884
  "license",
852
885
  "funding",
853
886
  "homepage",
@@ -883,7 +916,9 @@ function sortPackageJson() {
883
916
  "simple-git-hooks",
884
917
  "lint-staged",
885
918
  "nano-staged",
886
- "eslintConfig"
919
+ "eslintConfig",
920
+ "prettier",
921
+ "tsdown"
887
922
  ],
888
923
  pathPattern: "^$"
889
924
  },
@@ -893,7 +928,7 @@ function sortPackageJson() {
893
928
  },
894
929
  {
895
930
  order: { type: "asc" },
896
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
931
+ pathPattern: String.raw`^(?:resolutions|overrides|pnpm\.overrides)$`
897
932
  },
898
933
  {
899
934
  order: [
@@ -1044,6 +1079,84 @@ function sortTsconfig() {
1044
1079
  ] }
1045
1080
  }];
1046
1081
  }
1082
+ function sortPnpmWorkspace() {
1083
+ return [{
1084
+ files: ["**/pnpm-workspace.yaml"],
1085
+ name: "coderwyd/sort/pnpm-workspace",
1086
+ rules: { "yaml/sort-keys": [
1087
+ "error",
1088
+ {
1089
+ order: [
1090
+ ...[
1091
+ "cacheDir",
1092
+ "catalogMode",
1093
+ "cleanupUnusedCatalogs",
1094
+ "dedupeDirectDeps",
1095
+ "deployAllFiles",
1096
+ "enablePrePostScripts",
1097
+ "engineStrict",
1098
+ "extendNodePath",
1099
+ "hoist",
1100
+ "hoistPattern",
1101
+ "hoistWorkspacePackages",
1102
+ "ignoreCompatibilityDb",
1103
+ "ignoreDepScripts",
1104
+ "ignoreScripts",
1105
+ "ignoreWorkspaceRootCheck",
1106
+ "managePackageManagerVersions",
1107
+ "minimumReleaseAge",
1108
+ "minimumReleaseAgeExclude",
1109
+ "modulesDir",
1110
+ "nodeLinker",
1111
+ "nodeVersion",
1112
+ "optimisticRepeatInstall",
1113
+ "packageManagerStrict",
1114
+ "packageManagerStrictVersion",
1115
+ "preferSymlinkedExecutables",
1116
+ "preferWorkspacePackages",
1117
+ "publicHoistPattern",
1118
+ "registrySupportsTimeField",
1119
+ "requiredScripts",
1120
+ "resolutionMode",
1121
+ "savePrefix",
1122
+ "scriptShell",
1123
+ "shamefullyHoist",
1124
+ "shellEmulator",
1125
+ "stateDir",
1126
+ "supportedArchitectures",
1127
+ "symlink",
1128
+ "tag",
1129
+ "trustPolicy",
1130
+ "trustPolicyExclude",
1131
+ "updateNotifier"
1132
+ ],
1133
+ "packages",
1134
+ "overrides",
1135
+ "patchedDependencies",
1136
+ "catalog",
1137
+ "catalogs",
1138
+ ...[
1139
+ "allowedDeprecatedVersions",
1140
+ "allowNonAppliedPatches",
1141
+ "configDependencies",
1142
+ "ignoredBuiltDependencies",
1143
+ "ignoredOptionalDependencies",
1144
+ "neverBuiltDependencies",
1145
+ "onlyBuiltDependencies",
1146
+ "onlyBuiltDependenciesFile",
1147
+ "packageExtensions",
1148
+ "peerDependencyRules"
1149
+ ]
1150
+ ],
1151
+ pathPattern: "^$"
1152
+ },
1153
+ {
1154
+ order: { type: "asc" },
1155
+ pathPattern: ".*"
1156
+ }
1157
+ ] }
1158
+ }];
1159
+ }
1047
1160
 
1048
1161
  //#endregion
1049
1162
  //#region src/configs/specials.ts
@@ -1397,6 +1510,7 @@ function unicorn(options = {}) {
1397
1510
  "unicorn/no-console-spaces": "error",
1398
1511
  "unicorn/no-for-loop": "error",
1399
1512
  "unicorn/no-hex-escape": "error",
1513
+ "unicorn/no-immediate-mutation": "error",
1400
1514
  "unicorn/no-instanceof-builtins": "error",
1401
1515
  "unicorn/no-invalid-remove-event-listener": "error",
1402
1516
  "unicorn/no-lonely-if": "error",
@@ -1409,6 +1523,8 @@ function unicorn(options = {}) {
1409
1523
  "unicorn/no-unnecessary-array-splice-count": "error",
1410
1524
  "unicorn/no-unnecessary-await": "error",
1411
1525
  "unicorn/no-unnecessary-slice-end": "error",
1526
+ "unicorn/no-useless-collection-argument": "error",
1527
+ "unicorn/no-useless-error-capture-stack-trace": "error",
1412
1528
  "unicorn/no-zero-fractions": "error",
1413
1529
  "unicorn/prefer-add-event-listener": "error",
1414
1530
  "unicorn/prefer-array-find": "error",
@@ -1416,8 +1532,10 @@ function unicorn(options = {}) {
1416
1532
  "unicorn/prefer-array-index-of": "error",
1417
1533
  "unicorn/prefer-array-some": "error",
1418
1534
  "unicorn/prefer-at": "error",
1535
+ "unicorn/prefer-bigint-literals": "error",
1419
1536
  "unicorn/prefer-blob-reading-methods": "error",
1420
1537
  "unicorn/prefer-class-fields": "error",
1538
+ "unicorn/prefer-classlist-toggle": "error",
1421
1539
  "unicorn/prefer-date-now": "error",
1422
1540
  "unicorn/prefer-dom-node-append": "error",
1423
1541
  "unicorn/prefer-dom-node-dataset": "error",
@@ -1436,12 +1554,15 @@ function unicorn(options = {}) {
1436
1554
  "unicorn/prefer-prototype-methods": "error",
1437
1555
  "unicorn/prefer-query-selector": "error",
1438
1556
  "unicorn/prefer-reflect-apply": "error",
1557
+ "unicorn/prefer-response-static-json": "error",
1439
1558
  "unicorn/prefer-single-call": "error",
1440
1559
  "unicorn/prefer-string-replace-all": "error",
1441
1560
  "unicorn/prefer-string-slice": "error",
1442
1561
  "unicorn/prefer-string-starts-ends-with": "error",
1443
1562
  "unicorn/prefer-string-trim-start-end": "error",
1444
1563
  "unicorn/prefer-type-error": "error",
1564
+ "unicorn/require-module-attributes": "error",
1565
+ "unicorn/require-module-specifiers": "error",
1445
1566
  "unicorn/throw-new-error": "error",
1446
1567
  ...overrides
1447
1568
  }
@@ -1687,7 +1808,7 @@ const defaultPluginRenaming = {
1687
1808
  * The merged ESLint configurations.
1688
1809
  */
1689
1810
  async function defineConfig(options = {}, ...userConfigs) {
1690
- const { autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, react: enableReact = false, regexp: enableRegexp = true, svelte: enableSvelte = false, tailwindcss: enableTailwindCSS = false, typescript: enableTypeScript = isUsingTypeScript, unocss: enableUnoCSS = false, vue: enableVue = isUsingVue } = options;
1811
+ const { autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, pnpm: enableCatalogs = false, react: enableReact = false, regexp: enableRegexp = true, svelte: enableSvelte = false, tailwindcss: enableTailwindCSS = false, typescript: enableTypeScript = isUsingTypeScript, unocss: enableUnoCSS = false, vue: enableVue = isUsingVue } = options;
1691
1812
  let isInEditor$1 = options.isInEditor;
1692
1813
  if (isInEditor$1 == null) {
1693
1814
  isInEditor$1 = isInEditorEnv();
@@ -1707,7 +1828,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1707
1828
  configs$1.push(ignores(options.ignores), javascript({
1708
1829
  isInEditor: isInEditor$1,
1709
1830
  overrides: getOverrides(options, "javascript")
1710
- }), comments(), node(), jsdoc(), imports(), unicorn(), command(), deMorgan(), perfectionist());
1831
+ }), comments(), node(), jsdoc(), imports(), unicorn(), command(), deMorgan(), perfectionist(), sortPnpmWorkspace());
1711
1832
  if (enableVue) componentExts.push("vue");
1712
1833
  if (enableTypeScript) configs$1.push(typescript({
1713
1834
  ...typescriptOptions,
@@ -1741,6 +1862,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1741
1862
  overrides: getOverrides(options, "tailwindcss")
1742
1863
  }));
1743
1864
  if (options.jsonc ?? true) configs$1.push(jsonc({ overrides: getOverrides(options, "jsonc") }), sortPackageJson(), sortTsconfig());
1865
+ if (enableCatalogs) configs$1.push(pnpm());
1744
1866
  if (options.yaml ?? true) configs$1.push(yaml({ overrides: getOverrides(options, "yaml") }));
1745
1867
  configs$1.push(specials(), prettier());
1746
1868
  if ("files" in options) 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.");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderwyd/eslint-config",
3
3
  "type": "module",
4
- "version": "4.7.2",
4
+ "version": "4.9.1",
5
5
  "description": "Donny's ESLint config",
6
6
  "author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
7
7
  "license": "MIT",
@@ -21,13 +21,13 @@
21
21
  "access": "public"
22
22
  },
23
23
  "exports": {
24
- ".": "./dist/index.js",
25
- "./cli": "./dist/cli.js",
24
+ ".": "./dist/index.mjs",
25
+ "./cli": "./dist/cli.mjs",
26
26
  "./package.json": "./package.json"
27
27
  },
28
- "main": "./dist/index.js",
29
- "module": "./dist/index.js",
30
- "types": "./dist/index.d.ts",
28
+ "main": "./dist/index.mjs",
29
+ "module": "./dist/index.mjs",
30
+ "types": "./dist/index.d.mts",
31
31
  "bin": "./bin/index.js",
32
32
  "files": [
33
33
  "bin",
@@ -37,7 +37,7 @@
37
37
  "node": ">=18.18.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@eslint-react/eslint-plugin": "^1.5.8",
40
+ "@eslint-react/eslint-plugin": "^1.5.8 || ^2.0.0",
41
41
  "@unocss/eslint-plugin": ">=0.50.0",
42
42
  "eslint": "^9.5.0",
43
43
  "eslint-plugin-react-hooks": "^4.6.0 || ^5.0.0 || ^7.0.0",
@@ -75,60 +75,59 @@
75
75
  "dependencies": {
76
76
  "@antfu/install-pkg": "^1.1.0",
77
77
  "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
78
- "@typescript-eslint/eslint-plugin": "^8.46.1",
79
- "@typescript-eslint/parser": "^8.46.1",
80
- "@vitest/eslint-plugin": "^1.3.20",
78
+ "@typescript-eslint/eslint-plugin": "^8.52.0",
79
+ "@typescript-eslint/parser": "^8.52.0",
80
+ "@vitest/eslint-plugin": "^1.6.5",
81
+ "cac": "^6.7.14",
81
82
  "eslint-config-flat-gitignore": "^2.1.0",
82
83
  "eslint-config-prettier": "^10.1.8",
83
- "eslint-plugin-antfu": "^3.1.1",
84
- "eslint-plugin-command": "^3.3.1",
84
+ "eslint-plugin-antfu": "^3.1.3",
85
+ "eslint-plugin-command": "^3.4.0",
85
86
  "eslint-plugin-de-morgan": "^2.0.0",
86
- "eslint-plugin-import-lite": "^0.3.0",
87
- "eslint-plugin-jsdoc": "61.1.2",
87
+ "eslint-plugin-import-lite": "^0.5.0",
88
+ "eslint-plugin-jsdoc": "61.4.1",
88
89
  "eslint-plugin-jsonc": "^2.21.0",
89
90
  "eslint-plugin-n": "^17.23.1",
90
91
  "eslint-plugin-no-only-tests": "^3.3.0",
91
- "eslint-plugin-perfectionist": "^4.15.1",
92
+ "eslint-plugin-perfectionist": "^5.3.0",
93
+ "eslint-plugin-pnpm": "^1.4.3",
92
94
  "eslint-plugin-regexp": "^2.10.0",
93
- "eslint-plugin-unicorn": "^61.0.2",
94
- "eslint-plugin-unused-imports": "^4.2.0",
95
- "eslint-plugin-vue": "^10.5.0",
96
- "eslint-plugin-yml": "^1.19.0",
97
- "globals": "^16.4.0",
98
- "jsonc-eslint-parser": "^2.4.1",
95
+ "eslint-plugin-unicorn": "^62.0.0",
96
+ "eslint-plugin-unused-imports": "^4.3.0",
97
+ "eslint-plugin-vue": "^10.6.2",
98
+ "eslint-plugin-yml": "^1.19.1",
99
+ "globals": "^17.0.0",
100
+ "jsonc-eslint-parser": "^2.4.2",
99
101
  "local-pkg": "^1.1.2",
100
102
  "parse-gitignore": "^2.0.0",
101
103
  "prompts": "^2.4.2",
102
104
  "vue-eslint-parser": "^10.2.0",
103
- "yaml-eslint-parser": "^1.3.0",
104
- "yargs": "^18.0.0"
105
+ "yaml-eslint-parser": "^1.3.2"
105
106
  },
106
107
  "devDependencies": {
107
- "@antfu/ni": "^26.1.0",
108
- "@eslint-react/eslint-plugin": "^2.2.2",
109
- "@eslint/config-inspector": "^1.3.0",
108
+ "@eslint-react/eslint-plugin": "^2.5.1",
109
+ "@eslint/config-inspector": "^1.4.2",
110
110
  "@types/eslint-config-prettier": "^6.11.3",
111
- "@types/node": "^24.7.2",
111
+ "@types/node": "^25.0.3",
112
112
  "@types/prompts": "^2.4.9",
113
- "@types/yargs": "^17.0.33",
114
- "@unocss/eslint-plugin": "^66.5.3",
115
- "bumpp": "^10.3.1",
116
- "eslint": "^9.37.0",
117
- "eslint-plugin-react-hooks": "7.0.0",
118
- "eslint-plugin-react-refresh": "^0.4.23",
119
- "eslint-plugin-svelte": "^3.12.4",
113
+ "@typescript/native-preview": "7.0.0-dev.20260107.1",
114
+ "@unocss/eslint-plugin": "^66.5.12",
115
+ "bumpp": "^10.3.2",
116
+ "eslint": "^9.39.2",
117
+ "eslint-plugin-react-hooks": "7.0.1",
118
+ "eslint-plugin-react-refresh": "^0.4.26",
119
+ "eslint-plugin-svelte": "^3.13.1",
120
120
  "eslint-plugin-tailwindcss": "^3.18.2",
121
121
  "eslint-typegen": "^2.3.0",
122
122
  "jiti": "^2.6.1",
123
- "nano-staged": "^0.8.0",
124
- "prettier": "^3.6.2",
125
- "publint": "^0.3.14",
123
+ "nano-staged": "^0.9.0",
124
+ "prettier": "^3.7.4",
125
+ "publint": "^0.3.16",
126
126
  "simple-git-hooks": "^2.13.1",
127
- "svelte": "^5.40.0",
128
- "svelte-eslint-parser": "^1.3.3",
129
- "tsdown": "^0.15.7",
127
+ "svelte-eslint-parser": "^1.4.1",
128
+ "tsdown": "^0.18.4",
130
129
  "typescript": "^5.9.3",
131
- "unplugin-unused": "^0.5.4"
130
+ "unplugin-unused": "^0.5.6"
132
131
  },
133
132
  "simple-git-hooks": {
134
133
  "pre-commit": "pnpm exec nano-staged"
@@ -137,13 +136,13 @@
137
136
  "*": "eslint --fix"
138
137
  },
139
138
  "scripts": {
140
- "build": "nr build:typegen && tsdown",
139
+ "build": "pnpm build:typegen && tsdown",
141
140
  "dev": "pnpx @eslint/config-inspector",
142
141
  "lint": "eslint .",
143
142
  "lint:fix": "eslint . --fix",
144
143
  "build:inspector": "pnpm build && pnpx @eslint/config-inspector build",
145
144
  "build:typegen": "jiti scripts/typegen.ts",
146
145
  "release": "bumpp",
147
- "typecheck": "tsc --noEmit"
146
+ "typecheck": "tsgo --noEmit"
148
147
  }
149
148
  }
File without changes