Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📎 Create a new git hooks recipe #1198

Closed
ematipico opened this issue Dec 15, 2023 · 3 comments · Fixed by #1410
Closed

📎 Create a new git hooks recipe #1198

ematipico opened this issue Dec 15, 2023 · 3 comments · Fixed by #1410
Assignees
Labels
A-Documentation Area: documentation A-Website Area: website S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@ematipico
Copy link
Member

ematipico commented Dec 15, 2023

Description

Essentially, on this page we want to add some recipes for how to add Biome to commit hooks:

  • lint-staged
  • lefthook
  • etc.

@nhedger: I know you set up a commit hook in biome-vscode, this knowledge could live in that page
@Conaclos : I know you created a repository around this, but honestly, I don't know what that is about. We can have some knowledge in that page

The name of the page isn't set on stone, feel free to come up with a better name

@ematipico ematipico added A-Website Area: website A-Documentation Area: documentation labels Dec 15, 2023
@ematipico ematipico added the S-Help-wanted Status: you're familiar with the code base and want to help the project label Dec 15, 2023
@nhedger nhedger changed the title 📎 Create a new hooks recipe 📎 Create a new git hooks recipe Dec 15, 2023
@danielsarsi
Copy link
Contributor

Hey! I'm using a simplified pre-commit hook only for formatting. Putting here in case it's useful for this task:

#!/usr/bin/env sh

EXTENSION="js|jsx|ts|tsx|json|mjs|cjs"
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E "(${EXTENSION})$" | tr '\n' ' ')

if [ -z "$STAGED_FILES" ]; then
  exit 0
fi

yarn biome format --write --colors=off $STAGED_FILES
git add $STAGED_FILES

if git diff --cached --quiet; then
  echo "No changes left to commit. Aborting."
  exit 1
fi

@depsimon
Copy link

Hey! I'm using a simplified pre-commit hook only for formatting.

Any downsides to running check instead of format have you been bit by something?

@nhedger
Copy link
Member

nhedger commented Dec 19, 2023

Hey! I'm using a simplified pre-commit hook only for formatting.

Any downsides to running check instead of format have you been bit by something?

check will also run the linter, so I guess it depends on what you're trying to achieve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Documentation Area: documentation A-Website Area: website S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants