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 #165

Merged
merged 4 commits into from
Feb 27, 2025

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.


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:17
@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.41%. Comparing base (f925551) to head (dcc31df).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #165      +/-   ##
==========================================
- Coverage   84.60%   84.41%   -0.19%     
==========================================
  Files         198      198              
  Lines       35400    35401       +1     
  Branches     4569     4543      -26     
==========================================
- Hits        29951    29885      -66     
- Misses       5295     5373      +78     
+ Partials      154      143      -11     
Flag Coverage Δ
suite.unit 84.41% <100.00%> (-0.19%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rix0rrr rix0rrr added the pr/exempt-integ-test Skips the integ test steps if set. label Feb 27, 2025
@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Feb 27, 2025
Merged via the queue into main with commit f0677df Feb 27, 2025
11 checks passed
@aws-cdk-automation aws-cdk-automation deleted the huijbers/unbound-method branch February 27, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/exempt-integ-test Skips the integ test steps if set.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants