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

chore: enable unbound-method eslint rule #33605

Merged
merged 5 commits into from
Feb 28, 2025
Merged

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Feb 27, 2025

Unbound method calls using this are likely to have unintended effects.

Here is an example with static methods, but the same thing applies to object methods:

class Class {
  public static staticMethod() {
    this.otherStaticMethod()
  }

  public static otherStaticMethod() { }
}

// ✅ valid
Class.staticMethod();

// ❌ boom
const x = Class.staticMethod;
x();

When assigning a method to a variable, you need to take extra care and this linter rule is going to remind you.

This rule also catches a lot of cases were we meant to call a function but accidentally didn't:

// Actual examples of unintentional code in our code base
list.map(x => x.toString).join(', ')

expect(x).toBeTruthy

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Unbound method calls using `this` are likely to have unintended effects.

Here is an example with static methods, but the same thing applies
to object methods:

```ts
class Class {
  public static staticMethod() {
    this.otherStaticMethod()
  }

  public static otherStaticMethod() { }
}

// ✅ valid
Class.staticMethod();

// ❌ boom
const x = Class.staticMethod;
x();
```

When assigning a method to a variable, you need to take extra
care and this linter rule is going to remind you.
@rix0rrr rix0rrr requested a review from a team February 27, 2025 11:18
@github-actions github-actions bot added the p2 label Feb 27, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team February 27, 2025 11:19
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 27, 2025
@rix0rrr rix0rrr requested a review from a team as a code owner February 27, 2025 13:51
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 82.21%. Comparing base (127059e) to head (49d78a5).
Report is 1 commits behind head on main.

❌ Your patch status has failed because the patch coverage (50.00%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33605   +/-   ##
=======================================
  Coverage   82.21%   82.21%           
=======================================
  Files         119      119           
  Lines        6876     6876           
  Branches     1162     1162           
=======================================
  Hits         5653     5653           
  Misses       1120     1120           
  Partials      103      103           
Flag Coverage Δ
suite.unit 82.21% <50.00%> (ø)

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

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 82.21% <50.00%> (ø)

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)

@rix0rrr rix0rrr added the pr-linter/exempt-codecov The PR linter will not require codecov checks to pass label Feb 27, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 27, 2025 14:05

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 28, 2025
Copy link
Contributor

mergify bot commented Feb 28, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 49d78a5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit f44209e into main Feb 28, 2025
18 of 20 checks passed
Copy link
Contributor

mergify bot commented Feb 28, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot deleted the huijbers/unbound-method branch February 28, 2025 11:41
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member pr-linter/exempt-codecov The PR linter will not require codecov checks to pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants