Skip to content

[Chore] Update pre-commit hook to fail on ESLint warnings - #11445

Merged
ThieryMichel merged 4 commits into
masterfrom
chore/husky-fail-on-warnings
Nov 12, 2026
Merged

ThieryMichel merged 4 commits into
masterfrom
chore/husky-fail-on-warnings

Conversation

@nawan-b

@nawan-b nawan-b commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The pre-commit hook runs eslint --fix on staged files, which only fails on errors. A warning (e.g. an unused import) doesn't block the commit.

Solution

  • Run ESLint with --max-warnings 0 in .lintstagedrc, so the hook also fails on warnings.
  • Add --no-warn-ignored, otherwise committing a file ignored by ESLint (e.g. a create-react-admin template) fails because of the "File ignored" warning.
  • Fix the 3 warnings left in files that the hook lints but yarn lint doesn't:
    • remove the unused slugify function in docs/js/ra-navigation.js
    • remove the unused index argument in the replace-Datagrid-DataTable-Props codemod fixtures

How To Test

  1. Add an unused import to a source file (e.g. import { join } from 'path';), stage it and commit: the commit is rejected with ESLint found too many warnings (maximum: 0).
  2. Remove the import, stage and commit again: the commit succeeds.
  3. Stage a change in a file ignored by ESLint (e.g. packages/create-react-admin/templates/common/src/Layout.tsx) and commit: the commit succeeds.

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (not applicable: tooling configuration only)
  • The PR includes one or several stories (not applicable: no component change)
  • The documentation is up to date

@nawan-b nawan-b added the RFR Ready For Review label Nov 10, 2026
@ThieryMichel ThieryMichel added this to the 5.15.7 milestone Nov 12, 2026
@ThieryMichel
ThieryMichel merged commit a1f8dca into master Nov 12, 2026
15 checks passed
@ThieryMichel
ThieryMichel deleted the chore/husky-fail-on-warnings branch November 12, 2026 13:36
@fzaninotto fzaninotto changed the title Update pre-commit hook to fail on ESLint warnings [Chore] Update pre-commit hook to fail on ESLint warnings Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants