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
Use Prettier for ESLint formatting TypeScript #23631
Conversation
I think the CodeQL failure is because the previously suppressed warnings are popping up because the suppression through the UI are line specific |
Mastodon aligns the |
This pull request has merge conflicts that must be resolved before it can be merged. |
07f000e
to
1be3f33
Compare
Prettier is an opinionated formatter with few options https://prettier.io/docs/en/options.html |
This pull request has merge conflicts that must be resolved before it can be merged. |
1be3f33
to
129ae48
Compare
129ae48
to
3451a24
Compare
This pull request has merge conflicts that must be resolved before it can be merged. |
3451a24
to
10abf35
Compare
This pull request has resolved merge conflicts and is ready for review. |
This pull request has merge conflicts that must be resolved before it can be merged. |
10abf35
to
a726821
Compare
This pull request has resolved merge conflicts and is ready for review. |
This pull request has merge conflicts that must be resolved before it can be merged. |
a726821
to
5659d80
Compare
This pull request has resolved merge conflicts and is ready for review. |
I split the commits between the JSX and JS files to see if one or the other might be easier to accept initially |
This pull request has merge conflicts that must be resolved before it can be merged. |
Looks good!
What about this? Could this cause issues? |
No, you can run |
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.
👍
Let's merge this!
const { hovering, handleMouseEnter, handleMouseLeave } = | ||
useHovering(autoPlayGif); |
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.
Is that way of having the right-hand side entirely on a new line really more readable?
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.
The whole line is > 80 char, so Prettier reformats it to be under this limit by moving the right-hand side to the new line
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.
Yeah I understand this is a result of applying the > 80 chars rule, I just find that less readable. But that's a pretty minor corner-case.
className='account__avatar-overlay' style={{ width: size, height: size }} | ||
className="account__avatar-overlay" |
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.
Afaik, this quote style is the opposite of the code style we've been enforcing since the beginning of the project.
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.
This can be changed using the jsxSingleQuote
option if needed, but I think double quotes are the standard nowadays in JSX, as they are in HTML.
const { timestamp } = props; | ||
const delta = (new Date(timestamp)).getTime() - state.now; | ||
const unitDelay = getUnitDelay(selectUnits(delta)); | ||
const unitRemainder = Math.abs(delta % unitDelay); | ||
const { timestamp } = props; | ||
const delta = new Date(timestamp).getTime() - state.now; | ||
const unitDelay = getUnitDelay(selectUnits(delta)); | ||
const unitRemainder = Math.abs(delta % unitDelay); |
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.
Afaik this is another change from a coding style we were leaning towards. I don't have a strong opinion either way, but I'm wary of changing existing rules, especially if we end up applying this to JS files as well.
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.
I think one of the goals that prettier seems to aim for is to minimize the git noise. Since if the longest variable changes length, the rest of the lines would need to be re-written, so there is no option to use this style with prettier.
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.
That does make sense. I'd just want to have @Gargron to ack on this has he has explicitly asked for the current code style in the past (when our toolchain did not enforce either code style).
I would really like this to be merged soon as more Typescript is appearing in the codebase. @nschonni could you enable Do you have any other remarks we need to act on @ClearlyClaire? |
This pull request has merge conflicts that must be resolved before it can be merged. |
With my glitch-soc maintainer hat, in addition to my earlier comment, I'd like to avoid bundling automatic changes with manual changes (e.g. removing the iOS detection thing). The reason is glitch-soc works by maintaining a copy of the front-end files with local modifications, and trying to apply a large-scale change like automatic linting is most likely going to not work, but if I know this is just automatic linting, I can run the linter separately. However, if the commit contains both automatic changes and manual changes, I cannot do that (and Mastodon PRs end up squashed in a single commit, so that would end up as a single commit). |
Extracted from @nshonni's work here: mastodon#23631
This pull request has resolved merge conflicts and is ready for review. |
Thanks a lot for your work on this @nschonni ❤️ |
Adds the ESLint prettier configs and removes rules shadowed by that plugin https://github.com/prettier/eslint-config-prettier/blob/main/index.js
Ran the noisy cleanup as part of the second commit