Skip to content

feat: implement formatting checks to CI #1153

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

fabiovincenzi
Copy link
Contributor

@fabiovincenzi fabiovincenzi commented Aug 15, 2025

Fixes #1152
Adds formatting checks to CI pipeline, automated formatting via a pre-commit hook and improves npm scripts to enforce consistent code formatting across the codebase, preventing formatting-related merge conflicts.

Copy link

netlify bot commented Aug 15, 2025

Deploy Preview for endearing-brigadeiros-63f9d0 ready!

Name Link
🔨 Latest commit 4a2a297
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/68a7170fa6052c00086daea7
😎 Deploy Preview https://deploy-preview-1153--endearing-brigadeiros-63f9d0.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

codecov bot commented Aug 15, 2025

Codecov Report

❌ Patch coverage is 91.07143% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.80%. Comparing base (d9d8b18) to head (4a2a297).

Files with missing lines Patch % Lines
src/service/passport/jwtAuthHandler.js 85.71% 3 Missing ⚠️
src/service/passport/jwtUtils.js 93.93% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1153   +/-   ##
=======================================
  Coverage   82.80%   82.80%           
=======================================
  Files          66       66           
  Lines        2786     2786           
  Branches      334      334           
=======================================
  Hits         2307     2307           
  Misses        432      432           
  Partials       47       47           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@jescalada jescalada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this would be overridden by any local formatting rules. Is the priority configurable on our side? 🤔

Also, is it possible to modify this so that it formats automatically on save? Though a bit annoying, it's probably the best way to help contributors get the formatting right.

@kriswest
Copy link
Contributor

Also, is it possible to modify this so that it formats automatically on save? Though a bit annoying, it's probably the best way to help contributors get the formatting right.

Usually a job for lint-staged and husky to apply it in a commit hook: https://prettier.io/docs/install.html#git-hooks

Applying on save is harder. I use the prettier-vscode extension which picks up the project's config and applies it on save.

Its still worth having a check in on formatting in CI - but make it check (prettier --check), it should not make changes as that can lead to some hard-to-debug weirdness (rare but has happened).

@fabiovincenzi
Copy link
Contributor Author

I also use prettier-vscode, which automatically detects the project configuration and applies formatting on save. Having a formatting check in CI ensures that what gets pushed is properly formatted. If you think it would be useful, I can implement lint-staged and husky to format code at commit time.

@kriswest
Copy link
Contributor

Formatting on commit works well on other projects I contribute to @fabiovincenzi. We're already running something via husky on commit - just commitlint I think: https://github.com/finos/git-proxy/blob/main/.husky/commit-msg
You may need to work with that to make sure they play nice: https://prettier.io/docs/precommit

@kriswest
Copy link
Contributor

Check seems to work, but needs an npm run format run to make it pass and confirm all is in sync. If the precommit hook is working, it only applies to files that are part of the PR, hence, the 52 failures outside the PR scope.

@kriswest kriswest requested a review from jescalada August 21, 2025 10:19
@fabiovincenzi
Copy link
Contributor Author

I’ll run npm run format now. I delayed it earlier to keep the review clearer.

@kriswest
Copy link
Contributor

I’ll run npm run format now. I delayed it earlier to keep the review clearer.

Fair! Looking good on the check. Have you tested the pre-commit hook without the VSCode plugin running? It should run when you commit to your fork, so you can derive a new branch to test on without affecting the PR. I haven't had a chance to do so.

Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - pending confirmation that the pre-commit hook is working (without a VsCode plugin applying rules on save) - note it will only apply prettier to files that are changing in a commit (staged files)

@fabiovincenzi
Copy link
Contributor Author

I’ve tested it on a separate branch without the VSCode plugin, and I can confirm the pre-commit hook is working as expected. Thanks @kriswest for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce merge conflicts by enforcing consistent code formatting
3 participants