Skip to content
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

Upgrade to wp-prettier 2.2.1 #47950

Merged
merged 3 commits into from Dec 2, 2020
Merged

Upgrade to wp-prettier 2.2.1 #47950

merged 3 commits into from Dec 2, 2020

Conversation

jsnajdr
Copy link
Member

@jsnajdr jsnajdr commented Dec 2, 2020

This is how Calypso codebase gets reformatted after upgrade to wp-prettier@2.2.1. I was originally testing with a local build, so the PR contained only the formatting changes and not the package upgrade. Later after verifying the upgrade both with Calypso and Gutenberg, I published wp-prettier@2.2.1-beta-§ to NPM and updated our package.json accordingly.

Notable changes:

a( b, (
  c,
  d
) => {
  e();
} );

no longer breaks the argument list of the inline arrow function and formats the code more nicely:

a(
  b,
  ( c, d ) => {
    e();
  }
);

This is an expected change that's been announced in Prettier 2.2.0 changelog.

Then there's fixed arrow function formatting inside Styled Components template literal:

styled(A)`
  @media (aaaaaaaaaaaaa) {
	z-index: ${(props) => (props.isComplete ? '1' : '0')};
  }
`;

Also expected, it's a bug fixed in 2.1.2 (prettier/prettier#9136) after our report.

Finally, Prettier stopped breaking type parameters in long class ... extends statements.

Before:

export default class SiteLevelPurchasesErrorBoundary extends React.Component<
  SiteLevelPurchasesErrorBoundaryProps
>

After:

export default class SiteLevelPurchasesErrorBoundary extends React.Component< SiteLevelPurchasesErrorBoundaryProps >

@jsnajdr jsnajdr requested review from sirreal, scinos and a team December 2, 2020 10:28
@jsnajdr jsnajdr self-assigned this Dec 2, 2020
@matticbot
Copy link
Contributor

@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Dec 2, 2020
@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Contributor

@scinos scinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes make sense to me.

@jsnajdr jsnajdr marked this pull request as ready for review December 2, 2020 12:19
@jsnajdr jsnajdr requested a review from a team as a code owner December 2, 2020 12:19
@jsnajdr
Copy link
Member Author

jsnajdr commented Dec 2, 2020

Thanks @scinos for approving 👍 Now I also published the package to NPM and added another commit that upgrades wp-prettier to the new package. Can you please have a second look before I merge the PR?

Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visual inspection of changes looks good, thanks 👍

@scinos
Copy link
Contributor

scinos commented Dec 2, 2020

LGTM. Code Style errors seems to be unrelated.

@jsnajdr
Copy link
Member Author

jsnajdr commented Dec 2, 2020

Code Style errors seems to be unrelated.

One of them are missing JSDoc params that are trivial and zero-risk to fix. So I pushed a commit with that.

The second file with violations is more interesting. It's in an error boundary React component written by @nbloomf where a TypeScript ESLint rule complains about return types of methods not being declared on the component's methods:

Missing return type on function. (@typescript-eslint/explicit-module-boundary-types)

In general, this rule makes sense: it encourages that types that are part of public APIs are explicitly named and declared, instead of just being anonymous types inferred from code.

But here, the offending methods are methods of the ReactComponent superclass:

  • getDerivedStateFromError
  • componentDidCatch
  • render

It's already pretty clear what the types are supposed to be, and they have names and definitions. There's no need to repeat what a return type of render is. I think that the rule is overreaching here. Cc @sirreal if he has any insights.

@jsnajdr jsnajdr merged commit 6fc4918 into trunk Dec 2, 2020
@jsnajdr jsnajdr deleted the try/wp-prettier-2.2.1 branch December 2, 2020 14:37
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants