Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

refactor: convert Engine component to hooks #233

Merged
merged 7 commits into from
Oct 31, 2019

Conversation

bighuggies
Copy link
Contributor

Type: refactor

Description:

Refactored <Engine /> to a functional component using hooks, similar to #150 and #156

Also unrolled the reduce function, improving readability.

Snapshots are the same and also tested locally by updating the hardcoded engine data:
image

Resolves #116

@codecov
Copy link

codecov bot commented Oct 28, 2019

Codecov Report

Merging #233 into master will decrease coverage by 0.13%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #233      +/-   ##
==========================================
- Coverage   88.98%   88.85%   -0.14%     
==========================================
  Files         139      139              
  Lines         926      915      -11     
  Branches      159      160       +1     
==========================================
- Hits          824      813      -11     
  Misses         88       88              
  Partials       14       14
Impacted Files Coverage Δ
src/components/Engines/Engines.tsx 100% <100%> (ø) ⬆️

'node-JS': engines.node,
'NPM-version': engines.npm,
};
const engines = packageMeta && packageMeta.latest && packageMeta.latest.engines;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw that TypeScript 3.7 is specified in package.json, but ?. doesn't seem to be supported by the tooling yet :(

Copy link
Member

Choose a reason for hiding this comment

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

That's odd, I did not tried yet. I'll double check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it was prettier that was giving me issues, 1.19 with support for 3.7 isn't released yet: https://github.com/prettier/prettier/blob/master/CHANGELOG.unreleased.md

Copy link
Contributor

Choose a reason for hiding this comment

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

Really? 😞 I didn't test the new features yet, but I thought we could already use it ... so let's update prettier :D

src/components/Engines/Engines.test.tsx Outdated Show resolved Hide resolved
src/components/Engines/Engines.test.tsx Outdated Show resolved Hide resolved
@bighuggies bighuggies requested a review from a team October 29, 2019 21:50
{engines.node && (
<Grid item={true} xs={6}>
<List subheader={<StyledText variant={'subtitle1'}>{'node JS'}</StyledText>}>
<EngineListItem button={true}>
Copy link
Member

Choose a reason for hiding this comment

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

You can remove button={true}

{engines.npm && (
<Grid item={true} xs={6}>
<List subheader={<StyledText variant={'subtitle1'}>{'NPM version'}</StyledText>}>
<EngineListItem button={true}>
Copy link
Member

Choose a reason for hiding this comment

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

Same here, You can remove button={true}

Copy link
Member

Choose a reason for hiding this comment

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

This should be enforced by eslint, I'd suggest let it go and add the plugin or rule and change all places at a time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think @ayusharma is referring to the fact that the EngineListItem styled component doesn't accept a button prop.

I left it because removing it breaks the snapshot tests, which I consider bad practice when doing a refactor like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi all! I just checked and the ListItem component from Material UI does accepted the prop button..we should change it if we don't want to use the ButtonBase only :
image

So IMO it's fine if you leave like it is now...we will check all cases in our design system

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@priscilawebdev priscilawebdev Oct 31, 2019

Choose a reason for hiding this comment

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

regarding this lint rule, I believe we should discuss about it. I find this rule very annoying ... I also prefer to write button only

src/components/Engines/Engines.tsx Show resolved Hide resolved
src/components/Engines/Engines.test.tsx Show resolved Hide resolved
@bighuggies bighuggies requested a review from ayusharma October 30, 2019 11:15
Copy link
Contributor

@priscilawebdev priscilawebdev left a comment

Choose a reason for hiding this comment

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

@bighuggies thanks for contributing :-) I really like that you added a print of your changes.. I will do the same next time. Having something visual helps during review

priscilawebdev
priscilawebdev previously approved these changes Oct 30, 2019
Copy link
Member

@juanpicado juanpicado left a comment

Choose a reason for hiding this comment

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

Great !!! 🚀 👻 👻 🎃 🎃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using React Hooks (Refactoring, New Components)
5 participants