Skip to content

Commit 1b57a1d

Browse files
committed
chore: add eslint to pre-commit hooks
Chiseling at #31590 and bringing what's atomically committable out of there. This simply adds eslint checks to pre-commit. Note that: - it requires having run `npm i` in superset-frontend - it's set up to NOT run in CI as part of the pre-commit validation workflow, since we run eslint more formally in another workflow Why doing this? Currently it's common to forget to run `npm run lint` prior to committing/pushing, so people can waste time waiting for CI to fail where it could be caught easily. It's nice to have pre-commit do the check itself because it will only evaluate the files that have changed, making it much faster than running a full lint run against all files.
1 parent ef57318 commit 1b57a1d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: .github/workflows/pre-commit.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-24.04
1919
strategy:
2020
matrix:
21-
python-version: ["current", "previous"]
21+
python-version: ["current", "next", "previous"]
2222
steps:
2323
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
2424
uses: actions/checkout@v4
@@ -41,6 +41,8 @@ jobs:
4141
- name: pre-commit
4242
run: |
4343
set +e # Don't exit immediately on failure
44+
# Skip eslint as it requires `npm ci` and is executed in another job
45+
export SKIP=eslint
4446
pre-commit run --all-files
4547
if [ $? -ne 0 ] || ! git diff --quiet --exit-code; then
4648
echo "❌ Pre-commit check failed."

Diff for: .pre-commit-config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ repos:
5252
- id: trailing-whitespace
5353
exclude: ^.*\.(snap)
5454
args: ["--markdown-linebreak-ext=md"]
55+
- repo: local
56+
hooks:
57+
- id: eslint
58+
name: eslint
59+
entry: bash -c 'cd superset-frontend && npm run eslint -- $(echo "$@" | sed "s|superset-frontend/||g")'
60+
language: system
61+
pass_filenames: true
62+
files: \.(js|jsx|ts|tsx)$
5563
- repo: https://github.com/pre-commit/mirrors-prettier
5664
rev: v4.0.0-alpha.8 # Use the sha or tag you want to point at
5765
hooks:

0 commit comments

Comments
 (0)