Skip to content

Conversation

@reakaleek
Copy link
Member

@reakaleek reakaleek commented Nov 7, 2025

Details

What Gets Checked

Pre-commit hooks (run on staged files):

  • prettier - Formats TypeScript, JavaScript, CSS, and JSON files in src/Elastic.Documentation.Site/
  • typescript-check - Type checks TypeScript files with tsc --noEmit (only if TS files are staged)
  • eslint - Lints and fixes JavaScript/TypeScript files

Pre-push hooks (run on files being pushed):

  • dotnet-lint - Lints C# and F# files using ./build.sh lint (runs dotnet format --verify-no-changes)

Installation

Husky.Net is included as a dotnet tool. After cloning the repository, restore the tools:

dotnet tool restore

Then install the git hooks:

dotnet husky install

That's it! The hooks will now run automatically on every commit and push.

Usage

Once installed, hooks run automatically when you commit or push:

git add .
git commit -m "your message"  # Pre-commit hooks run here
git push                       # Pre-push hooks run here

Note: If hooks modify files (prettier, eslint), the commit will fail so you can review the changes. Simply stage the changes and commit again:

git add -u
git commit -m "your message"

If the dotnet-lint hook fails during push, you need to fix the linting errors and commit the fixes before pushing again.

Manual Execution

You can test hooks without committing or pushing:

# Run all pre-commit tasks
dotnet husky run --group pre-commit

# Run all pre-push tasks
dotnet husky run --group pre-push

# Test individual tasks
dotnet husky run --name prettier
dotnet husky run --name typescript-check
dotnet husky run --name eslint
dotnet husky run --name dotnet-lint

Configuration

Hook configuration is defined in .husky/task-runner.json. See the Husky.Net documentation for more details.

@reakaleek reakaleek requested a review from a team as a code owner November 7, 2025 08:51
@reakaleek reakaleek requested a review from Mpdreamz November 7, 2025 08:51
Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

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

LGTM thank you for setting this up.

@reakaleek reakaleek marked this pull request as draft November 7, 2025 09:02
@reakaleek reakaleek force-pushed the feature/husky branch 3 times, most recently from f386295 to f1796bd Compare November 7, 2025 10:41
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🔍 Preview links for changed docs

@reakaleek reakaleek requested a review from Mpdreamz November 7, 2025 10:57
@reakaleek reakaleek self-assigned this Nov 7, 2025
@reakaleek reakaleek marked this pull request as ready for review November 7, 2025 10:57
@reakaleek reakaleek added the chore label Nov 7, 2025
@reakaleek reakaleek merged commit bdda8b3 into main Nov 7, 2025
22 of 23 checks passed
@reakaleek reakaleek deleted the feature/husky branch November 7, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants