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(instrumentation-xhr): fix eslint warnings #5402

Merged

Conversation

chancancode
Copy link
Contributor

Which problem is this PR solving?

/home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/types.ts
  66:28  warning  Don't use `Function` as a type  @typescript-eslint/ban-types

/home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/utils.ts
  44:16  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  45:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-xml-http-request/test/xhr.test.ts
  69:22  warning  Don't use `Function` as a type  @typescript-eslint/ban-types
  104:22  warning  Don't use `Function` as a type  @typescript-eslint/ban-types

Ref #5365

Short description of the changes

The middle ones are the same as #5401, the rest are replacing Function with a more specific call signature, and they are either in tests or private API, so no breakages expected.

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/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/types.ts
  66:28  warning  Don't use `Function` as a type  @typescript-eslint/ban-types

/home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/utils.ts
  44:16  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  45:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-xml-http-request/test/xhr.test.ts
  69:22  warning  Don't use `Function` as a type  @typescript-eslint/ban-types
  104:22  warning  Don't use `Function` as a type  @typescript-eslint/ban-types
```

The middle ones are the same as open-telemetry#5401, the rest are replacing
`Function` with a more specific call signature, and they are either
in tests or private API, so no breakages expected.

Ref open-telemetry#5365
@chancancode chancancode requested a review from a team as a code owner January 30, 2025 02:44
@chancancode chancancode mentioned this pull request Jan 30, 2025
25 tasks
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.64%. Comparing base (29d0da5) to head (75eadfa).
Report is 20 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5402   +/-   ##
=======================================
  Coverage   94.64%   94.64%           
=======================================
  Files         318      318           
  Lines        8033     8033           
  Branches     1688     1688           
=======================================
  Hits         7603     7603           
  Misses        430      430           

@david-luna
Copy link
Contributor

@chancancode I'm adding the Skip changelog label as discussed in #5408 (comment)

@@ -53,8 +57,9 @@ export function getXHRBodyLength(
return getByteLength(body.toString());
}

if (typeof body === 'string') {
return getByteLength(body);
// ArrayBuffer | ArrayBufferView
Copy link
Contributor

Choose a reason for hiding this comment

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

any particular reason you moved the order of the checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi yes, it's notionally the same change from #5401. The type started out (for TypeScript) as a bunch of possibilities union-ed together (string | ... | ArrayBuffer | ArrayBufferView) so by arranging the branches in a strategic order (eliminating those possibilities in order) we will get the desired result without having to explicitly tell TypeScript what's up

@david-luna david-luna added this pull request to the merge queue Feb 6, 2025
Merged via the queue into open-telemetry:main with commit e744798 Feb 6, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants