From 40245aacf90c87bbe69508976d5a29281dae23d8 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:58:54 +1100 Subject: [PATCH] Run pre-commit type check only for TypeScript (#1597) * Prevent unnecessary type-checks * Remove commented code --- .husky/pre-commit | 2 -- lint-staged.config.js | 13 +++++++++++++ package.json | 8 +------- 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 lint-staged.config.js diff --git a/.husky/pre-commit b/.husky/pre-commit index 5af23fe84..a19f49ff7 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,7 +1,5 @@ if [[ "$OS" == "Windows_NT" ]]; then npx.cmd lint-staged - npm.cmd run typecheck else npx lint-staged - npm run typecheck fi diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 000000000..05a79cffd --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,13 @@ +export default { + './**/*.js': (stagedFiles) => formatFiles(stagedFiles), + + './**/*.{ts,tsx,vue}': (stagedFiles) => [ + ...formatFiles(stagedFiles), + 'tsc --noEmit', + 'tsc-strict' + ] +} + +function formatFiles(fileNames) { + return [`prettier --write ${fileNames.join(' ')}`] +} diff --git a/package.json b/package.json index 4d2604b04..b6030d738 100644 --- a/package.json +++ b/package.json @@ -93,10 +93,4 @@ "vue-router": "^4.4.3", "zod": "^3.23.8", "zod-validation-error": "^3.3.0" - }, - "lint-staged": { - "./**/*.{js,ts,tsx,vue}": [ - "prettier --write" - ] - } -} + }}