-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
@@ -56,20 +59,24 @@ | |||
{ | |||
"files": ["**/*.test.{ts,tsx}"], | |||
"rules": { | |||
"jest/no-truthy-falsy": "off", | |||
"shopify/jsx-no-hardcoded-content": "off", |
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 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", |
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.
Sometimes we do actually want pubic functions
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 wonder if we should enable this and add an ignore whenever public is used, which is only in Banner
i think?
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.
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", |
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.
Sometimes we want empty wrapping divs
@@ -28,13 +27,16 @@ | |||
"allowBlockStart": false | |||
} | |||
], | |||
"babel/no-unused-expressions": "off", |
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 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", |
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 use isTruthy() / isFalsy() A LOT and I don't want to go and refactor everything
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.
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 = {}; |
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 probably 🔥 this and change line 14 to never
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'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: {}
.
I requested translations and since the translations have already been released feel free to mark as |
What's the status on this PR @BPScott? |
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 |
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.
After a squash you should be good to go 🎉 😄
"shopify/no-ancestor-directory-import": "error", | ||
"shopify/react-prefer-private-members": "off", |
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 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(); |
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'm ok with this, however an alternative could have been
let removeEventListener: jest.SpyInstace;
...
removeEventListener = jest.spyOn(...)
...
removeEventListener.mockRestore
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.
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 ourown 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