support: Integrate Lefthook for pre-commit Biome formatting#10694
support: Integrate Lefthook for pre-commit Biome formatting#10694yuki-takei merged 4 commits intomasterfrom
Conversation
- Add lefthook as dev dependency in root package.json - Create lefthook.yml with pre-commit hook for Biome formatting - Update .devcontainer/app/postCreateCommand.sh to install Lefthook hooks - Update .devcontainer/pdf-converter/postCreateCommand.sh to install Lefthook hooks - Configured to automatically format staged files with Biome on commit - Excludes Stylelint as per requirement (Stylelint not included in hooks) Co-authored-by: yuki-takei <1638767+yuki-takei@users.noreply.github.com>
|
@copilot このプロジェクトでは npm ではなく pnpm を使っています それから、biome 公式ドキュメントを参考に、安全な修正も行いたいです |
- Changed from npx to pnpm biome in lefthook.yml (project uses pnpm) - Added --unsafe flag to apply safe fixes as per Biome official docs - Configured pnpm to only build lefthook dependency (not other deps) Co-authored-by: yuki-takei <1638767+yuki-takei@users.noreply.github.com>
Updated in commit 6cef1e8:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot |
Per Biome official documentation, --unsafe should NOT be used in pre-commit hooks. The --unsafe flag applies both safe AND unsafe fixes, which could break code logic. Pre-commit hooks should only apply safe fixes using --write without --unsafe. Co-authored-by: yuki-takei <1638767+yuki-takei@users.noreply.github.com>
Corrected in commit 6590960. Removed The |
Implementation Plan: Lefthook Integration with Biome
Implementation Details
The pre-commit hook uses
pnpm biome check --writeto apply only safe fixes (formatting and safe linting corrections) as recommended by Biome's official documentation. Unsafe fixes that could alter code logic are intentionally skipped in automated hooks and must be applied manually when needed.Note: The user mentioned Stylelint is not needed, but it's currently configured in the project. This implementation excludes it from Lefthook but doesn't remove existing Stylelint configuration to avoid breaking changes.
Original prompt
Start implementation
[Chronological Review: The conversation began with the user requesting the integration of Lefthook to automate formatting with Biome during pre-commit. The user then specified that Stylelint was unnecessary and asked for an explanation of the need for a prepare script. Following this, the user mentioned that the team mandates the use of devcontainer specifications and suggested that the postCreateCommand.sh file under .devcontainer would be a suitable place for certain configurations. The user also indicated that a pdf-converter is also necessary.][Intent Mapping:
[Technical Inventory:
[Code Archaeology:
[Progress Assessment:
[Context Validation: All critical information for continuation is captured, including user requests and the context of the devcontainer setup.]
[Recent Commands Analysis:
1. Conversation Overview: - Primary Objectives: - "lefthook を導入し、precommit で biome による自動フォーマットをしたい" - Implement Lefthook for automatic formatting with Biome. - "stylelint は不要" - Exclude Stylelint from the setup. - "prepare スクリプトがなぜ必要なのか説明して" - Understand the necessity of a prepare script. - "チームには devcontainer の仕様を義務づけています" - Adhere to team mandates for devcontainer specifications. - ".devcontainer 配下の postCreateCommand.sh に書く方がいいかと思った" - Suggest using postCreateCommand.sh for configurations. - "pdf-converter でも必要" - Include a pdf-converter in the setup.-
-
- Technical Foundation:
- Lefthook: A tool for managing Git hooks.
- Biome: A code formatting tool.
- Devcontainer: A specification for defining development environments.
- postCreateCommand.sh: A script for post-creation commands in devcontainers.
- pdf-converter: A tool required for project needs.
- Codebase Status:
- No specific files were modified or discussed in detail, but the user emphasized the importance of the postCreateCommand.sh file for configurations.
- Problem Resolution:
- Issues Encountered: No specific technical problems were reported, but the user seeks clarity on the prepare script.
- Solutions Implemented: None yet, as the integration is still in the planning phase.
- Debugging Context: Ongoing discussions about tool integration and team requirements.
- Lessons Learned: The importance of adhering to team standards and the need for clear documentation of tool usage.
- Progress Tracking:
- Completed Tasks: User has outlined the requirements for Lefthook and Biome.
- Partially Complete Work: Implementation details for Lefthook and the prepare script are pending.
- Validated Outcomes: None confirmed yet.
- Active Work State:
- Current Focus: Discussing the integration of Lefthook ...
Session Context: The conversation has revolved around setting up Lefthook and Biome for code formatting, clarifying the need for a prepare script, and adhering to team standards for development environments.
User Intent Evolution: The user has consistently focused on integrating specific tools and ensuring compliance with team practices, indicating a structured approach to development.
Created from VS Code.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.