From e5071a29a7c9b56d8fbfaaefed08089135ef7f4d Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 18 Aug 2026 23:42:55 -0700 Subject: [PATCH] chore: add lint-staged for staged-file linting Add lint-staged and a lint:staged script that runs eslint+stylelint on staged TS/TSX/CSS/SCSS only, faster than full pnpm lint. Point AGENTS.md at it for commit-time checks; typecheck stays CI-only. --- AGENTS.md | 2 +- package.json | 6 +++++ pnpm-lock.yaml | 65 +++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index dd42b9da0..af3d261a7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,7 +1,7 @@ ## General guidelines - Never use the em dash "—". Use plain dash "-" instead. -- Code changes are unfinished until `pnpm lint` passes. Use `pnpm lint:fix` to auto-fix what it can, then re-run `pnpm lint`. Skip when the turn did not modify code. +- On an explicit commit request: `git add` the changes, run `pnpm lint:staged`, then commit. It lints only staged TS/TSX/CSS/SCSS via eslint+stylelint and auto-fixes; typecheck runs in CI (`test.yml`), not locally. Do not stage or run it outside a commit request. ## Agent skills diff --git a/package.json b/package.json index 76ca76420..d556c7457 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "postinstall": "electron-builder install-app-deps", "lint": "pnpm run typecheck && pnpm run lint-code && pnpm run lint-styles", "lint:commits": "commitlint", + "lint:staged": "lint-staged", "lint:fix": "pnpm run lint-code:fix && pnpm run lint-styles:fix", "lint-code": "eslint --max-warnings=0 --cache .", "lint-code:fix": "eslint --cache --fix .", @@ -69,6 +70,10 @@ "version": "pnpm version --no-git-tag-version", "postversion": "node ./scripts/update-app-stream.mjs" }, + "lint-staged": { + "*.{ts,tsx}": "eslint --max-warnings=0 --fix", + "*.{css,scss}": "stylelint --max-warnings=0 --fix" + }, "resolutions": { "xml2js": "0.5.0" }, @@ -178,6 +183,7 @@ "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-refresh": "^0.4.26", "i18next-parser": "^9.4.0", + "lint-staged": "^17.3.0", "postcss-preset-mantine": "^1.18.0", "postcss-simple-vars": "^7.0.1", "prettier": "^3.8.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3417faa12..e4c16c1ff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -279,7 +279,7 @@ importers: version: 8.18.1 '@vitejs/plugin-react': specifier: ^5.2.0 - version: 5.2.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)) + version: 5.2.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0)) babel-plugin-react-compiler: specifier: ^1.0.0 version: 1.0.0 @@ -300,7 +300,7 @@ importers: version: 4.0.0 electron-vite: specifier: ^4.0.1 - version: 4.0.1(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)) + version: 4.0.1(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0)) eslint: specifier: ^9.39.4 version: 9.39.4(jiti@2.7.0) @@ -322,6 +322,9 @@ importers: i18next-parser: specifier: ^9.4.0 version: 9.4.0 + lint-staged: + specifier: ^17.3.0 + version: 17.3.0 postcss-preset-mantine: specifier: ^1.18.0 version: 1.18.0(postcss@8.5.15) @@ -351,7 +354,7 @@ importers: version: 5.9.3 vite: specifier: ^7.3.5 - version: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0) + version: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0) vite-plugin-conditional-import: specifier: ^0.1.7 version: 0.1.7 @@ -360,10 +363,10 @@ importers: version: 1.6.0 vite-plugin-ejs: specifier: ^1.7.0 - version: 1.7.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)) + version: 1.7.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0)) vite-plugin-pwa: specifier: ^1.3.0 - version: 1.3.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0))(workbox-build@7.4.1(@types/babel__core@7.20.5))(workbox-window@7.4.1) + version: 1.3.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0))(workbox-build@7.4.1(@types/babel__core@7.20.5))(workbox-window@7.4.1) packages: @@ -4148,6 +4151,11 @@ packages: lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} + lint-staged@17.3.0: + resolution: {integrity: sha512-woZS3vNe3UKqBaLPvbLOtKRY4tLANpWQhom12MGWqC8Mh1lCOO+WgSwmX2amjJAqTY9BkXYW87fCUH5H9Ph6xw==} + engines: {node: '>=22.22.1'} + hasBin: true + load-script@1.0.0: resolution: {integrity: sha512-kPEjMFtZvwL9TaZo0uZ2ml+Ye9HUMmPwbYRJ324qF9tqMejwykJ5ggTyvzmrbBeapCAbk98BSbTeovHEEP1uCA==} @@ -4585,6 +4593,10 @@ packages: resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} engines: {node: '>=12'} + picomatch@4.0.5: + resolution: {integrity: sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==} + engines: {node: '>=12'} + pkg-up@3.1.0: resolution: {integrity: sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==} engines: {node: '>=8'} @@ -5201,6 +5213,10 @@ packages: streamx@2.28.0: resolution: {integrity: sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==} + string-argv@0.3.2: + resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==} + engines: {node: '>=0.6.19'} + string-to-color@2.2.2: resolution: {integrity: sha512-XeA2goP7PNsSlz8RRn6KhYswnMf5Tl+38ajfy8n4oZJyMGC4qqKgHNHsZ/3qwvr42NRIjf9eSr721SyetDeMkA==} @@ -5882,6 +5898,11 @@ packages: resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} engines: {node: '>=18'} + yaml@2.9.0: + resolution: {integrity: sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==} + engines: {node: '>= 14.6'} + hasBin: true + yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} @@ -7993,7 +8014,7 @@ snapshots: '@typescript-eslint/types': 8.61.0 eslint-visitor-keys: 5.0.1 - '@vitejs/plugin-react@5.2.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0))': + '@vitejs/plugin-react@5.2.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0))': dependencies: '@babel/core': 7.29.7 '@babel/plugin-transform-react-jsx-self': 7.29.7(@babel/core@7.29.7) @@ -8001,7 +8022,7 @@ snapshots: '@rolldown/pluginutils': 1.0.0-rc.3 '@types/babel__core': 7.20.5 react-refresh: 0.18.0 - vite: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0) + vite: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0) transitivePeerDependencies: - supports-color @@ -8903,7 +8924,7 @@ snapshots: transitivePeerDependencies: - supports-color - electron-vite@4.0.1(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)): + electron-vite@4.0.1(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0)): dependencies: '@babel/core': 7.29.7 '@babel/plugin-transform-arrow-functions': 7.29.7(@babel/core@7.29.7) @@ -8911,7 +8932,7 @@ snapshots: esbuild: 0.25.12 magic-string: 0.30.21 picocolors: 1.1.1 - vite: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0) + vite: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0) transitivePeerDependencies: - supports-color @@ -10132,6 +10153,14 @@ snapshots: lines-and-columns@1.2.4: {} + lint-staged@17.3.0: + dependencies: + picomatch: 4.0.5 + string-argv: 0.3.2 + tinyexec: 1.3.0 + optionalDependencies: + yaml: 2.9.0 + load-script@1.0.0: {} locate-path@3.0.0: @@ -10531,6 +10560,8 @@ snapshots: picomatch@4.0.4: {} + picomatch@4.0.5: {} + pkg-up@3.1.0: dependencies: find-up: 3.0.0 @@ -11175,6 +11206,8 @@ snapshots: - bare-abort-controller - react-native-b4a + string-argv@0.3.2: {} + string-to-color@2.2.2: dependencies: colornames: 1.1.1 @@ -11747,23 +11780,23 @@ snapshots: fast-glob: 3.3.3 magic-string: 0.30.21 - vite-plugin-ejs@1.7.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)): + vite-plugin-ejs@1.7.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0)): dependencies: ejs: 3.1.10 - vite: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0) + vite: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0) - vite-plugin-pwa@1.3.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0))(workbox-build@7.4.1(@types/babel__core@7.20.5))(workbox-window@7.4.1): + vite-plugin-pwa@1.3.0(vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0))(workbox-build@7.4.1(@types/babel__core@7.20.5))(workbox-window@7.4.1): dependencies: debug: 4.4.3 pretty-bytes: 6.1.1 tinyglobby: 0.2.17 - vite: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0) + vite: 7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0) workbox-build: 7.4.1(@types/babel__core@7.20.5) workbox-window: 7.4.1 transitivePeerDependencies: - supports-color - vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0): + vite@7.3.5(@types/node@24.13.2)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.9.0): dependencies: esbuild: 0.27.7 fdir: 6.5.0(picomatch@4.0.4) @@ -11777,6 +11810,7 @@ snapshots: jiti: 2.7.0 sugarss: 5.0.1(postcss@8.5.15) terser: 5.48.0 + yaml: 2.9.0 void-elements@3.1.0: {} @@ -12035,6 +12069,9 @@ snapshots: yallist@5.0.0: {} + yaml@2.9.0: + optional: true + yargs-parser@21.1.1: {} yargs-parser@22.0.0: {}