Skip to content

[Git hooks] Replace pre-push with pre-commit - #10327

Merged
weronikaolejniczak merged 13 commits into
elastic:mainfrom
weronikaolejniczak:chore/pre-commit-hook
Nov 20, 2026
Merged

weronikaolejniczak merged 13 commits into
elastic:mainfrom
weronikaolejniczak:chore/pre-commit-hook

Conversation

@weronikaolejniczak

@weronikaolejniczak weronikaolejniczak commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes https://github.com/elastic/eui-private/issues/450. Depends on #10325.

Replaces the slow pre-push hook (rebuild, lint, tests) with a pre-commit hook (Husky + lint-staged) on staged files:

  • Prettier with the root config, repo-wide.
  • ESLint and Stylelint --fix in eui and the theme packages, using each package's own config.

Type checks and tests stay in CI.

weronikaolejniczak and others added 4 commits November 17, 2026 10:55
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…nfig

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@weronikaolejniczak weronikaolejniczak added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label Nov 17, 2026
@weronikaolejniczak
weronikaolejniczak marked this pull request as ready for review November 18, 2026 09:36
@weronikaolejniczak
weronikaolejniczak requested a review from a team as a code owner November 18, 2026 09:36
Comment thread packages/eui/.lintstagedrc.js Resolved
Comment thread scripts/lint-staged/eslint.js Resolved
Comment thread scripts/lint-staged/eslint.js Resolved
weronikaolejniczak and others added 2 commits November 18, 2026 10:42
Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	package.json
#	yarn.lock
Also cover the lint-staged ESLint task with tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: weronika.olejniczak <weronika.olejniczak@elastic.co>
Comment thread scripts/lint-staged/eslint.test.js Resolved
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: weronika.olejniczak <weronika.olejniczak@elastic.co>
@angeles-mzb
angeles-mzb self-requested a review November 18, 2026 13:42
@angeles-mzb

Copy link
Copy Markdown
Contributor

Tested different scenarios locally with real commits:

  • Prettier reformats and commit succeeds
  • ESLint blocks a commit with bad code such as a debugger
  • ESLint ignored files with bad code does not block the commit
  • Stylelint blocks a commit with a bad CSS prop

There is an edge case that we might want to act on: if you have a clean workspace, you haven't built packages yet (or you haven't build @elastic/eslint-plugin-eui), you won't be able to commit on packages/eui/src because @elastic/eslint-plugin-eui is trying to get loaded and you get an ugly not friendly error.

We could either check, when the plugin is necessary, if it is built or not and print something like “Run yarn workspace @elastic/eui build:workspaces first” if not, or build it always on post install which might go against the goal of this PR.

Thanks for making this much faster! 🎉

Comment thread scripts/lint-staged/eslint.js Resolved
…ssing

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread package.json Resolved
Comment thread packages/eui/package.json Resolved
Comment thread scripts/lint-staged/eslint.js Resolved
Comment thread scripts/lint-staged/eslint.js Resolved
Comment thread scripts/lint-staged/eslint.test.js Resolved
Comment thread scripts/lint-staged/eslint.test.js Resolved
Run EUI lint in CI when the ESLint plugin changes, document the build step and Husky rollback, and use forward slashes in generated paths so the hook works on Windows.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread scripts/lint-staged/eslint.js Resolved

@angeles-mzb angeles-mzb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retested, I can see the hint now, I'd remove the stack trace so the hint can actually be found but I don't think we will encounter this often so up to you. Approving!

node:internal/modules/cjs/loader:1611
  const err = new Error(`Cannot find module '${request}'`);
              ^

Error: Failed to load plugin '@elastic/eui' declared in '.eslintrc.js': Cannot find module '.../eui/packages/eui/node_modules/@elastic/eslint-plugin-eui/lib/cjs/index.js'
Require stack:
-.../eui/packages/eui/__placeholder__.js
Referenced from: .../eui/packages/eui/.eslintrc.js

Run `yarn workspace @elastic/eui build:workspaces` first.
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1611:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1600:9)
    at resolveExports (node:internal/modules/cjs/loader:754:14)
    at Module._findPath (node:internal/modules/cjs/loader:821:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1557:27)
    at wrapResolveFilename (node:internal/modules/cjs/loader:1118:27)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1169:12)
    at require.resolve (node:internal/modules/helpers:175:31)
    at Object.resolve (.../eui/packages/eui/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2325:46)
    at ConfigArrayFactory._loadPlugin (.../eui/packages/eui/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3392:33) {
  code: 'MODULE_NOT_FOUND',
  path: '.../eui/packages/eui/node_modules/@elastic/eslint-plugin-eui',
  messageTemplate: 'plugin-missing',
  messageData: {
    pluginName: '@elastic/eslint-plugin-eui',
    resolvePluginsRelativeTo: '.../eui/packages/eui',
    importerName: '.eslintrc.js'
  }
}

Node.js v24.22.3
husky - pre-commit script failed (code 1)

Comment thread scripts/lint-staged/eslint.js Resolved
Comment thread scripts/lint-staged/eslint.test.js Resolved
Comment thread scripts/lint-staged/eslint.test.js Resolved
Comment thread scripts/lint-staged/eslint.test.js Resolved
Co-authored-by: Cursor <cursoragent@cursor.com>
@weronikaolejniczak
weronikaolejniczak enabled auto-merge (squash) November 20, 2026 11:57
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

@weronikaolejniczak
weronikaolejniczak merged commit dd94e8f into elastic:main Nov 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants