From e6f79f73eac4d3d44399dd983ee691a9f0848124 Mon Sep 17 00:00:00 2001 From: David LJ Date: Mon, 11 Nov 2024 21:49:23 +0100 Subject: [PATCH] build: run linter on changed files in pre-commit hook (#815) --- .lintstagedrc.json | 4 +++- angular.json | 7 +------ package.json | 6 ++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.lintstagedrc.json b/.lintstagedrc.json index b49eccda..b480b3c6 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,3 +1,5 @@ { - "*": "pnpm run format" + "!*.{html,ts,mts,json}": ["pnpm run format"], + "**/*.{html,ts,mts,json}": ["pnpm run lint:code:raw", "pnpm run format"], + ".github/**/*.y?(a)ml": ["pnpm run lint:gh-actions"] } diff --git a/angular.json b/angular.json index def4c439..befde021 100644 --- a/angular.json +++ b/angular.json @@ -174,12 +174,7 @@ "lint": { "builder": "@angular-eslint/builder:lint", "options": { - "lintFilePatterns": [ - "src/**/*.{html,ts,json}", - "cypress/**/*.{ts,json}", - "scripts/**/*.{mts,ts,json}", - "*.json" - ], + "lintFilePatterns": ["."], "maxWarnings": 0 } } diff --git a/package.json b/package.json index c3ef8356..1b842325 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,10 @@ "format:check-all": "pnpm run format-check .", "git-hooks": "husky", "lighthouseci": "lhci autorun", - "lint": "pnpm run '/^lint:.*/'", - "lint:code": "ng lint --max-warnings 0", + "lint": "pnpm run '/^lint:[\\w-]*$/'", + "lint:code": "pnpm run lint:code:raw .", + "lint:code:raw": "eslint --max-warnings 0", + "lint:code:raw//": "☝️ lint-staged can't/shouldn't use 'ng lint'", "lint:commit-message": "pnpm run commitlint:edit-msg", "lint:gh-actions": "actionlint || true", "prebuild:font-subsets": "tsm scripts/src/generate-font-subsets.ts",