瀏覽代碼

feat: lint add pnpm config

xingyu4j 6 月之前
父節點
當前提交
f77216d8f4

+ 1 - 0
internal/lint-configs/eslint-config/package.json

@@ -43,6 +43,7 @@
     "eslint-plugin-n": "catalog:",
     "eslint-plugin-no-only-tests": "catalog:",
     "eslint-plugin-perfectionist": "catalog:",
+    "eslint-plugin-pnpm": "catalog:",
     "eslint-plugin-prettier": "catalog:",
     "eslint-plugin-regexp": "catalog:",
     "eslint-plugin-unicorn": "catalog:",

+ 1 - 0
internal/lint-configs/eslint-config/src/configs/index.ts

@@ -8,6 +8,7 @@ export * from './jsdoc';
 export * from './jsonc';
 export * from './node';
 export * from './perfectionist';
+export * from './pnpm';
 export * from './prettier';
 export * from './regexp';
 export * from './test';

+ 41 - 0
internal/lint-configs/eslint-config/src/configs/pnpm.ts

@@ -0,0 +1,41 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function pnpm(): Promise<Linter.Config[]> {
+  const [pluginPnpm, parserPnpm, parserJsonc] = await Promise.all([
+    interopDefault(import('eslint-plugin-pnpm')),
+    interopDefault(import('yaml-eslint-parser')),
+    interopDefault(import('jsonc-eslint-parser')),
+  ] as const);
+
+  return [
+    {
+      files: ['package.json', '**/package.json'],
+      languageOptions: {
+        parser: parserJsonc,
+      },
+      plugins: {
+        pnpm: pluginPnpm,
+      },
+      rules: {
+        'pnpm/json-enforce-catalog': 'error',
+        'pnpm/json-prefer-workspace-settings': 'error',
+        'pnpm/json-valid-catalog': 'error',
+      },
+    },
+    {
+      files: ['pnpm-workspace.yaml'],
+      languageOptions: {
+        parser: parserPnpm,
+      },
+      plugins: {
+        pnpm: pluginPnpm,
+      },
+      rules: {
+        'pnpm/yaml-no-duplicate-catalog-item': 'error',
+        'pnpm/yaml-no-unused-catalog-item': 'error',
+      },
+    },
+  ];
+}

+ 2 - 0
internal/lint-configs/eslint-config/src/index.ts

@@ -11,6 +11,7 @@ import {
   jsonc,
   node,
   perfectionist,
+  pnpm,
   prettier,
   regexp,
   test,
@@ -50,6 +51,7 @@ async function defineConfig(config: FlatConfig[] = []) {
     command(),
     turbo(),
     yaml(),
+    pnpm(),
     ...customConfig,
     ...config,
   ];

+ 1 - 21
package.json

@@ -100,25 +100,5 @@
     "node": ">=20.12.0",
     "pnpm": ">=10.0.0"
   },
-  "packageManager": "pnpm@10.22.0",
-  "pnpm": {
-    "peerDependencyRules": {
-      "allowedVersions": {
-        "eslint": "*"
-      }
-    },
-    "overrides": {
-      "@ast-grep/napi": "catalog:",
-      "@ctrl/tinycolor": "catalog:",
-      "clsx": "catalog:",
-      "esbuild": "0.25.3",
-      "jiti": "catalog:",
-      "pinia": "catalog:",
-      "vue": "catalog:"
-    },
-    "neverBuiltDependencies": [
-      "canvas",
-      "node-gyp"
-    ]
-  }
+  "packageManager": "pnpm@10.22.0"
 }

+ 34 - 0
pnpm-lock.yaml

@@ -255,6 +255,9 @@ catalogs:
     eslint-plugin-perfectionist:
       specifier: ^4.15.1
       version: 4.15.1
+    eslint-plugin-pnpm:
+      specifier: ^1.3.0
+      version: 1.3.0
     eslint-plugin-prettier:
       specifier: ^5.5.4
       version: 5.5.4
@@ -1026,6 +1029,9 @@ importers:
       eslint-plugin-perfectionist:
         specifier: 'catalog:'
         version: 4.15.1(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3)
+      eslint-plugin-pnpm:
+        specifier: 'catalog:'
+        version: 1.3.0(eslint@9.39.1(jiti@2.6.1))
       eslint-plugin-prettier:
         specifier: 'catalog:'
         version: 5.5.4(@types/eslint@9.6.1)(eslint@9.39.1(jiti@2.6.1))(prettier@3.7.4)
@@ -6213,6 +6219,10 @@ packages:
   emoji-regex@9.2.2:
     resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
 
+  empathic@2.0.0:
+    resolution: {integrity: sha512-i6UzDscO/XfAcNYD75CfICkmfLedpyPDdozrLMmQc5ORaQcdMoc21OnlEylMIqI7U8eniKrPMxxtj8k0vhmJhA==}
+    engines: {node: '>=14'}
+
   encodeurl@2.0.0:
     resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==}
     engines: {node: '>= 0.8'}
@@ -6423,6 +6433,11 @@ packages:
     peerDependencies:
       eslint: '>=8.45.0'
 
+  eslint-plugin-pnpm@1.3.0:
+    resolution: {integrity: sha512-Lkdnj3afoeUIkDUu8X74z60nrzjQ2U55EbOeI+qz7H1He4IO4gmUKT2KQIl0It52iMHJeuyLDWWNgjr6UIK8nw==}
+    peerDependencies:
+      eslint: ^9.0.0
+
   eslint-plugin-prettier@5.5.4:
     resolution: {integrity: sha512-swNtI95SToIz05YINMA6Ox5R057IMAmWZ26GqPxusAp1TZzj+IdY9tXNWWD3vkF/wEqydCONcwjTFpxybBqZsg==}
     engines: {node: ^14.18.0 || >=16.0.0}
@@ -8449,6 +8464,9 @@ packages:
     resolution: {integrity: sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==}
     engines: {node: '>=10.13.0'}
 
+  pnpm-workspace-yaml@1.3.0:
+    resolution: {integrity: sha512-Krb5q8Totd5mVuLx7we+EFHq/AfxA75nbfTm25Q1pIf606+RlaKUG+PXH8SDihfe5b5k4H09gE+sL47L1t5lbw==}
+
   popmotion@11.0.5:
     resolution: {integrity: sha512-la8gPM1WYeFznb/JqF4GiTkRRPZsfaj2+kCxqQgr2MJylMmIKUwBfWW8Wa5fml/8gmtlD5yI01MP1QCZPWmppA==}
 
@@ -15521,6 +15539,8 @@ snapshots:
 
   emoji-regex@9.2.2: {}
 
+  empathic@2.0.0: {}
+
   encodeurl@2.0.0: {}
 
   encoding-sniffer@0.2.1:
@@ -15819,6 +15839,16 @@ snapshots:
       - supports-color
       - typescript
 
+  eslint-plugin-pnpm@1.3.0(eslint@9.39.1(jiti@2.6.1)):
+    dependencies:
+      empathic: 2.0.0
+      eslint: 9.39.1(jiti@2.6.1)
+      jsonc-eslint-parser: 2.4.1
+      pathe: 2.0.3
+      pnpm-workspace-yaml: 1.3.0
+      tinyglobby: 0.2.15
+      yaml-eslint-parser: 1.3.1
+
   eslint-plugin-prettier@5.5.4(@types/eslint@9.6.1)(eslint@9.39.1(jiti@2.6.1))(prettier@3.7.4):
     dependencies:
       eslint: 9.39.1(jiti@2.6.1)
@@ -17940,6 +17970,10 @@ snapshots:
 
   pngjs@5.0.0: {}
 
+  pnpm-workspace-yaml@1.3.0:
+    dependencies:
+      yaml: 2.8.2
+
   popmotion@11.0.5:
     dependencies:
       framesync: 6.1.2

+ 16 - 0
pnpm-workspace.yaml

@@ -1,3 +1,6 @@
+neverBuiltDependencies:
+  - canvas
+  - node-gyp
 packages:
   - internal/*
   - internal/lint-configs/*
@@ -101,6 +104,7 @@ catalog:
   eslint-plugin-n: ^17.23.1
   eslint-plugin-no-only-tests: ^3.3.0
   eslint-plugin-perfectionist: ^4.15.1
+  eslint-plugin-pnpm: ^1.3.0
   eslint-plugin-prettier: ^5.5.4
   eslint-plugin-regexp: ^2.10.0
   eslint-plugin-unicorn: ^62.0.0
@@ -197,3 +201,15 @@ catalog:
   yaml-eslint-parser: ^1.3.1
   zod: ^3.25.67
   zod-defaults: 0.1.3
+  esbuild: 0.25.3
+peerDependencyRules:
+  allowedVersions:
+    eslint: '*'
+overrides:
+  '@ast-grep/napi': 'catalog:'
+  '@ctrl/tinycolor': 'catalog:'
+  clsx: 'catalog:'
+  esbuild: 'catalog:'
+  jiti: 'catalog:'
+  pinia: 'catalog:'
+  vue: 'catalog:'