biome
biome copied to clipboard
🐛 CLI setting --staged checks unstaged changes
Environment information
CLI:
Version: 1.8.3
Color support: true
Platform:
CPU Architecture: x86_64
OS: linux
Environment:
BIOME_LOG_DIR: unset
NO_COLOR: unset
TERM: "xterm-color"
JS_RUNTIME_VERSION: "v20.12.2"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: unset
Biome Configuration:
Status: Loaded successfully
Formatter disabled: false
Linter disabled: false
Organize imports disabled: false
VCS disabled: true
Workspace:
Open Documents: 0
What happened?
Hello,
i have pre-commit hook in git which looks like this:
./node_modules/.bin/biome check --staged --no-errors-on-unmatched
The issue is that Biome checks staged files, but i have unstaged changes, that may cause linter error.
For now i ended up with this workaround:
# get staged file names
stage_files=$(git diff --cached --name-only)
err_output=""
# check each staged file via biome check
# @see https://biomejs.dev/reference/cli/
for file in $stage_files; do
file_content=$(git show ":$file")
err_output="$err_output"`echo "$file_content" | ./node_modules/.bin/biome lint --no-errors-on-unmatched --stdin-file-path="$file" 2>&1 > /dev/null`
done
if [ -n "$err_output" ]; then
echo "$err_output"
exit 1
fi
Expected result
Would be nice, that biome could have options like --staged-files
and --staged-changes
.
Code of Conduct
- [X] I agree to follow Biome's Code of Conduct