diff --git a/eslint.config.js b/eslint.config.js index 41a0079299..5eb52ccf04 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -12,10 +12,6 @@ module.exports = { }, rules: { "@typescript-eslint/no-this-alias": "off", - "eqeqeq": [ - "error", - "smart" - ], "prefer-rest-params": "off", "@typescript-eslint/naming-convention": [ "error", diff --git a/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts b/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts index 0af8695911..a1f4df09c1 100644 --- a/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts +++ b/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts @@ -36,7 +36,8 @@ export class AsyncLocalStorageContextManager extends AbstractAsyncHooksContextMa thisArg?: ThisParameterType, ...args: A ): ReturnType { - const cb = thisArg == null ? fn : fn.bind(thisArg); + const cb = + thisArg === null || thisArg === undefined ? fn : fn.bind(thisArg); return this._asyncLocalStorage.run(context, cb as never, ...args); } diff --git a/packages/opentelemetry-core/src/common/attributes.ts b/packages/opentelemetry-core/src/common/attributes.ts index df6b8f7a57..ae88743785 100644 --- a/packages/opentelemetry-core/src/common/attributes.ts +++ b/packages/opentelemetry-core/src/common/attributes.ts @@ -18,7 +18,7 @@ import { SpanAttributeValue, SpanAttributes } from '@opentelemetry/api'; export function sanitizeAttributes(attributes: unknown): SpanAttributes { const out: SpanAttributes = {}; - if (attributes == null || typeof attributes !== 'object') { + if (attributes === null || typeof attributes !== 'object') { return out; } @@ -36,7 +36,7 @@ export function sanitizeAttributes(attributes: unknown): SpanAttributes { } export function isAttributeValue(val: unknown): val is SpanAttributeValue { - if (val == null) { + if (val === null || val === undefined) { return true; } @@ -52,7 +52,7 @@ function isHomogeneousAttributeValueArray(arr: unknown[]): boolean { for (const element of arr) { // null/undefined elements are allowed - if (element == null) continue; + if (element === null || element === undefined) continue; if (!type) { if (isValidPrimitiveAttributeValue(element)) { diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index c353a38673..2fd5ccc237 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -173,7 +173,7 @@ function setLogLevelFromEnv( const value = values[key]; if (typeof value === 'string') { const theLevel = logLevelMap[value.toUpperCase()]; - if (theLevel != null) { + if (typeof theLevel === 'number') { environment[key] = theLevel; } } diff --git a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts index 5aa369d82b..6b6bb2961d 100644 --- a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts +++ b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts @@ -112,7 +112,7 @@ export class FetchInstrumentation extends InstrumentationBase< ): void { const parsedUrl = web.parseUrl(response.url); span.setAttribute(HttpAttribute.HTTP_STATUS_CODE, response.status); - if (response.statusText != null) { + if (typeof response.statusText === 'string') { span.setAttribute(HttpAttribute.HTTP_STATUS_TEXT, response.statusText); } span.setAttribute(HttpAttribute.HTTP_HOST, parsedUrl.host); diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts index 9995cd985c..7c0346fb8e 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts @@ -68,7 +68,7 @@ describe('HttpInstrumentation Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts index 7df9f3e771..8894ecdcff 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts @@ -80,7 +80,7 @@ describe('HttpsInstrumentation Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts index f507b7f1f1..0c2da0c113 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts @@ -53,7 +53,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options != null + options !== null && options !== undefined ? http.get(input, options, onGetResponseCb) : http.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts index f75cf1e566..3cd346953f 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts @@ -57,7 +57,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options != null + options !== null && options !== undefined ? https.get(input, options, onGetResponseCb) : https.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts index be05279d9a..748eb9ebf0 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts @@ -58,7 +58,7 @@ describe('Packages', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts index 65b0040eab..0dbf568f35 100644 --- a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts @@ -63,7 +63,7 @@ describe('HttpPlugin Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts index f507b7f1f1..0c2da0c113 100644 --- a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts +++ b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts @@ -53,7 +53,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options != null + options !== null && options !== undefined ? http.get(input, options, onGetResponseCb) : http.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts index e742977e86..8d13bd9802 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts @@ -72,7 +72,7 @@ describe('Packages', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts index 74a247e909..804711ed4b 100644 --- a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts @@ -76,7 +76,7 @@ describe('HttpsPlugin Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts index f75cf1e566..3cd346953f 100644 --- a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts +++ b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts @@ -57,7 +57,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options != null + options !== null && options !== undefined ? https.get(input, options, onGetResponseCb) : https.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index ea6ebce182..f56bd01f16 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -89,7 +89,8 @@ export class Span implements api.Span, ReadableSpan { setAttribute(key: string, value?: SpanAttributeValue): this; setAttribute(key: string, value: unknown): this { - if (value == null || this._isSpanEnded()) return this; + if (value === null || value === undefined || this._isSpanEnded()) + return this; if (key.length === 0) { api.diag.warn(`Invalid attribute key: ${key}`); return this;