-
Notifications
You must be signed in to change notification settings - Fork 913
refactor(instrumentation-http): fix eslint warnings #5394
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
base: main
Are you sure you want to change the base?
refactor(instrumentation-http): fix eslint warnings #5394
Conversation
Fix the following eslint warnings: ``` /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/src/http.ts 236:41 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 251:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 252:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 283:41 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 298:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 299:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any ``` Extracted a utility function with more precise types for the job. Ref open-telemetry#5365
Fix the following eslint warnings: ``` /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/src/http.ts 508:17 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion 931:11 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion 1032:13 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion 1043:13 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion ``` Because the expression we check is indirected through the a method call (`getConfig()`), TypeScript cannot assume the value would be the same across the two calls. By extracting the value and checking for that, TypeScript can narrow the type correctly and we can avoid the non-null assertion. Ref open-telemetry#5365
``` /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/src/http.ts 1051:15 warning Don't use `Function` as a type @typescript-eslint/ban-types ``` Be explict about what type of functions we are expecting here. Ref open-telemetry#5365
``` /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts 86:27 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts 86:27 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts 81:25 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api 156:43 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api 161:43 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api 213:35 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts 300:9 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts 274:9 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api ``` Generally speaking, `new URL()` is not a direct replacement for the deprecated `url.parse()`, so this type of change requires careful considerations. However, in this instance, these are all found in test code, which cuts out a lot of the typically associated issues, and the tests passing after the change is a good indication for correctness. Ref open-telemetry#5365
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5394 +/- ##
=======================================
Coverage 94.64% 94.64%
=======================================
Files 318 318
Lines 8033 8033
Branches 1688 1688
=======================================
Hits 7603 7603
Misses 430 430 🚀 New features to boost your workflow:
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
Hi @chancancode could you please resolve the conflict? Also the |
Which problem is this PR solving?
Fixes the following eslint warnings:
Ref #5365
Short description of the changes
There are a fair bit of changes here, but splitting into multiple PRs would just create a lot of conflicts. So instead, each commit is one unit of change with a detailed description in the commit message.
Type of change
Please delete options that are not relevant.
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
Checklist: