mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5311] [Feature]: Introduce a code formatter for frontend #3722
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3722
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @NikanZeyaei on GitHub (Jun 14, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5311
Is your feature request related to a problem?
The frontend/ package currently enforces code quality through ESLint, but it has no automatic formatter. As a result, style decisions such as quote style, trailing commas, line length, and import wrapping are left to individual contributors. This creates inconsistent formatting across the codebase, noisy diffs in PRs, and unnecessary review rounds purely over style.
Describe the solution you'd like
Add a dedicated formatter to frontend/ and wire it into the existing development workflow.
Alternatives you've considered
Biome / Oxlint are faster all-in-one alternatives to the current ESLint + Prettier combo, but switching tools would require more config changes and risk destabilizing the existing flat-config setup. Sticking with Prettier for now keeps the change minimal and focused on formatting only.
Concrete use case
No response
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
Frontend (UI / panel pages)
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 14, 2026):
The proposal is technically accurate and the implementation path is straightforward. Here is what is confirmed in the current source and a few details worth accounting for in the PR.
Current state (confirmed in source)
frontend/package.jsonhas no Prettier oreslint-config-prettierindevDependencies. No.prettierrcorprettier.config.jsexists.frontend/eslint.config.jsuses the ESLint flat-config format (an array export). Addingeslint-config-prettieras the final spread entry is the correct approach for this format.frontendCI job in.github/workflows/ci.ymlrunslint,typecheck,test,build, andauditsteps, but no format-check step.Implementation notes
Generated files.
frontend/src/generated/contains four auto-generated files (examples.ts,schemas.ts,types.ts,zod.ts) produced bynpm run gen. These should be listed in a.prettierignoreto avoid format drift between generation runs. The existingeslint.config.jsalready ignoresnode_modules/**and../internal/web/dist/**; mirroring those in.prettierignoreis prudent.Flat-config integration.
eslint-config-prettierexports a plain config object, so in the flat-config array it should be spread last:CI step placement. In
.github/workflows/ci.yml, theformat:checkstep is best inserted before theBuildstep in thefrontendjob so it fails fast without spending time on a full Vite build.Initial formatting PR. Running
npm run formatonce on the existing source before the feature PR is merged (or as a combined first PR) avoids polluting future diffs. ThecodegenCI job already enforces that generated files are not stale (git diff --exit-code), so after the initial format pass the generated files should be re-generated and committed together to keep that check green.The proposed Prettier config (
semi,singleQuote,trailingComma: es5,printWidth: 100,tabWidth: 2) is a reasonable starting point; the project can adjust it before the initial format run without consequence since no baseline exists yet.This reply was generated automatically; a maintainer may follow up.