Skip to content

Conversation

obenland
Copy link
Member

@obenland obenland commented Aug 29, 2025

Proposed changes:

  • Adds a git hook infrastructure using Husky.
  • Adds precommit hook that
    • sorts namespace imports in changed PHP files.
    • checks for unused imports in changed PHP files and aborts the commit if it finds any (I thought that was better than automatically removing them and potentially create fatal errors. Happy to change that though).
    • runs phpcbf on changed PHP files.
    • runs npm run format.
  • Updates all existing php files with correct namespace imports.

Testing instructions:

  • Check out this branch.
  • Run npm install.
  • Add an unused namespace import in a php file.
  • Attempt to commit that change.

@obenland obenland requested a review from pfefferle August 29, 2025 20:49
@obenland obenland self-assigned this Aug 29, 2025
@obenland obenland added the Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. label Aug 29, 2025
@Copilot Copilot AI review requested due to automatic review settings August 29, 2025 20:49
Copy link

@Copilot Copilot AI left a 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;

Copy link
Preview

Copilot AI Aug 29, 2025

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.

Suggested change

Copilot uses AI. Check for mistakes.

Copy link
Member Author

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?

Copy link
Member

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!

@pfefferle
Copy link
Member

Can you maybe say some words about husky and why you have used it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Followers [Block] Reactions [Block] Remote Reply aka "Reply on the Fediverse", in the comment list [Feature] Collections [Feature] Health Check [Feature] Import [Feature] Reactions [Feature] REST API [Feature] WP Admin [Focus] Compatibility Ensuring the plugin plays well with other plugins [Focus] Editor Changes to the ActivityPub experience in the block editor Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants