-
Notifications
You must be signed in to change notification settings - Fork 837
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(api): fix eslint warnings #5366
base: main
Are you sure you want to change the base?
Conversation
/home/runner/work/opentelemetry-js/opentelemetry-js/api/src/diag/ComponentLogger.ts 36:25 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 40:25 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 44:24 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 48:24 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 52:27 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 60:9 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any /home/runner/work/opentelemetry-js/opentelemetry-js/api/src/experimental/trace/SugaredTracer.ts 80:5 warning 'context' is already declared in the upper scope on line 17 column 10 @typescript-eslint/no-shadow 129:5 warning 'context' is already declared in the upper scope on line 17 column 10 @typescript-eslint/no-shadow 135:5 warning 'context' is already declared in the upper scope on line 17 column 10 @typescript-eslint/no-shadow /home/runner/work/opentelemetry-js/opentelemetry-js/api/src/trace/NoopTracer.ts 102:37 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any Ref open-telemetry#5365
typeof spanContext['traceId'] === 'string' && | ||
'traceFlags' in spanContext && | ||
typeof spanContext['traceFlags'] === 'number' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This imposes a very slight runtime cost from the additional check. If that is undesirable here, there are plenty of alternative factoring that would accomplish the same without runtime code, this is just the most readable IMO.
Alternatively, if we trust the types, this function can be deleted altogether. It's only ever called from L47; the input came from getSpanContext()
, which is typed to return SpanContext | undefined
. If that is accurate (looks like it to me), then all we really needed to check is !== undefined
and it can be done inline.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5366 +/- ##
=======================================
Coverage 94.54% 94.54%
=======================================
Files 318 318
Lines 8052 8055 +3
Branches 1694 1698 +4
=======================================
+ Hits 7613 7616 +3
Misses 439 439
|
Which problem is this PR solving?
Fixes the following eslint warnings:
Ref #5365
Fixing
TextMapPropagator.ts
is a breaking change, so that will be submitted separately.Short description of the changes
Refactor to avoid the patterns being flagged.
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: