From 242063dc74ea80c1a1d46a25a878c938cb746c26 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Thu, 11 Apr 2024 16:11:06 +0200 Subject: [PATCH] Fix Husky setup (#28636) Signed-off-by: Jon Koops --- js/.husky/pre-commit | 3 +-- js/lint-staged.config.js | 8 ++++++++ package.json | 7 ++----- 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 js/lint-staged.config.js diff --git a/js/.husky/pre-commit b/js/.husky/pre-commit index 96d2da1344..f96aca84fd 100755 --- a/js/.husky/pre-commit +++ b/js/.husky/pre-commit @@ -7,5 +7,4 @@ if [ ! -f "$FILE" ]; then exit 0; fi -cd js -pnpm exec lint-staged +ESLINT_USE_FLAT_CONFIG=true pnpm exec lint-staged diff --git a/js/lint-staged.config.js b/js/lint-staged.config.js new file mode 100644 index 0000000000..2bc705881e --- /dev/null +++ b/js/lint-staged.config.js @@ -0,0 +1,8 @@ +import path from "node:path"; + +const CONFIG_PATH = path.resolve(import.meta.dirname, "eslint.config.js"); + +export default { + "*.{js,jsx,mjs,ts,tsx}": (filenames) => + `eslint --config ${CONFIG_PATH} --cache --fix ${filenames.join(" ")}`, +}; diff --git a/package.json b/package.json index 33ea4c1795..5c2138a57c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "root", "type": "module", "scripts": { - "prepare": "cd .. && husky js/.husky" + "prepare": "husky js/.husky" }, "devDependencies": { "@eslint/eslintrc": "^3.0.2", @@ -24,8 +24,5 @@ "typescript-eslint": "^7.6.0", "wireit": "^0.14.4" }, - "packageManager": "pnpm@8.15.5", - "lint-staged": { - "*.{js,jsx,mjs,ts,tsx}": "eslint --cache --fix" - } + "packageManager": "pnpm@8.15.5" }