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

Enable the new rule react/no-unused-class-component-methods and fix eslint errors #3662

Conversation

julienw
Copy link
Contributor

@julienw julienw commented Nov 22, 2021

I tried it and found it was useful to do some code maintenance and clean up actually unused instance and class methods and variables.

I did some manual testing and everything seems to work just fine :-)

deploy preview

@julienw julienw force-pushed the add-react-no-unused-class-component-methods branch from 36d6b5f to 1f3c1cb Compare November 22, 2021 13:53
@julienw julienw changed the title Enable the rule new react/no-unused-class-component-methods and fix eslint errors Enable the new rule react/no-unused-class-component-methods and fix eslint errors Nov 22, 2021
@julienw julienw requested a review from canova November 22, 2021 13:54
version: '15.0',
flowVersion: '0.63.1',
version: '17.0',
flowVersion: '0.96.0',
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'm not exactly sure about the usefulness of these properties, but seeing them outdated always makes me crazy so I took the opportunity to update these. It's supposed to trigger different behaviors in the eslint react plugin, but I'm not so sure.

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 not sure if it's because of this, but I started to get 4 additional warnings when I tested this on my local.

profiler/src/test/components/StackChart.test.js
  240:3  warning  Test has no assertions  jest/expect-expect
  244:3  warning  Test has no assertions  jest/expect-expect

profiler/src/test/components/TrackContextMenu.test.js
  428:5  warning  Test has no assertions  jest/expect-expect
  540:5  warning  Test has no assertions  jest/expect-expect

Edit: Well, actually it looks like I'm getting that on the main branch as well. I guess I didn't see them earlier because I didn't do a yarn install properly earlier 🤷‍♂️ . I guess we can fix this in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I filed this yesterday about that: jest-community/eslint-plugin-jest#988
I think this is due to the latest upate...
This is unfortunate because they skip it for "todo", see jest-community/eslint-plugin-jest#954 ! Then it may be very easy to fix there...

Copy link
Member

Choose a reason for hiding this comment

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

Oh, interesting. This is definitely something they should fix. Also, maybe we should change these tests to it.todo as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it.todo would be more appropriate in this case yeah

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. Also to be clear, I wasn't talking for this PR, we can fix these in another PR.

@julienw julienw removed the request for review from canova November 22, 2021 13:55
@codecov
Copy link

codecov bot commented Nov 22, 2021

Codecov Report

Merging #3662 (ee276a5) into main (98493ee) will increase coverage by 0.01%.
The diff coverage is n/a.

❗ Current head ee276a5 differs from pull request most recent head 34ad55b. Consider uploading reports for the commit 34ad55b to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3662      +/-   ##
==========================================
+ Coverage   88.77%   88.79%   +0.01%     
==========================================
  Files         259      259              
  Lines       21748    21731      -17     
  Branches     5566     5563       -3     
==========================================
- Hits        19307    19296      -11     
+ Misses       2262     2257       -5     
+ Partials      179      178       -1     
Impacted Files Coverage Δ
src/components/app/MenuButtons/Permalink.js 81.81% <ø> (-1.52%) ⬇️
src/components/app/MenuButtons/Publish.js 80.20% <ø> (+3.73%) ⬆️
src/components/app/ProfileDeleteButton.js 93.02% <ø> (+1.91%) ⬆️
src/components/flame-graph/FlameGraph.js 90.78% <ø> (ø)
src/components/js-tracer/index.js 100.00% <ø> (ø)
...rc/components/shared/ButtonWithPanel/ArrowPanel.js 91.66% <ø> (ø)
src/components/shared/TrackSearchField.js 53.33% <ø> (ø)
src/components/shared/TreeView.js 77.87% <ø> (ø)
src/components/shared/VirtualList.js 93.26% <ø> (ø)
src/components/stack-chart/Canvas.js 94.41% <ø> (-0.07%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98493ee...34ad55b. Read the comment docs.

@@ -152,10 +152,6 @@ export class ProfileDeletePanel extends PureComponent<PanelProps, PanelState> {
}
};

onCancelDeletion = () => {
this.props.onProfileDeleteCanceled();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is used directly in the render function

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense.

@julienw julienw requested a review from canova November 22, 2021 15:27
Copy link
Member

@canova canova left a comment

Choose a reason for hiding this comment

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

That looks like a nice clean-up, thanks! One important thing before merging this is to not forget to rebase this PR and fix the additional errors before landing. Because I added a new class that includes focus function that's not called directly (in the TrackSearchField.js file). We should also ignore this function, otherwise will get perma errors.

@@ -152,10 +152,6 @@ export class ProfileDeletePanel extends PureComponent<PanelProps, PanelState> {
}
};

onCancelDeletion = () => {
this.props.onProfileDeleteCanceled();
Copy link
Member

Choose a reason for hiding this comment

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

That makes sense.

version: '15.0',
flowVersion: '0.63.1',
version: '17.0',
flowVersion: '0.96.0',
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 not sure if it's because of this, but I started to get 4 additional warnings when I tested this on my local.

profiler/src/test/components/StackChart.test.js
  240:3  warning  Test has no assertions  jest/expect-expect
  244:3  warning  Test has no assertions  jest/expect-expect

profiler/src/test/components/TrackContextMenu.test.js
  428:5  warning  Test has no assertions  jest/expect-expect
  540:5  warning  Test has no assertions  jest/expect-expect

Edit: Well, actually it looks like I'm getting that on the main branch as well. I guess I didn't see them earlier because I didn't do a yarn install properly earlier 🤷‍♂️ . I guess we can fix this in another PR.

@julienw julienw force-pushed the add-react-no-unused-class-component-methods branch from 1f3c1cb to ee276a5 Compare November 24, 2021 15:13
@julienw julienw enabled auto-merge (squash) November 24, 2021 15:46
@julienw julienw merged commit 7401aaf into firefox-devtools:main Nov 24, 2021
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

2 participants