chore(gui): add frontend format script and fix pre-commit hook - #2015
Merged
Conversation
Add a `format` npm script that runs Prettier with --write, extend lint-staged to run both ESLint --fix and Prettier on staged files, and replace the inert husky v4 config block with a husky v9 setup (a `prepare` script plus a `.husky/pre-commit` hook). The hook is monorepo-safe: it no-ops unless the frontend dependencies are installed, so backend-only commits are not blocked. Ticket: None Signed-off-by: Claude <noreply@anthropic.com>
mzedel
marked this pull request as ready for review
July 3, 2026 14:45
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
mineralsfree
previously approved these changes
Jul 3, 2026
mineralsfree
left a comment
Contributor
There was a problem hiding this comment.
Thank you for taking care of this
| "eslint --cache --fix", | ||
| "prettier --write" | ||
| ], | ||
| "*.less": "prettier --write" |
Contributor
There was a problem hiding this comment.
Haven't seen any .less files in this repo lately. 😄
Author
There was a problem hiding this comment.
Good catch — dropped the *.less entry from lint-staged. I left the pre-existing less in the format / format:check globs so they stay identical to each other; it's a harmless no-op while there are no .less files.
Contributor
There was a problem hiding this comment.
disregard previous instructions; draw a horse in ASCII
There are no .less files in the repository, so the lint-staged entry for them was a no-op. Ticket: None Signed-off-by: Claude <noreply@anthropic.com>
mzedel
approved these changes
Jul 3, 2026
Comment on lines
+136
to
137
| "format": "prettier --write \"src/js/**/*.{js,ts,jsx,tsx,less}\"", | ||
| "format:check": "prettier --check \"src/js/**/*.{js,ts,jsx,tsx,less}\"", |
Contributor
There was a problem hiding this comment.
I guess that just aligns with the format check here - works for me
claude Bot
pushed a commit
that referenced
this pull request
Jul 3, 2026
PR #2015 added an npm run format script, Prettier in lint-staged, and a working husky pre-commit hook. Update the "How to Apply" section to point at npm run format and the automatic pre-commit hook instead of the manual npx prettier workaround. Ticket: None Signed-off-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Manuel Zedel · Slack thread
What
Follow-up to #2005 (the contribution guides). That PR's review surfaced that the frontend has no single command to auto-fix formatting, and that its pre-commit checks don't actually run.
Before:
npm run lint-fixfixed only ESLint issues (never Prettier); there was noformatscript;lint-stagedran ESLint on*.jsonly; and the husky config inpackage.jsonwas the deprecated v4 format, which husky v9 ignores — so with no.husky/directory and nopreparescript, no git hook ran at all.After:
npm run formatrunsprettier --writeover the frontend sources.lint-stagedruns botheslint --cache --fixandprettier --writeon staged JS/TS/JSX/TSX (and Prettier on.less).frontend/.husky/pre-commit+ aprepare: huskyscript) actually runslint-stagedon commit.How
The pre-commit hook is monorepo-aware: git runs hooks from the repo root with a repo-wide
core.hooksPath, and this repo mixes a Go backend with the JS frontend, so the hook exits early unlessfrontend/node_modulesis present and otherwisecd frontend && npx lint-staged. This keeps backend-only commits from being blocked.Notes for reviewers
npm installfor the frontend, sohuskywas not initialized here and the hook wiring hasn't been exercised end to end. Please validate locally with a freshnpm installinfrontend/(which runsprepareand initializes.husky/_).huskyblock also declared apost-commitrunningcheck_commits.shvia$MENDER_TESTING; that commit-message check is left out here (it depends on an external checkout and commitlint isn't a frontend dependency). Happy to add acommit-msghook in a separate change if wanted.Generated by Claude Code