-
Notifications
You must be signed in to change notification settings - Fork 80
Add precommit hook with automated formatting #2122
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
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds precommit hook infrastructure using Husky to automate code formatting and enforce code quality standards. The hooks sort namespace imports, check for unused imports, run PHP code formatting, and ensure consistent JavaScript formatting before commits.
- Adds Husky precommit hook that automatically formats PHP and JavaScript files
- Sorts and validates namespace imports in all existing PHP files
- Updates prettier configuration to exclude additional directories
Reviewed Changes
Copilot reviewed 70 out of 72 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
package.json | Adds Husky dependency and prepare script |
.husky/pre-commit | Implements precommit hook for formatting and import validation |
.prettierignore | Updates ignore patterns for formatting |
Multiple PHP files | Alphabetically sorts namespace imports according to new standards |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
use Activitypub\Activity\Base_Object; | ||
use Activitypub\Activity\Generic_Object; | ||
use Activitypub\Transformer\Base; | ||
use Activitypub\Transformer\Post; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty line added after use statements should be removed. The existing formatting was correct with no blank line between use statements and the class comment.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pfefferle Do you have a preference for or against separating class imports from function imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to separate them!
Can you maybe say some words about husky and why you have used it? |
Proposed changes:
phpcbf
on changed PHP files.npm run format
.Testing instructions:
npm install
.