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

feat(eslint-plugin): [class-methods-use-this] add extension rule #6457

Merged
merged 3 commits into from Jul 18, 2023

Conversation

bradzacher
Copy link
Member

@bradzacher bradzacher commented Feb 13, 2023

PR Checklist

Overview

This adds a standard AST fork of the base rule that can be configured to ignore one or both of the cases where a method has the override keyword, or the parent class implements an interface.

Based on #7260

@bradzacher bradzacher added the enhancement: new base rule extension New base rule extension required to handle a TS specific case label Feb 13, 2023
@nx-cloud
Copy link

nx-cloud bot commented Feb 13, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 71620da. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


🟥 Failed Commands
Node 18 - nx test eslint-plugin
Node 14 - nx test eslint-plugin --coverage=false
✅ Successfully ran 45 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@netlify
Copy link

netlify bot commented Feb 13, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 04b4d2c
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/64b65f29f8c4f70009032a25
😎 Deploy Preview https://deploy-preview-6457--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bradzacher bradzacher marked this pull request as draft March 13, 2023 02:20
@JoshuaKGoldberg
Copy link
Member

@bradzacher is this still something you have time to work on?

@bradzacher
Copy link
Member Author

I think it was almost done if memory serves me correctly. I'll have a look today.

@bradzacher bradzacher force-pushed the 1103-ignore-methods-on-override branch from 71620da to b110ee9 Compare July 18, 2023 09:24
@nx-cloud
Copy link

nx-cloud bot commented Jul 18, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 41da796. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 35 targets

Sent with 💌 from NxCloud.

@bradzacher bradzacher force-pushed the 1103-ignore-methods-on-override branch from b110ee9 to 04b4d2c Compare July 18, 2023 09:45
@bradzacher bradzacher changed the base branch from main to update-getFunctionHeadLoc July 18, 2023 09:45
@bradzacher bradzacher force-pushed the 1103-ignore-methods-on-override branch from 04b4d2c to 4527fb7 Compare July 18, 2023 10:07
@bradzacher bradzacher marked this pull request as ready for review July 18, 2023 10:10
@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

Merging #6457 (41da796) into update-getFunctionHeadLoc (be95293) will decrease coverage by 0.09%.
The diff coverage is 69.35%.

Additional details and impacted files
@@                      Coverage Diff                      @@
##           update-getFunctionHeadLoc    #6457      +/-   ##
=============================================================
- Coverage                      87.48%   87.40%   -0.09%     
=============================================================
  Files                            379      381       +2     
  Lines                          13250    13311      +61     
  Branches                        3911     3933      +22     
=============================================================
+ Hits                           11592    11634      +42     
- Misses                          1279     1292      +13     
- Partials                         379      385       +6     
Flag Coverage Δ
unittest 87.40% <69.35%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ges/eslint-plugin/src/util/getStaticStringValue.ts 23.52% <23.52%> (ø)
.../eslint-plugin/src/rules/class-methods-use-this.ts 86.36% <86.36%> (ø)
packages/eslint-plugin/src/util/isNullLiteral.ts 100.00% <100.00%> (ø)

> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/your-rule-name** for documentation.
> See **https://typescript-eslint.io/rules/RULE_NAME_REPLACEME** for documentation.
Copy link
Member

Choose a reason for hiding this comment

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

unrelated?

Copy link
Member Author

Choose a reason for hiding this comment

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

it was just me fleshing out the template
i noticed this was super easy to miss this so I made it more obvious!

Copy link
Member

Choose a reason for hiding this comment

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

I like it :)

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Super! ✨

ACK on the pulling in code from upstream as-is. I trust you on filling in the missing unit tests coverage if needed for the rule.

pushContext();
},
'FunctionDeclaration:exit'(): void {
popContext();
Copy link
Member

Choose a reason for hiding this comment

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

[Testing] Was it intentional that these bits aren't covered by unit tests?

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 all the tests from the base rule - so either it's not covered by the base tests or code cov is wrong again. IDK

Copy link
Member

Choose a reason for hiding this comment

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

If ESLint core isn't testing these lines, who are we to dispute??

Base automatically changed from update-getFunctionHeadLoc to main July 18, 2023 13:30
@bradzacher bradzacher dismissed JoshuaKGoldberg’s stale review July 18, 2023 13:30

The base branch was changed.

@bradzacher bradzacher merged commit 18ea3b1 into main Jul 18, 2023
43 of 45 checks passed
@bradzacher bradzacher deleted the 1103-ignore-methods-on-override branch July 18, 2023 13:34
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: new base rule extension New base rule extension required to handle a TS specific case
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[class-methods-use-this] Allow when required by interface
2 participants