Skip to content

feat(git): biome pre-commit hook - #1487

Open
Dhruv-0-Arora wants to merge 7 commits into
devfrom
darora1/336/biome-commit-hook
Open

feat(git): biome pre-commit hook#1487
Dhruv-0-Arora wants to merge 7 commits into
devfrom
darora1/336/biome-commit-hook

Conversation

@Dhruv-0-Arora

@Dhruv-0-Arora Dhruv-0-Arora commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Task

A git hook to notify you when you try to commit something that you have a formatting error in the files that you are trying to commit. To install just bun i

  • will append a sh /fission/scripts/hooks/pre-commit to your /.git/hooks/pre-commit

To bypass, run git commit *--no-verify* when committing

Note

Works on git worktrees only if that worktree contains the /fission/scripts/hooks/pre-commit file

Warning

Install script doesn't work on windows when using powershell and cmd. Fails cleanly

SYNTH-336

Symptom

There a quite a few chore(formatting): ... commits right now. This PR aims to reduce the number of those.

Verification

Create a formatting mistake in a file and try to commit the formatting mistake.


Before merging, ensure the following criteria are met:

  • All acceptance criteria outlined in the ticket are met.
  • Necessary test cases have been added and updated.
  • A feature toggle or safe disable path has been added (if applicable).
  • User-facing polish:
    • Ask: "Is this ready-looking?"
  • Cross-linking between Jira and GitHub:
    • PR links to the relevant Jira issue.
    • Jira ticket has a comment referencing this PR.

blocks the commit when it finds biome issues with the changed code
Comment thread fission/package.json Outdated
Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>
Comment thread fission/package.json Outdated
@Dhruv-0-Arora
Dhruv-0-Arora requested a review from 0xda157 August 10, 2026 18:36
Comment thread fission/package.json Outdated
Comment thread fission/README.md Outdated
@Dhruv-0-Arora
Dhruv-0-Arora force-pushed the darora1/336/biome-commit-hook branch from b88ee6c to a93ecdd Compare August 12, 2026 18:55
@Dhruv-0-Arora
Dhruv-0-Arora requested a review from rutmanz August 12, 2026 18:55
Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>
@Dhruv-0-Arora
Dhruv-0-Arora force-pushed the darora1/336/biome-commit-hook branch from a93ecdd to 5b4b95b Compare August 12, 2026 21:19
Comment thread fission/package.json Outdated
@0xda157
0xda157 marked this pull request as draft August 17, 2026 23:31
Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>
@Dhruv-0-Arora
Dhruv-0-Arora requested a review from 0xda157 August 19, 2026 17:52
@Dhruv-0-Arora
Dhruv-0-Arora marked this pull request as ready for review August 19, 2026 17:52
exit 0
fi

hooks_dir=$(git config --get core.hooksPath 2>/dev/null || true)

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.

hooks_dir=$(true) ?

mkdir -p "$(dirname "$hook_file")"

if [ ! -e "$hook_file" ]; then
printf '#!/bin/sh\n' >"$hook_file"

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.

we should always use /bin/sh or always use /usr/bin/env sh

mkdir -p "$(dirname "$hook_file")"

if [ ! -e "$hook_file" ]; then
printf '#!/bin/sh\n' >"$hook_file"

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.

Suggested change
printf '#!/bin/sh\n' >"$hook_file"
echo "#!/bin/sh" >"$hook_file"

exit 0
fi

printf '%s\n' "$HOOK_COMMAND" >>"$hook_file"

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.

Suggested change
printf '%s\n' "$HOOK_COMMAND" >>"$hook_file"
echo "$HOOK_COMMAND" >>"$hook_file"

@0xda157 0xda157 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.

this breaks if you checkout a branch that doesn't include this PR. we should copy the script to pre-commit, not insert a script that calls it.

@PepperLola PepperLola left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I left a couple comments. If the pre-commit hook is installed automatically on bun i would we want a way to disable the installation for CI? Could just be an env var we specify in the workflow file or something.

exit 0
fi

if ! xargs -0 bun x biome check --no-errors-on-unmatched --files-ignore-unknown=true <"$staged_list"; then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will read the staged files from disk? In which case it's possible that someone could stage something that's formatted correctly, make a change to the file with bad formatting (but not stage) and then they'd be blocked from committing even though the staged change is okay.

This could also happen the other way around - someone stages changes with bad formatting and then runs the formatter but doesn't stage the correctly formatted files. Then they'd be allowed to commit even though the format is bad.

Comment thread fission/scripts/hooks/install.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants