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

📎 Feature: --staged option to simplify the creation of git hook scripts #2296

Closed
castarco opened this issue Apr 4, 2024 · 0 comments · Fixed by #2300
Closed

📎 Feature: --staged option to simplify the creation of git hook scripts #2296

castarco opened this issue Apr 4, 2024 · 0 comments · Fixed by #2300
Assignees
Labels
A-CLI Area: CLI S-Feature Status: new feature to implement

Comments

@castarco
Copy link
Contributor

castarco commented Apr 4, 2024

Description

Problem Statement

As of today, biome does not provide a direct mechanism to select (for linting, formatting or checking) only the files that are staged for a commit.

We have a "similar" flag, --changed, but its main purpose is to be used in CI, and allows us to check only the files that changed between 2 points in history (which can be explicit or implicit).

Many people think at first that --changed will also help them to select only the files that are staged, not being the case.

More advanced users have found workarounds to this issue ( #1198 (comment) ), but these involve having to write longer, more complex and slower scripts. Not everyone can come up with these solutions, even if they seem simple after we see them.

Others rely on tools such as lint-staged, but this involves adding more dependencies to the project (which in this case are much slower than biome), and opens up the possibility for more bugs caused by unexpected interactions between lint-staged and biome.

Proposal

After a discussion held in Discord ( https://discord.com/channels/1132231889290285117/1222450681919832134 ), we agreed that it would be a good idea to introduce a new --staged flag for the lint, format and check commands that will make biome take into account only the files that are staged.

Addendum

While --staged doesn't give us much when we are running "potentially destructive" commands such as format or check --apply (because we still need to independently obtain a list of staged files so we can re-add them to the "stage" before they are committed), it gives a clear advantage for readonly-mode commands such as lint without --apply.

@ematipico ematipico added A-CLI Area: CLI S-Feature Status: new feature to implement labels Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI S-Feature Status: new feature to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants