-
Notifications
You must be signed in to change notification settings - Fork 739
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
Add prettier #7857
Add prettier #7857
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't do that big code refactor which will cause lots of conflicts when cherry-picking,
can we do this for new files only currently?
Great initiative - but of course the blames are also really useful for assigning blame ;-) Luckily we will be moving more code to typescript incrementally, so would love to see a consistent style at that stage as well as for new files =) |
fea5caf
to
ed56851
Compare
Thanks for the suggestions! I've added an ignore file containing everything that would be changed, I've opted to leave these 3 files (which already match the new formatting) out of the new ignore file
|
ed56851
to
5f24ff2
Compare
this still has a big problem: node versions... our CI is currently using an old version of node that isn't supported by prettier. I'm talking to people about how we can upgrade that, but one option could be to use a github workflow for this. It's not preferable because it'll waste CI time (see also: #7850) but it's something we could do more immediately... then again, I'm not sure how hard node will be to update |
cef19cd
to
5f24ff2
Compare
5f24ff2
to
081ee68
Compare
I added Node v20 to the Tinderbox container, and I think I'll clone that for all CI for co-24.04 onwards. |
e604b6d
to
a668232
Compare
the build is still failing for the same issue - I'm not sure if it's added and only not being used? It may be worth checking if 24.04 CI shares the same issue and fixing it there if it does |
a668232
to
7701b04
Compare
8a17cf3
to
c390a59
Compare
Seems reasonable to me =) But I'll leave to a JS person. Thanks Skyler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, but maybe let's wait for CI test (unit + cypress step) to be sure it will not fail all the builds
c390a59
to
9be8fc9
Compare
a99bf60
to
feaca43
Compare
Prettier is a code formatter for javascript/typescript. It's relatively common to see complaints about style in pull requests or inconsistent style getting in to Collabora Online. Also, without a formatter it's harder for editors to automatically format code in sensible and consistent ways Prettier doesn't have many options, but those which it does have I have set to the closest values to current behavior (e.g. single quotes) in order to minimize unnecessary changes This commit doesn't format all existing files. Doing so would cause blames, cherry-picks and diffs to become much less useful. Instead, we use browser/.beforeprettier to list all files that would need to be changed, and this file is ignored. You are encouraged but not required to set your editor's equivalent of 'editor.formatOnSaveMode' to only format changed lines This commit also does format of docstatefunctions.js, previously it did not in to check that an incorrectly-formatted file could fail CI. Now it does to make sure that formatting fixes the issue. This file was chosen because it is very new and very small. Change-Id: Ie6067f34aa658f887e149a08aebd0180b2354005 Signed-off-by: Skyler Grey <[email protected]>
feaca43
to
92d01ca
Compare
CI is back up to having checks, and I've modified the commit to make sure it doesn't format any files before our CI runs prettier. In other words: it can now fail, so that's good. I think we should merge this soon. I note also that when we do merge it we need to be sure that we either rerun CI for or manually format currently open and green PRs that add new files (or CI will start complaining about them after they get merged if they have formatting issues) |
Prettier is a code formatter for javascript/typescript. It's relatively
common to see complaints about style in pull requests or inconsistent
style getting in to Collabora Online. Also, without a formatter it's
harder for editors to automatically format code in sensible and
consistent ways
Prettier doesn't have many options, but those which it does have I have
set to the closest values to current behavior (e.g. single quotes) in
order to minimize unnecessary changes. There'll still be a lot of
changes, but in my opinion this is preferable to no formatter as we only
pay the cost once but get benefits continuing on into the future
I have decided to format everything in a single commit, as it will make it easier to ignore in blames in the future and less annoying in the future. It's annoying now, and I'm sorry for that. When reviewing, you'll probably want to look at individual commits - I don't imagine the full diff view will be particularly helpful.