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

Update to latest sewing-kit #1344

Merged
merged 3 commits into from
May 8, 2019
Merged

Update to latest sewing-kit #1344

merged 3 commits into from
May 8, 2019

Conversation

BPScott
Copy link
Member

@BPScott BPScott commented Apr 24, 2019

WHY are these changes introduced?

Keeping up to date, includes new linting rules mostly, meaning when eslint-plugin-shopify jumps to use the new typescript parser there will be less effort to update it and get onto a newer typescript version.

WHAT is this pull request doing?

Update a few dependencies that we want to keep in sync with sewing-kit

Use sewing-kit optimize to optimize svgs instead of maintaining our
own script which does the same thing.


An update to babel-plugin-shopify has changed the default value of "useBuiltIns". We now explicitly set "useBuildIns: 'entry'" in our babel.config.js to maintain the same behaviour as previously. Not doing this results in adding ~50kb extra polyfill stuff.

This doesn't affect polaris when used as part of sewing-kit because sk doesn't use the stand-alone build.

To Review

This PR is split into multiple commits, one of which is all the automatic fixes from running yarn run format which contains the majority of the code changes (apart from the yarn.lock file). It might be easier to look at the commits one-by-one rather than scrolling through a load of automatic fixes.

To Test

  • Ensure tests / linting / type checks pass
  • Ensure aria labels still appear as you'd expect in the components where I had to add translations

@BPScott BPScott temporarily deployed to polaris-react-pr-1344 April 24, 2019 13:01 Inactive
@BPScott BPScott changed the title Update to latest sewing-kit [WIP] Update to latest sewing-kit Apr 24, 2019
@BPScott BPScott temporarily deployed to polaris-react-pr-1344 May 1, 2019 17:28 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1344 May 3, 2019 11:40 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1344 May 3, 2019 11:50 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1344 May 3, 2019 12:44 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1344 May 3, 2019 12:48 Inactive
@BPScott BPScott changed the title [WIP] Update to latest sewing-kit Update to latest sewing-kit May 3, 2019
@BPScott BPScott requested a review from AndrewMusgrave May 3, 2019 13:06
@@ -56,20 +59,24 @@
{
"files": ["**/*.test.{ts,tsx}"],
"rules": {
"jest/no-truthy-falsy": "off",
"shopify/jsx-no-hardcoded-content": "off",
Copy link
Member Author

Choose a reason for hiding this comment

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

We want to check for hardcoded content to make sure we're using translated strings in our source, but we don't care about that in our tests and examples.

"shopify/no-ancestor-directory-import": "error",
"shopify/react-prefer-private-members": "off",
Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes we do actually want pubic functions

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should enable this and add an ignore whenever public is used, which is only in Banner i think?

Copy link
Member Author

@BPScott BPScott May 8, 2019

Choose a reason for hiding this comment

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

There's 36 violations currently, 1/3 of which are false positives warning about examples written in JS when you can't even use private members (bug raised: Shopify/web-configs#110), and many of the others seem related to legacy context stuff - subscribe/unsubscribe stuff. I don't know enough about the code they touch to know what should be private or not.

I'd totally be open to reevaluating this in the future, but I don't want to touch them now :)

"import/named": "off",
"import/no-named-as-default": "off",
"react/button-has-type": "off",
"react/no-array-index-key": "off",
"react/jsx-fragments": ["error", "element"],
"shopify/jsx-no-complex-expressions": "off",
"shopify/jsx-prefer-fragment-wrappers": "off",
Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes we want empty wrapping divs

@@ -28,13 +27,16 @@
"allowBlockStart": false
}
],
"babel/no-unused-expressions": "off",
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't seem to work in the way that I'd expect

@@ -56,20 +59,24 @@
{
"files": ["**/*.test.{ts,tsx}"],
"rules": {
"jest/no-truthy-falsy": "off",
Copy link
Member Author

Choose a reason for hiding this comment

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

we use isTruthy() / isFalsy() A LOT and I don't want to go and refactor everything

Copy link
Member

@AndrewMusgrave AndrewMusgrave left a comment

Choose a reason for hiding this comment

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

Awesome stuff 😄 most of the comments are about the same, let me know what you think.

@@ -22,7 +22,7 @@ class Modifier extends React.Component<ComposedProps, {}> {
return null;
}

state = {};
state: any = {};
Copy link
Member

Choose a reason for hiding this comment

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

We can probably 🔥 this and change line 14 to never

Copy link
Member Author

Choose a reason for hiding this comment

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

I've got no idea what this does. So I elected for not changing the code and just making typescript happy. It looks like this component still has state it's just defined in the passed setMobileUserMenuProps function.

Thinking a little deeper, matching this type with the second arg of React.Component<ComposedProps, {}> is a better plan. I've changed it to state: {}.

@AndrewMusgrave
Copy link
Member

I requested translations and since the translations have already been released feel free to mark as async when you want to 🚢

@danrosenthal
Copy link
Contributor

What's the status on this PR @BPScott?

@BPScott BPScott temporarily deployed to polaris-react-pr-1344 May 6, 2019 21:26 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1344 May 6, 2019 21:35 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1344 May 7, 2019 09:56 Inactive
@BPScott
Copy link
Member Author

BPScott commented May 7, 2019

I've rebased this atop master, fixed additional issues (autofixing jest's toEqual to toStrictEqual) and addressed PR feedback. I've also updated the babel config to retain the old useBuiltIns behaviour, which means the bundle size is unaffected (previously it grew by a substantial amount).

I've responded to your comments and this is now read for re-review @AndrewMusgrave

Copy link
Member

@AndrewMusgrave AndrewMusgrave left a comment

Choose a reason for hiding this comment

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

After a squash you should be good to go 🎉 😄

"shopify/no-ancestor-directory-import": "error",
"shopify/react-prefer-private-members": "off",
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should enable this and add an ignore whenever public is used, which is only in Banner i think?


listenerMap.keyup({keyCode: Key.Escape});
afterEach(() => {
(document.addEventListener as jest.Mock).mockRestore();
Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with this, however an alternative could have been

let removeEventListener: jest.SpyInstace;
...
removeEventListener = jest.spyOn(...)
...
removeEventListener.mockRestore

BPScott added 3 commits May 8, 2019 11:26
Update a few dependencies that we want to keep in sync with sewing-kit

Use `sewing-kit optimize` to optimize svgs instead of maintaining our
own script which does the same thing.
@BPScott BPScott requested a deployment to polaris-react-pr-1344 May 8, 2019 09:28 Abandoned
@BPScott BPScott merged commit 4a2a7fe into master May 8, 2019
@BPScott BPScott deleted the bump-sk branch May 8, 2019 09:38
@chloerice chloerice temporarily deployed to production May 8, 2019 19:57 Inactive
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.

4 participants