CLDSRV-1002: format the whole codebase with prettier - #6297
DarkIsDude wants to merge 16 commits into
Conversation
Hello darkisdude,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
|
/create_pull_requests |
There was a problem hiding this comment.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
|
It seems prettier does not handle strings well -creating useless string concatenations, keeping unneeded wrapped lines or not splitting lines, and leaving multi-line strings concatenated with single-line strings-, which this is not caught by the linter either, and I ended up doing the linter myself... Specific remarks:
A few extra notable findings regarding tech debts we may handle to address sooner rather than later (though not in this PR obviously):
|
8724166 to
90fa521
Compare
The lint job of the tests workflow runs prettier --check on every file, next to ESLint, instead of a separate workflow diffing the files a pull request touches; the diff script goes away. Issue: CLDSRV-1002
Prettier and max-len both cap lines at 120 columns, but Prettier cannot break string literals, template literals or comments, so it leaves some lines longer and max-len reports them: 109 errors on the reformatted tree. Fixing them would mean hand-split strings or disable comments, which is the concatenation noise the reformat removes. Turn max-len off. The eslint-disable max-len directives become unused, which ESLint 9 reports as warnings and the lint job fails on (--max-warnings 0), so they are removed with it. Issue: CLDSRV-1002
The website fixtures' exact bytes are asserted as ETags in websiteHead.js and websiteHeadWithACL.js. monitoring/dashboard.json is generated from dashboard.py by grafanalib; it is also marked as generated so GitHub collapses its diff. Issue: CLDSRV-1002
Plain output of `yarn prettier:write`, no manual edit on top. Issue: CLDSRV-1002
Prettier pads markdown table cells for alignment, which pushed this table to 82 columns and tripped MD013. mdlint's config lives in the shared Guidelines package and cannot be relaxed per repo, so shorten the widest cell instead. Issue: CLDSRV-1002
Adds .git-blame-ignore-revs, which GitHub reads automatically; the file explains the one-time git config needed locally. Issue: CLDSRV-1002
Prettier reflowed the code to 120 columns, which left many messages and test descriptions as chains of short literals joined with `+`. Merge adjacent literals into a single string wherever the result fits; strings that cannot fit are re-split into as few pieces as possible. Issue: CLDSRV-1002
Strings that were wrapped by hand for the old 80-column limit kept their short pieces after the Prettier reflow, often as one short line followed by several full ones. Re-split them into as few balanced pieces as fit in 120 columns, or into a single literal when it fits. Issue: CLDSRV-1002
Where a message was built as a plain string concatenated with a template literal, merge the pieces into a single template literal. Kept separate from the plain-string merges so it can be reviewed, or dropped, on its own. Issue: CLDSRV-1002
Merging the hand-wrapped literals exposed pieces that had been joined without a separating space (and one doubled space), in test names and in a few error messages. Add the missing spaces. Issue: CLDSRV-1002
Covers code added to development/9.4 after the cleanup was written and every remaining plain, template or mixed pair joined with + on one line, so no-useless-concat has nothing left to report. The ACL XML builder now pushes whole fragments instead of separate hardcoded entries joined with ''. String values are unchanged, checked by comparing the parsed string contents of every file before and after. Issue: CLDSRV-1002
Joins that glued two words (badconfig, localCachesentinel, ...), a missing space after a colon, a double space, and the localCache password assertion message. No test asserts these messages. Issue: CLDSRV-1002
Nothing is left for it to report after the string cleanup; enabling it stops new '...' + '...' joins on one line. Chains split over several lines are not reported, by the rule's design. Issue: CLDSRV-1002
From review: drop quotes docker-compose does not need, keep the async check ternary on three lines (an empty trailing comment stops prettier joining it), merge the completempu test title, add blank lines between tests, indent the encryption test XML bodies with the code, and drop the quotes around function names in describe titles. Issue: CLDSRV-1002
The template literal carried the code indentation into the response body, between the XML declaration and the root element. Only that whitespace changes; the document is the same. Issue: CLDSRV-1002
`.then(() => cb()).catch(cb)` calls cb a second time with the error when cb itself throws. Pass cb as the rejection handler instead, and let the bucket logging cleanup return its promise to mocha. Issue: CLDSRV-1002
d1c449e to
2b69358
Compare
Integration data createdI have created the integration data for the additional destination branches.
The following branches will NOT be impacted:
Follow integration pull requests if you would like to be notified of The following options are set: create_pull_requests |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
The following options are set: create_pull_requests |
Motivation and context
Prettier has only ever been checked on the files a PR touches, so the codebase
was being reformatted a few files at a time and most of it was still
unformatted. The RRR of Sep 7, 2026 concluded we should stop spreading it out
and do it in one go, so that formatting noise never lands in a review again.
Base is
development/9.4; 9.5 inherits it by forward merge.What changed
👷 check prettier formatting on the whole repo— the CI job runsprettier --check .instead of diffing against the merge base.scripts/prettier-diff.shand theprettier:diffscript are gone, replacedby
prettier:checkandprettier:write. ESLint'smax-lenis turned off:it duplicates Prettier's
printWidthand disagrees with it on linesPrettier cannot break (long string literals). The now-dead
eslint-disable max-lendirectives are removed with it.🙈 keep the website test fixtures out of prettier— their exact bytesare asserted as ETags in
websiteHead.js/websiteHeadWithACL.js.🎨 format the whole codebase with prettier— 499 files, the plainoutput of
yarn prettier:write, no manual edit on top.💚 keep the reformatted table within mdlint's line limit— Prettier'stable padding pushed a
CLAUDE.mdtable past MD013.📝 ignore the reformat commit in git blame— adds.git-blame-ignore-revs.📝 put the blame ignore setup first, one comment per commit🎨 merge string literals that prettier left concatenated— Prettiercollapses
'...' + '...'onto one line but keeps the+; runs of adjacentliterals are merged (or re-split into fewer pieces when too long). Also adds
the spaces that were missing at some of those joins.
👷 run the prettier check in the tests workflow lint job— drops theseparate
lintworkflow; Prettier now runs on every push next to ESLint.Commit 3 is mechanical; commit 7 is scripted with string values unchanged apart from the added spaces.
Verification
yarn prettier:check— cleanyarn lint— 0 errors, 3004 warnings, identical todevelopment/9.4yarn test— 6105 passing, 5 pendingRelated issues
https://scality.atlassian.net/browse/CLDSRV-1002