From 4bad1a258fc06d2f447437ede4e1f4f061b19f20 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 14 Jan 2025 14:18:09 -0800 Subject: [PATCH] chore: add eslint to pre-commit hooks (#31845) --- .github/workflows/pre-commit.yml | 2 ++ .pre-commit-config.yaml | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 640468d2a216f..f3044353f7637 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -41,6 +41,8 @@ jobs: - name: pre-commit run: | set +e # Don't exit immediately on failure + # Skip eslint as it requires `npm ci` and is executed in another job + export SKIP=eslint pre-commit run --all-files if [ $? -ne 0 ] || ! git diff --quiet --exit-code; then echo "❌ Pre-commit check failed." diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4361616527e1..bb34ee4055280 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,6 +52,14 @@ repos: - id: trailing-whitespace exclude: ^.*\.(snap) args: ["--markdown-linebreak-ext=md"] + - repo: local + hooks: + - id: eslint + name: eslint + entry: bash -c 'cd superset-frontend && npm run eslint -- $(echo "$@" | sed "s|superset-frontend/||g")' + language: system + pass_filenames: true + files: \.(js|jsx|ts|tsx)$ - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 # Use the sha or tag you want to point at hooks: