| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Hmm, yarn lint:ts --fix still makes some conflicting changes. Hang on for one more commit. |
Sorry, something went wrong.
|
PatternFly-React preview: https://patternfly-react-pr-2810.surge.sh |
Sorry, something went wrong.
|
Ok, this should be all set now. I ran yarn lint:ts --fix and it had some more changes to make, then ran yarn prettier again and it made no changes, so they don't conflict. |
Sorry, something went wrong.
There was a problem hiding this comment.
🎊 🎉
Sorry, something went wrong.
|
Rebased on master |
Sorry, something went wrong.
|
Let's try to do get this in post code-freeze next week after one final rebase. Things are a little hectic now. |
Sorry, something went wrong.
|
Fair enough 🙂 |
Sorry, something went wrong.
|
(moved this comment to the bottom to track latest commits) |
Sorry, something went wrong.
|
Hmm.. @redallen I'm having trouble parsing the errors in the CircleCI log, do you know why this would be failing CI? I didn't make any different configuration changes compared to before the rebase. |
Sorry, something went wrong.
|
@mturley During yarn build it's something to do with Chart types: src/components/ChartVoronoiContainer/ChartVoronoiContainer.tsx(153,6): error TS2322: Type '{ activateData?: boolean; activateLabels?: boolean; disable?: boolean; labels?: (point: any, index: number, points: any[]) => string; mouseFollowTooltips?: boolean; onActivated?: (points: any[], props: VictoryVoronoiContainerProps) => void; ... 14 more ...; theme: ChartThemeDefinitionInterface; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<VictoryVoronoiContainer> & Readonly<VictoryVoronoiContainerProps> & Readonly<{ children?: ReactNode; }>'.
Property 'className' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<VictoryVoronoiContainer> & Readonly<VictoryVoronoiContainerProps> & Readonly<{ children?: ReactNode; }>'
Charts has been touched a lot lately, so I'd recheck the merge conflicts for that file. Worst case, checkout master's version and then relint the file. |
Sorry, something went wrong.
Hmm, that's what I did (I cherry-picked only the config changes and relinted the whole repo). I'll take a closer look at that file, thanks! |
Sorry, something went wrong.
| // Note: theme is required by voronoiContainerMixin, but @types/victory is missing a prop type | ||
| // @ts-ignore | ||
| return <VictoryVoronoiContainer className={chartClassName} labelComponent={chartLabelComponent} theme={theme} {...rest} />; | ||
| return ( |
There was a problem hiding this comment.
Ahh, @redallen it looks like it was this @ts-ignore not being applied anymore because the offending code was moved down a line by prettier. I'll add a prettier-ignore on the same line, and we might have to do that in the future where we need @ts-ignore on a long line.
It's weird that we can't just ts-ignore multiple lines... looks like an open issue: microsoft/TypeScript#19573
Sorry, something went wrong.
|
I rebased this on the latest master, and squashed it into 3 commits to make it easier to rebase in case we need to do so again:
|
Sorry, something went wrong.
|
@dgutride do you think it would make sense to try and merge this (after a final rebase) immediately after this week's code freeze ends, to minimize conflicts with other PRs? It doesn't change our dist, but it touches a lot of files. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
There was a problem hiding this comment.
Not a fan of how Prettier reformats the code. Some code is less readable, IMO -- formatted for a reason. Although, the yarn lint:ts --fix is much needed. Those changes in chart changes look ok.
Sorry, something went wrong.
|
@dlabrecq what formatting opinions of Prettier do you dislike? We can reconfigure it: https://prettier.io/docs/en/options.html. I'm not really concerned about how the code is formatted as long as it's formatted consistently. Messy indentation was my main gripe. |
Sorry, something went wrong.
|
I do agree somewhat that Prettier tries too much to fit the most code into every line, but I think maybe that could be helped by lowering the print-width option. They actually recommend that you don't exceed 80 characters on that option (see the yellow box at the top of the options docs), and we have it set to 120. I would be open to shortening this to 80 or 100 (and then obviously there would be many lines which would end up longer than that). |
Sorry, something went wrong.
|
@mturley I often use separate lines when I destructure multiple items or sometimes when importing long names, but that's just my preference to make things more readable. It's not a big deal, just not a fan. I am a big fan of running yarn lint:ts --fix, tho |
Sorry, something went wrong.
|
I agree actually, those sound like good reasons to disagree with Prettier. We could lower the print width to make that less of an issue, and in extreme cases we could use // prettier-ignore if it's being really fussy. This PR doesn't automatically run it going forward though, so we can always run it and then change things back if we disagree with it. |
Sorry, something went wrong.
|
@dlabrecq I'll bug you just one last time (I know you're not thinking of this as a big deal), but just for comparison's sake I made a few separate branches and ran the same process with the print-width set to 100 characters (mturley@c5fbfe4) and set to 80 characters (mturley@fc02c3b). The lower the print-width, the more readable a lot of code gets, but files end up larger in terms of lines of code. Do you have an opinion on whether either of these would be better than the 120-character width in this PR? |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks better. Still some odd indentations in some places, but not a deal breaker.
Sorry, something went wrong.
| ? height > defaultSize | ||
| ? value + (height - defaultSize) * scale | ||
| : value - (defaultSize - height) * scale | ||
| : width > defaultSize |
There was a problem hiding this comment.
This indentation looks much better compared to the others I noted
Sorry, something went wrong.
| | 'triangleUp' | ||
| | 'dash' | ||
| | 'threshold' | ||
| | Function; |
There was a problem hiding this comment.
Better...
Sorry, something went wrong.
| ? defaultPadding.top * 0.5 + (defaultPadding.bottom * 0.5 - defaultPadding.bottom) - 25 | ||
| : title | ||
| ? -defaultPadding.bottom + 60 | ||
| : -defaultPadding.bottom; |
There was a problem hiding this comment.
This indentation looks a little off?
Sorry, something went wrong.
There was a problem hiding this comment.
It looks like Prettier will indent a nested ternary if it is nested within the true-branch (foo ? bar ? 1 : 2 : 3) but not if it is trailing / nested in the false-branch (foo ? 1 : bar ? 2 : 3). This is a bit weird but seems reasonable to me... to be honest though, maybe we should avoid nested ternary expressions unless we use parentheses to make them more clear. Maybe that would help here.
Sorry, something went wrong.
There was a problem hiding this comment.
Looks like this is a subject of debate in Prettier: prettier/prettier#5814 (blog post explaining their decision to do it that way: https://prettier.io/blog/2018/11/07/1.15.0.html#flatten-else-branch-for-nested-ternaries-5039-by-suchipi-5272-by-duailibe-5333-by-ikatyang)
Sorry, something went wrong.
There was a problem hiding this comment.
Huh. Adding parens around the second expression there, Prettier removes them. Maybe that's a case where // prettier-ignore would be useful if we need an exception to make that code extra clear.
Sorry, something went wrong.
There was a problem hiding this comment.
I didn't realize // prettier-ignore was available. That could be quite useful for those couple of weird issues
Sorry, something went wrong.
There was a problem hiding this comment.
Agreed. You can even configure a .prettierignore file to ignore entire files/directories if necessary
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
|
Your changes have been released in:
Thanks for your contribution! 🎉 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What:
Because we realized that some important code-formatting-related TSLint rules are broken, @redallen and I decided that it would be appropriate to add Prettier to our linter, and run it on existing code.
This PR:
Hopefully this will help to make our code a little more readable and consistent going forward!
cc @redallen
Closes #2362 (for real this time)