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

refactor(context-zone-peer-dep): fix eslint warnings #5371

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chancancode
Copy link
Contributor

Which problem is this PR solving?

Fixed this eslint warning:

    /home/runner/work/opentelemetry-js/opentelemetry-js/packages/opentelemetry-context-zone-peer-dep/src/util.ts
      22:39  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

Ref #5365

Short description of the changes

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • eslint

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

    /home/runner/work/opentelemetry-js/opentelemetry-js/packages/opentelemetry-context-zone-peer-dep/src/util.ts
      22:39  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

Ref open-telemetry#5365
@chancancode chancancode requested a review from a team as a code owner January 24, 2025 19:28
* @param obj - The object to check.
*/
export function isListenerObject(obj: any = {}): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parameter default seems pointless as that will just always return false. Removed it since this is a private utility not a public export.

typeof obj.addEventListener === 'function' &&
'removeEventListener' in obj &&
typeof obj.removeEventListener === 'function'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are alternatives without changing the runtime code (which can impose a small runtime cost), but this seemed the most straightforward/clear, and doesn't seem like the micro performance cost should matter all that much.

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.54%. Comparing base (f927e82) to head (e535f4a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5371   +/-   ##
=======================================
  Coverage   94.54%   94.54%           
=======================================
  Files         318      318           
  Lines        8052     8052           
  Branches     1694     1694           
=======================================
  Hits         7613     7613           
  Misses        439      439           

@chancancode chancancode mentioned this pull request Jan 24, 2025
25 tasks
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.

1 participant