From d4d1ab265879f9719aa25b171987503872d27aab Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 14 Dec 2023 11:15:15 -0500 Subject: [PATCH] feat: enable biome recommended linter rules --- .eslintrc.js | 4 + .size-limit.js | 2 +- biome.json | 57 ++- package.json | 2 +- packages/angular/src/tracing.ts | 9 +- .../subject.js | 2 +- .../onLoad/captureExceptionInOnLoad/init.js | 2 +- .../onLoad/customBrowserTracing/init.js | 2 +- .../loader/onLoad/customInit/init.js | 2 +- .../loader/onLoad/customIntegrations/init.js | 2 +- .../onLoad/customIntegrationsFunction/init.js | 2 +- .../loader/onLoad/customReplay/init.js | 2 +- .../loader-suites/loader/onLoad/init.js | 2 +- .../loader/onLoad/onLoadLate/subject.js | 2 +- .../loader/onLoad/pageloadTransaction/init.js | 2 +- .../loader/onLoad/replay/init.js | 2 +- .../onLoad/sentryOnLoadAndOnLoad/init.js | 2 +- .../scripts/detectFlakyTests.ts | 4 +- .../Breadcrumbs/xhr/get/subject.js | 2 +- .../Breadcrumbs/xhr/post/subject.js | 2 +- .../captureException/errorEvent/subject.js | 2 +- .../eventListener-wrapping/subject.js | 2 +- .../replay/errors/errorsInSession/test.ts | 2 +- .../xhr/captureRequestBody/test.ts | 10 +- .../xhr/captureRequestHeaders/test.ts | 4 +- .../xhr/captureRequestSize/test.ts | 4 +- .../xhr/captureResponseBody/test.ts | 10 +- .../xhr/captureResponseHeaders/test.ts | 4 +- .../xhr/captureResponseSize/test.ts | 6 +- .../xhr/captureTimestamps/test.ts | 2 +- .../subject.js | 2 +- .../protocol_fn_identifiers/subject.js | 2 +- .../regular_fn_identifiers/subject.js | 4 +- .../utils/generatePage.ts | 2 +- .../utils/generatePlugin.ts | 4 +- .../webpack.config.ts | 32 +- packages/browser/src/helpers.ts | 2 +- .../browser/src/integrations/breadcrumbs.ts | 2 +- packages/browser/src/integrations/dedupe.ts | 2 +- .../src/integrations/globalhandlers.ts | 6 +- .../browser/src/integrations/httpcontext.ts | 2 +- .../browser/src/integrations/linkederrors.ts | 2 +- packages/browser/src/integrations/trycatch.ts | 115 +++--- packages/browser/src/loader.js | 26 +- packages/browser/src/profiling/integration.ts | 2 +- packages/browser/src/profiling/utils.ts | 4 +- packages/browser/src/transports/offline.ts | 2 +- .../browser/test/integration/common/init.js | 4 +- .../test/integration/common/triggers.js | 4 +- .../browser/test/integration/common/utils.js | 2 +- .../browser/test/integration/suites/api.js | 92 ++--- .../test/integration/suites/breadcrumbs.js | 381 ++++++++---------- .../test/integration/suites/builtins.js | 201 +++++---- .../browser/test/integration/suites/config.js | 20 +- .../test/integration/suites/helpers.js | 26 +- .../integration/suites/loader-specific.js | 21 +- .../browser/test/integration/suites/loader.js | 36 +- .../test/integration/suites/onerror.js | 62 ++- .../suites/onunhandledrejection.js | 94 ++--- .../browser/test/integration/suites/shell.js | 6 +- packages/browser/test/package/npm-build.js | 2 +- .../test/unit/profiling/integration.test.ts | 2 +- packages/bun/src/integrations/bunserver.ts | 2 +- packages/core/src/baseclient.ts | 4 +- packages/core/src/eventProcessors.ts | 2 +- packages/core/src/hub.ts | 7 +- .../core/src/integrations/functiontostring.ts | 2 +- .../core/src/integrations/inboundfilters.ts | 2 +- .../core/src/integrations/linkederrors.ts | 2 +- packages/core/src/integrations/metadata.ts | 2 +- packages/core/src/integrations/requestdata.ts | 2 +- packages/core/src/scope.ts | 2 +- packages/core/src/tracing/sampling.ts | 4 +- packages/core/src/tracing/span.ts | 2 +- packages/core/src/tracing/transaction.ts | 2 +- packages/core/test/lib/integration.test.ts | 4 +- packages/core/test/lib/tracing/trace.test.ts | 2 +- packages/core/test/mocks/integration.ts | 12 +- packages/core/test/mocks/transport.ts | 2 +- .../deno/src/integrations/normalizepaths.ts | 2 +- packages/deno/test/normalize.ts | 10 +- .../create-react-app/src/App.tsx | 2 + .../create-remix-app-v2/app/entry.server.tsx | 2 + .../create-remix-app-v2/app/root.tsx | 1 + .../create-remix-app/app/entry.server.tsx | 2 + .../create-remix-app/app/root.tsx | 1 + .../app/client-component/error.tsx | 4 +- .../parameter/[...parameters]/error.tsx | 4 +- .../parameter/[parameter]/error.tsx | 4 +- .../nextjs-app-dir/app/error.tsx | 4 +- .../app/server-component/error.tsx | 4 +- .../parameter/[...parameters]/error.tsx | 4 +- .../parameter/[parameter]/error.tsx | 4 +- .../nextjs-app-dir/assert-build.ts | 2 - .../components/client-error-debug-tools.tsx | 8 + .../nextjs-app-dir/event-proxy-server.ts | 2 +- .../pages/pages-router/ssr-error-class.tsx | 1 + .../pages/pages-router/ssr-error-fc.tsx | 1 + .../nextjs-app-dir/sentry.client.config.ts | 2 +- .../nextjs-app-dir/sentry.edge.config.ts | 2 +- .../nextjs-app-dir/sentry.server.config.ts | 2 +- .../nextjs-app-dir/tests/transactions.test.ts | 2 +- .../event-proxy-server.ts | 2 +- .../node-experimental-fastify-app/src/app.js | 14 +- .../node-express-app/event-proxy-server.ts | 2 +- .../node-express-app/src/app.ts | 14 +- .../sveltekit/event-proxy-server.ts | 2 +- .../sveltekit/src/hooks.client.ts | 2 +- .../sveltekit/src/hooks.server.ts | 2 +- packages/ember/.eslintrc.js | 2 - packages/ember/.template-lintrc.js | 2 - packages/ember/addon/index.ts | 2 +- packages/ember/config/ember-try.js | 6 +- packages/ember/config/environment.js | 6 +- packages/ember/ember-cli-build.js | 4 +- packages/ember/index.js | 5 +- packages/ember/testem.js | 2 - .../tests/acceptance/sentry-errors-test.ts | 2 +- .../acceptance/sentry-performance-test.ts | 6 +- .../tests/acceptance/sentry-replay-test.ts | 4 +- .../ember/tests/dummy/config/environment.js | 4 +- packages/ember/tests/dummy/config/targets.js | 2 - packages/ember/tests/helpers/setup-sentry.ts | 4 +- .../unit/instrument-route-performance-test.ts | 2 +- packages/ember/types/global.d.ts | 1 + packages/eslint-plugin-sdk/src/index.js | 1 - .../src/rules/no-class-field-initializers.js | 1 - .../src/rules/no-eq-empty.js | 3 +- .../src/rules/no-nullish-coalescing.js | 1 - .../src/rules/no-optional-chaining.js | 1 - .../src/rules/no-unsupported-es6-methods.js | 2 - .../test/lib/rules/no-eq-empty.js | 1 - packages/feedback/src/integration.ts | 2 +- packages/feedback/src/widget/createWidget.ts | 2 +- packages/gatsby/gatsby-browser.js | 2 +- packages/hub/test/hub.test.ts | 2 +- .../integration-shims/src/BrowserTracing.ts | 2 +- packages/integration-shims/src/Feedback.ts | 2 +- packages/integration-shims/src/Replay.ts | 2 +- packages/integrations/scripts/buildBundles.ts | 5 +- packages/integrations/src/captureconsole.ts | 2 +- packages/integrations/src/contextlines.ts | 2 +- packages/integrations/src/debug.ts | 2 +- packages/integrations/src/dedupe.ts | 2 +- packages/integrations/src/extraerrordata.ts | 4 +- packages/integrations/src/httpclient.ts | 2 +- packages/integrations/src/offline.ts | 2 +- .../integrations/src/reportingobserver.ts | 2 +- packages/integrations/src/rewriteframes.ts | 2 +- packages/integrations/src/sessiontiming.ts | 2 +- packages/integrations/src/transaction.ts | 2 +- .../integrations/test/extraerrordata.test.ts | 16 +- packages/integrations/test/offline.test.ts | 2 +- .../appRouterRoutingInstrumentation.ts | 4 +- .../routing/nextRoutingInstrumentation.ts | 4 +- .../pagesRouterRoutingInstrumentation.ts | 4 +- .../nextjs/src/config/withSentryConfig.ts | 2 +- packages/nextjs/test/config/fixtures.ts | 2 +- packages/nextjs/test/config/loaders.test.ts | 2 +- packages/nextjs/test/config/testUtils.ts | 2 +- .../integration/pages/[id]/errorClick.tsx | 1 + .../test/integration/pages/_document.tsx | 2 +- .../test/integration/pages/errorClick.tsx | 1 + .../test/server/tracingWithSentryAPI.test.ts | 14 +- .../src/integrations/express.ts | 2 +- .../src/integrations/fastify.ts | 2 +- .../src/integrations/graphql.ts | 2 +- .../src/integrations/hapi.ts | 2 +- .../src/integrations/http.ts | 2 +- .../src/integrations/mongo.ts | 2 +- .../src/integrations/mongoose.ts | 2 +- .../src/integrations/mysql.ts | 2 +- .../src/integrations/mysql2.ts | 2 +- .../src/integrations/nest.ts | 2 +- .../src/integrations/node-fetch.ts | 2 +- .../src/integrations/postgres.ts | 2 +- .../src/integrations/prisma.ts | 2 +- .../common-infix-parameterized/server.ts | 2 +- .../multiple-routers/common-infix/server.ts | 2 +- .../server.ts | 2 +- .../common-prefix-parameterized/server.ts | 2 +- .../server.ts | 2 +- .../server.ts | 2 +- .../multiple-routers/common-prefix/server.ts | 2 +- .../mysql/withConnect/scenario.ts | 4 +- .../mysql/withoutCallback/scenario.ts | 2 +- .../mysql/withoutConnect/scenario.ts | 2 +- .../tracing/auto-instrument/mysql/scenario.ts | 4 +- .../node-integration-tests/utils/index.ts | 6 +- .../node-integration-tests/utils/run-tests.ts | 2 +- packages/node/src/anr/index.ts | 2 +- packages/node/src/anr/websocket.ts | 2 +- packages/node/src/handlers.ts | 2 +- packages/node/src/integrations/console.ts | 2 +- packages/node/src/integrations/context.ts | 2 +- .../node/src/integrations/contextlines.ts | 2 +- packages/node/src/integrations/http.ts | 15 +- packages/node/src/integrations/inspector.d.ts | 48 ++- .../node/src/integrations/localvariables.ts | 6 +- packages/node/src/integrations/modules.ts | 2 +- .../src/integrations/onuncaughtexception.ts | 8 +- .../src/integrations/onunhandledrejection.ts | 2 +- .../node/src/integrations/undici/index.ts | 2 +- packages/node/src/integrations/utils/http.ts | 1 - packages/node/src/module.ts | 1 - packages/node/src/sdk.ts | 2 +- .../test/integrations/localvariables.test.ts | 1 + .../test/manual/memory-leak/context-memory.js | 2 +- .../manual/memory-leak/express-patient.js | 8 +- .../manual/memory-leak/large-module-src.js | 2 - .../node/test/manual/memory-leak/manager.js | 2 +- .../aggregates-disable-single-session.js | 2 +- .../terminal-state-sessions-sent-once.js | 8 +- .../unhandled-rejection-crashed-session.js | 4 +- .../test/manual/release-health/test-utils.js | 2 + .../manual/webpack-async-context/npm-build.js | 2 +- packages/opentelemetry/src/sampler.ts | 4 +- .../src/utils/groupSpansWithParents.ts | 4 +- packages/opentelemetry/test/trace.test.ts | 4 +- .../overhead-metrics/configs/ci/collect.ts | 2 +- packages/overhead-metrics/src/perf/cpu.ts | 4 +- packages/overhead-metrics/src/perf/network.ts | 4 +- packages/overhead-metrics/src/perf/sampler.ts | 4 +- .../overhead-metrics/src/results/analyzer.ts | 32 +- .../src/results/pr-comment.ts | 10 +- .../src/results/results-set.ts | 4 +- packages/overhead-metrics/src/util/console.ts | 2 +- packages/overhead-metrics/src/util/github.ts | 8 +- packages/overhead-metrics/src/util/json.ts | 2 +- .../test-apps/booking-app/main.js | 6 +- .../overhead-metrics/test-apps/jank/app.js | 29 +- packages/react/src/profiler.tsx | 3 +- packages/react/src/reactrouterv3.ts | 4 +- packages/react/src/reactrouterv6.tsx | 8 +- packages/react/test/errorboundary.test.tsx | 1 - packages/remix/src/client/performance.tsx | 2 +- packages/remix/src/utils/instrumentServer.ts | 10 +- packages/remix/src/utils/vendor/types.ts | 5 +- .../test/integration/app_v1/entry.server.tsx | 2 +- .../test/integration/app_v2/entry.server.tsx | 2 +- .../common/routes/capture-exception.tsx | 2 +- .../integration/test/server/utils/helpers.ts | 2 +- packages/replay-worker/examples/worker.js | 84 ++-- .../src/coreHandlers/util/fetchUtils.ts | 2 - .../src/coreHandlers/util/networkUtils.ts | 2 +- .../src/coreHandlers/util/onWindowOpen.ts | 7 +- packages/replay/src/integration.ts | 2 +- packages/replay/src/util/isExpired.ts | 6 +- .../coreHandlers/handleScope.test.ts | 2 +- .../test/integration/errorSampleRate.test.ts | 16 +- .../replay/test/integration/events.test.ts | 12 +- .../test/integration/sendReplayEvent.test.ts | 12 +- .../replay/test/integration/session.test.ts | 16 +- packages/replay/test/integration/stop.test.ts | 8 +- packages/replay/test/mocks/mockRrweb.ts | 2 +- .../unit/coreHandlers/handleFetch.test.ts | 6 +- .../coreHandlers/handleKeyboardEvent.test.ts | 12 +- .../unit/coreHandlers/handleScope.test.ts | 2 +- .../test/unit/coreHandlers/handleXhr.test.ts | 6 +- .../util/addBreadcrumbEvent.test.ts | 4 +- .../util/getAttributesToRecord.test.ts | 2 +- .../unit/eventBuffer/EventBufferArray.test.ts | 12 +- .../EventBufferCompressionWorker.test.ts | 18 +- .../unit/eventBuffer/EventBufferProxy.test.ts | 4 +- .../test/unit/multipleInstances.test.ts | 2 +- .../test/unit/session/createSession.test.ts | 4 +- .../test/unit/session/fetchSession.test.ts | 10 +- .../unit/session/loadOrCreateSession.test.ts | 28 +- .../test/unit/session/saveSession.test.ts | 2 +- .../test/unit/session/sessionSampling.test.ts | 8 +- .../replay/test/unit/util/addEvent.test.ts | 4 +- .../unit/util/createPerformanceEntry.test.ts | 6 +- .../unit/util/handleRecordingEmit.test.ts | 8 +- .../replay/test/unit/util/isExpired.test.ts | 10 +- .../test/unit/util/isSessionExpired.test.ts | 8 +- packages/replay/test/utils/use-fake-timers.ts | 4 +- packages/serverless/src/awsservices.ts | 2 +- .../serverless/src/gcpfunction/general.ts | 6 +- packages/serverless/src/google-cloud-grpc.ts | 6 +- packages/serverless/src/google-cloud-http.ts | 2 +- packages/serverless/test/gcpfunction.test.ts | 4 +- .../serverless/test/google-cloud-grpc.test.ts | 2 +- packages/sveltekit/src/client/router.ts | 4 +- packages/sveltekit/test/server/handle.test.ts | 2 +- .../src/browser/metrics/index.ts | 2 +- .../src/browser/metrics/utils.ts | 2 +- .../tracing-internal/src/browser/request.ts | 4 +- .../tracing-internal/src/browser/router.ts | 4 +- .../src/browser/web-vitals/getFID.ts | 2 +- .../src/browser/web-vitals/getINP.ts | 4 +- .../web-vitals/lib/getNavigationEntry.ts | 2 +- .../src/node/integrations/apollo.ts | 125 +++--- .../src/node/integrations/express.ts | 6 +- .../src/node/integrations/graphql.ts | 53 +-- .../src/node/integrations/mongo.ts | 87 ++-- .../src/node/integrations/mysql.ts | 71 ++-- .../src/node/integrations/postgres.ts | 113 +++--- .../src/node/integrations/prisma.ts | 2 +- .../test/integrations/node/mongo.test.ts | 10 +- .../test/integrations/node/postgres.test.ts | 8 +- .../test/integrations/node/prisma.test.ts | 2 +- packages/utils/src/aggregate-errors.ts | 2 +- packages/utils/src/baggage.ts | 6 +- packages/utils/src/browser.ts | 1 - packages/utils/src/dsn.ts | 4 +- packages/utils/src/instrument/console.ts | 8 +- packages/utils/src/instrument/dom.ts | 71 ++-- packages/utils/src/instrument/fetch.ts | 8 +- packages/utils/src/instrument/history.ts | 1 - packages/utils/src/instrument/xhr.ts | 191 +++++---- packages/utils/src/is.ts | 11 - packages/utils/src/misc.ts | 8 +- packages/utils/src/node-stack-trace.ts | 2 +- packages/utils/src/normalize.ts | 14 +- packages/utils/src/object.ts | 2 +- packages/utils/src/path.ts | 4 +- packages/utils/src/ratelimit.ts | 6 +- packages/utils/src/requestdata.ts | 5 +- packages/utils/src/stacktrace.ts | 2 +- packages/utils/src/string.ts | 12 +- packages/utils/src/supports.ts | 2 +- packages/utils/src/syncpromise.ts | 2 +- packages/utils/src/worldwide.ts | 12 +- packages/utils/test/cookie.test.ts | 16 +- packages/utils/test/is.test.ts | 16 - packages/utils/test/normalize.test.ts | 2 - packages/utils/test/syncpromise.test.ts | 2 +- packages/utils/test/userIntegrations.test.ts | 4 +- .../src/integrations/wintercg-fetch.ts | 2 +- packages/vercel-edge/src/sdk.ts | 2 +- packages/vue/src/integration.ts | 2 +- packages/vue/src/router.ts | 4 +- packages/vue/src/tracing.ts | 2 +- packages/vue/src/vendor/components.ts | 6 +- packages/wasm/src/index.ts | 2 +- scripts/prepack.ts | 23 +- 336 files changed, 1617 insertions(+), 1690 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5a217a09fd75..f814897e0af4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -28,6 +28,10 @@ module.exports = { rules: { // Disabled because it's included with Biome's linter 'no-control-regex': 'off', + 'no-param-reassign': 'off', + 'prefer-const': 'off', + '@typescript-eslint/ban-types': 'off', + 'react-hooks/exhaustive-deps': 'off', }, }, { diff --git a/.size-limit.js b/.size-limit.js index 599f59e07170..5be7452d664b 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -20,7 +20,7 @@ module.exports = [ import: '{ init, Replay, BrowserTracing }', gzip: true, limit: '75 KB', - modifyWebpackConfig: function (config) { + modifyWebpackConfig: config => { const webpack = require('webpack'); config.plugins.push( new webpack.DefinePlugin({ diff --git a/biome.json b/biome.json index 8e8155f8d6d8..60b9b9d42fac 100644 --- a/biome.json +++ b/biome.json @@ -11,18 +11,60 @@ "linter": { "enabled": true, "rules": { - "recommended": false, + "recommended": true, + "a11y": { + "all": false + }, + "complexity": { + "noForEach": "off", + "noUselessConstructor": "off", + "noStaticOnlyClass": "off", + "useOptionalChain": "off", + "useLiteralKeys": "off" + }, "correctness": { - "all": false, - "noUnusedVariables": "error", - "noPrecisionLoss": "error" + "noEmptyPattern": "off", + "noInnerDeclarations": "off", + "noVoidTypeReturn": "off", + "noEmptyCharacterClassInRegex": "off" + }, + "performance": { + "noDelete": "off" + }, + "security": { + "all": true + }, + "style": { + "noArguments": "off", + "noCommaOperator": "off", + "noNonNullAssertion": "off", + "noUselessElse": "off", + "useTemplate": "off", + "noVar": "off", + "useSingleVarDeclarator": "off", + "useDefaultParameterLast": "off", + "useExponentiationOperator": "off" }, "suspicious": { - "all": false, - "noControlCharactersInRegex": "error" + "noDebugger": "off", + "noDoubleEquals": "off", + "noExplicitAny": "off", + "noRedeclare": "off", + "noAssignInExpressions": "off", + "noConfusingVoidType": "off", + "noPrototypeBuiltins": "off", + "noShadowRestrictedNames": "off", + "noControlCharactersInRegex": "off" } }, - "ignore": [".vscode/*", "**/*.json"] + "ignore": [ + ".vscode/*", + "**/*.json", + "**/*.min.js", + "packages/browser-integration-tests/fixtures/loader.js", + "packages/browser/test/integration/polyfills/*.js", + "packages/replay-worker/examples/worker.js" + ] }, "files": { "ignoreUnknown": true @@ -44,6 +86,7 @@ ] }, "javascript": { + "globals": ["expect", "describe", "test", "it", "beforeEach", "afterEach", "beforeAll", "afterAll"], "formatter": { "enabled": true, "quoteStyle": "single", diff --git a/package.json b/package.json index f8bdaced8cbe..de8c53d09137 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "codecov": "codecov", "fix": "run-s fix:lerna fix:biome", "fix:lerna": "lerna run fix", - "fix:biome": "biome check --apply-unsafe .", + "fix:biome": "biome check --apply .", "changelog": "ts-node ./scripts/get-commit-list.ts", "link:yarn": "lerna exec yarn link", "lint": "run-s lint:lerna lint:biome", diff --git a/packages/angular/src/tracing.ts b/packages/angular/src/tracing.ts index 88a2490c1d58..5082823d34eb 100644 --- a/packages/angular/src/tracing.ts +++ b/packages/angular/src/tracing.ts @@ -27,8 +27,8 @@ let stashedStartTransactionOnLocationChange: boolean; */ export function routingInstrumentation( customStartTransaction: (context: TransactionContext) => Transaction | undefined, - startTransactionOnPageLoad: boolean = true, - startTransactionOnLocationChange: boolean = true, + startTransactionOnPageLoad = true, + startTransactionOnLocationChange = true, ): void { instrumentationInitialized = true; stashedStartTransaction = customStartTransaction; @@ -260,7 +260,8 @@ export function TraceClassDecorator(): ClassDecorator { * Decorator function that can be used to capture a single lifecycle methods of the component. */ export function TraceMethodDecorator(): MethodDecorator { - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ban-types + // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + // biome-ignore lint/complexity/noBannedTypes: Disable return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => { const originalMethod = descriptor.value; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -300,7 +301,7 @@ export function getParameterizedRouteFromSnapshot(route?: ActivatedRouteSnapshot let currentRoute = route && route.firstChild; while (currentRoute) { const path = currentRoute && currentRoute.routeConfig && currentRoute.routeConfig.path; - if (path === null || path === undefined) { + if (path == null) { break; } diff --git a/packages/browser-integration-tests/loader-suites/loader/noOnLoad/unhandeledPromiseRejectionHandler/subject.js b/packages/browser-integration-tests/loader-suites/loader/noOnLoad/unhandeledPromiseRejectionHandler/subject.js index 29401cd7131d..20dfa7bf71bd 100644 --- a/packages/browser-integration-tests/loader-suites/loader/noOnLoad/unhandeledPromiseRejectionHandler/subject.js +++ b/packages/browser-integration-tests/loader-suites/loader/noOnLoad/unhandeledPromiseRejectionHandler/subject.js @@ -1,3 +1,3 @@ -new Promise(function (resolve, reject) { +new Promise((resolve, reject) => { reject('this is unhandled'); }); diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/captureExceptionInOnLoad/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/captureExceptionInOnLoad/init.js index 8c8c99e30367..41d1faadea6e 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/captureExceptionInOnLoad/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/captureExceptionInOnLoad/init.js @@ -1,4 +1,4 @@ -Sentry.onLoad(function () { +Sentry.onLoad(() => { // You _have_ to call Sentry.init() before calling Sentry.captureException() in Sentry.onLoad()! Sentry.init(); Sentry.captureException('Test exception'); diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/customBrowserTracing/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/customBrowserTracing/init.js index 269593b620f1..4694dfe6adbb 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/customBrowserTracing/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/customBrowserTracing/init.js @@ -1,6 +1,6 @@ window._testBaseTimestamp = performance.timeOrigin / 1000; -Sentry.onLoad(function () { +Sentry.onLoad(() => { Sentry.init({ integrations: [ // Without this syntax, this will be re-written by the test framework diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/customInit/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/customInit/init.js index 4a9e000fd1c2..eb9458e44286 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/customInit/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/customInit/init.js @@ -1,7 +1,7 @@ window.__sentryOnLoad = 0; setTimeout(() => { - Sentry.onLoad(function () { + Sentry.onLoad(() => { window.__hadSentry = window.sentryIsLoaded(); Sentry.init({ diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrations/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrations/init.js index 5d2920680cfc..550029f23ac4 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrations/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrations/init.js @@ -6,7 +6,7 @@ class CustomIntegration { setupOnce() {} } -Sentry.onLoad(function () { +Sentry.onLoad(() => { Sentry.init({ integrations: [new CustomIntegration()], }); diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrationsFunction/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrationsFunction/init.js index 0836f8b3b887..666b32d69ea6 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrationsFunction/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrationsFunction/init.js @@ -6,7 +6,7 @@ class CustomIntegration { setupOnce() {} } -Sentry.onLoad(function () { +Sentry.onLoad(() => { Sentry.init({ integrations: integrations => [new CustomIntegration()].concat(integrations), }); diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/customReplay/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/customReplay/init.js index 921209ce14dc..42d24ae49899 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/customReplay/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/customReplay/init.js @@ -1,4 +1,4 @@ -Sentry.onLoad(function () { +Sentry.onLoad(() => { Sentry.init({ integrations: [ // Without this syntax, this will be re-written by the test framework diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/init.js index e63705186b2f..3dec27f429ba 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/init.js @@ -1,3 +1,3 @@ -Sentry.onLoad(function () { +Sentry.onLoad(() => { Sentry.init({}); }); diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/onLoadLate/subject.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/onLoadLate/subject.js index 1dcef58798cc..78c8de76a131 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/onLoadLate/subject.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/onLoadLate/subject.js @@ -1,7 +1,7 @@ Sentry.forceLoad(); setTimeout(() => { - Sentry.onLoad(function () { + Sentry.onLoad(() => { Sentry.captureException('Test exception'); }); }, 200); diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/pageloadTransaction/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/pageloadTransaction/init.js index 7c0fceed58a4..f575cf07ca35 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/pageloadTransaction/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/pageloadTransaction/init.js @@ -1,5 +1,5 @@ window._testBaseTimestamp = performance.timeOrigin / 1000; -Sentry.onLoad(function () { +Sentry.onLoad(() => { Sentry.init({}); }); diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/replay/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/replay/init.js index e63705186b2f..3dec27f429ba 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/replay/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/replay/init.js @@ -1,3 +1,3 @@ -Sentry.onLoad(function () { +Sentry.onLoad(() => { Sentry.init({}); }); diff --git a/packages/browser-integration-tests/loader-suites/loader/onLoad/sentryOnLoadAndOnLoad/init.js b/packages/browser-integration-tests/loader-suites/loader/onLoad/sentryOnLoadAndOnLoad/init.js index c922dae2569a..1f3976d096da 100644 --- a/packages/browser-integration-tests/loader-suites/loader/onLoad/sentryOnLoadAndOnLoad/init.js +++ b/packages/browser-integration-tests/loader-suites/loader/onLoad/sentryOnLoadAndOnLoad/init.js @@ -1,4 +1,4 @@ -Sentry.onLoad(function () { +Sentry.onLoad(() => { // this should be called _after_ window.sentryOnLoad Sentry.captureException(`Test exception: ${Sentry.getCurrentHub().getClient().getOptions().tracesSampleRate}`); }); diff --git a/packages/browser-integration-tests/scripts/detectFlakyTests.ts b/packages/browser-integration-tests/scripts/detectFlakyTests.ts index 8059b4841176..535ccbbae718 100644 --- a/packages/browser-integration-tests/scripts/detectFlakyTests.ts +++ b/packages/browser-integration-tests/scripts/detectFlakyTests.ts @@ -78,14 +78,14 @@ ${changedPaths.join('\n')} console.log(''); console.log(''); - console.error(`⚠️ Some tests failed.`); + console.error('⚠️ Some tests failed.'); console.error(error); process.exit(1); } console.log(''); console.log(''); - console.log(`☑️ All tests passed.`); + console.log('☑️ All tests passed.'); } function getTestPaths(): string[] { diff --git a/packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/subject.js b/packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/subject.js index f95bcb45c166..f5ffa0ba0c4c 100644 --- a/packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/subject.js +++ b/packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/subject.js @@ -3,7 +3,7 @@ const xhr = new XMLHttpRequest(); xhr.open('GET', 'http://localhost:7654/foo'); xhr.send(); -xhr.addEventListener('readystatechange', function () { +xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { Sentry.captureException('test error'); } diff --git a/packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/subject.js b/packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/subject.js index f8779b681d58..b2894090ebc3 100644 --- a/packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/subject.js +++ b/packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/post/subject.js @@ -5,7 +5,7 @@ xhr.setRequestHeader('Accept', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.send('{"my":"body"}'); -xhr.addEventListener('readystatechange', function () { +xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { Sentry.captureException('test error'); } diff --git a/packages/browser-integration-tests/suites/public-api/captureException/errorEvent/subject.js b/packages/browser-integration-tests/suites/public-api/captureException/errorEvent/subject.js index 207f9d1d58f6..30af7a73f429 100644 --- a/packages/browser-integration-tests/suites/public-api/captureException/errorEvent/subject.js +++ b/packages/browser-integration-tests/suites/public-api/captureException/errorEvent/subject.js @@ -1,4 +1,4 @@ -window.addEventListener('error', function (event) { +window.addEventListener('error', event => { Sentry.captureException(event); }); diff --git a/packages/browser-integration-tests/suites/public-api/instrumentation/eventListener-wrapping/subject.js b/packages/browser-integration-tests/suites/public-api/instrumentation/eventListener-wrapping/subject.js index 289068737dc2..e837d2e77cb1 100644 --- a/packages/browser-integration-tests/suites/public-api/instrumentation/eventListener-wrapping/subject.js +++ b/packages/browser-integration-tests/suites/public-api/instrumentation/eventListener-wrapping/subject.js @@ -12,7 +12,7 @@ class EventHandlerClass { const objectListener = new EventHandlerClass(); -window.attachListeners = function () { +window.attachListeners = () => { window.addEventListener('click', functionListener); window.addEventListener('click', objectListener); }; diff --git a/packages/browser-integration-tests/suites/replay/errors/errorsInSession/test.ts b/packages/browser-integration-tests/suites/replay/errors/errorsInSession/test.ts index 603758c95409..9f531f54241f 100644 --- a/packages/browser-integration-tests/suites/replay/errors/errorsInSession/test.ts +++ b/packages/browser-integration-tests/suites/replay/errors/errorsInSession/test.ts @@ -18,7 +18,7 @@ sentryTest( sentryTest.skip(); } - let errorEventId: string = 'invalid_id'; + let errorEventId = 'invalid_id'; const reqPromise0 = waitForReplayRequest(page, 0); const reqPromise1 = waitForReplayRequest(page, 1); diff --git a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/test.ts b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/test.ts index b2d4fddaad9e..69a9b2906ad1 100644 --- a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/test.ts +++ b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestBody/test.ts @@ -41,7 +41,7 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse xhr.open('POST', 'http://localhost:7654/foo'); xhr.send('input body'); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -122,7 +122,7 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse xhr.open('POST', 'http://localhost:7654/foo'); xhr.send('{"foo":"bar"}'); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -207,7 +207,7 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br xhr.open('POST', 'http://localhost:7654/foo'); xhr.send(body); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -288,7 +288,7 @@ sentryTest('captures text request body when matching relative URL', async ({ get xhr.open('POST', '/foo'); xhr.send('input body'); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -369,7 +369,7 @@ sentryTest('does not capture request body when URL does not match', async ({ get xhr.open('POST', 'http://localhost:7654/bar'); xhr.send('input body'); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); diff --git a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/test.ts b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/test.ts index 7158f034a2ef..e958b1b2c3f9 100644 --- a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/test.ts +++ b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestHeaders/test.ts @@ -45,7 +45,7 @@ sentryTest('captures request headers', async ({ getLocalTestPath, page, browserN xhr.setRequestHeader('X-Test-Header', 'test-value'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -132,7 +132,7 @@ sentryTest( xhr.setRequestHeader('X-Test-Header', 'test-value'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); diff --git a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize/test.ts b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize/test.ts index 15e5cc431d35..2b928f3e8beb 100644 --- a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize/test.ts +++ b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureRequestSize/test.ts @@ -41,7 +41,7 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest xhr.open('POST', 'http://localhost:7654/foo'); xhr.send('{"foo":"bar"}'); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -132,7 +132,7 @@ sentryTest('captures request size from non-text request body', async ({ getLocal xhr.open('POST', 'http://localhost:7654/foo'); xhr.send(blob); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); diff --git a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/test.ts b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/test.ts index 12ef0b2a6068..7b6c0a38303c 100644 --- a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/test.ts +++ b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseBody/test.ts @@ -45,7 +45,7 @@ sentryTest('captures text response body', async ({ getLocalTestPath, page, brows xhr.open('POST', 'http://localhost:7654/foo'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -130,7 +130,7 @@ sentryTest('captures JSON response body', async ({ getLocalTestPath, page, brows xhr.open('POST', 'http://localhost:7654/foo'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -217,7 +217,7 @@ sentryTest('captures JSON response body when responseType=json', async ({ getLoc xhr.responseType = 'json'; xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -302,7 +302,7 @@ sentryTest('captures non-text response body', async ({ getLocalTestPath, page, b xhr.open('POST', 'http://localhost:7654/foo'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -389,7 +389,7 @@ sentryTest( xhr.open('POST', 'http://localhost:7654/bar'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); diff --git a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/test.ts b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/test.ts index ed2c2f5b2765..f9193cb7de15 100644 --- a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/test.ts +++ b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseHeaders/test.ts @@ -48,7 +48,7 @@ sentryTest('captures response headers', async ({ getLocalTestPath, page, browser xhr.open('GET', 'http://localhost:7654/foo'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -139,7 +139,7 @@ sentryTest( xhr.open('GET', 'http://localhost:7654/bar'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); diff --git a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseSize/test.ts b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseSize/test.ts index ea0d6240c8e9..4c60d59edf88 100644 --- a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseSize/test.ts +++ b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureResponseSize/test.ts @@ -46,7 +46,7 @@ sentryTest( xhr.open('GET', 'http://localhost:7654/foo'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -142,7 +142,7 @@ sentryTest('captures response size without Content-Length header', async ({ getL xhr.open('GET', 'http://localhost:7654/foo'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); @@ -235,7 +235,7 @@ sentryTest('captures response size for non-string bodies', async ({ getLocalTest xhr.open('POST', 'http://localhost:7654/foo'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); diff --git a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureTimestamps/test.ts b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureTimestamps/test.ts index 1a60ceea6509..55870bbcb8b7 100644 --- a/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureTimestamps/test.ts +++ b/packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/captureTimestamps/test.ts @@ -46,7 +46,7 @@ sentryTest('captures correct timestamps', async ({ getLocalTestPath, page, brows xhr.setRequestHeader('X-Test-Header', 'test-value'); xhr.send(); - xhr.addEventListener('readystatechange', function () { + xhr.addEventListener('readystatechange', () => { if (xhr.readyState === 4) { // @ts-expect-error Sentry is a global setTimeout(() => Sentry.captureException('test error', 0)); diff --git a/packages/browser-integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js b/packages/browser-integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js index b9223bc91ac0..b54ce5d426c7 100644 --- a/packages/browser-integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js +++ b/packages/browser-integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js @@ -14,7 +14,7 @@ class Response { } } -const decodeBlob = function() { +const decodeBlob = () => { (function readFile() { httpsCall(); })(); diff --git a/packages/browser-integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js b/packages/browser-integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js index d7ca8d22e04c..9432ccc10c4e 100644 --- a/packages/browser-integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js +++ b/packages/browser-integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js @@ -14,7 +14,7 @@ class File { } } -const blob = function() { +const blob = () => { (function file() { https(); })(); diff --git a/packages/browser-integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js b/packages/browser-integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js index ff63abc6f3ca..a92489b070cb 100644 --- a/packages/browser-integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js +++ b/packages/browser-integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js @@ -14,9 +14,9 @@ class Test { } } -const qux = function() { +const qux = () => { (() => { - (function() { + (() => { foo(); })(); })(); diff --git a/packages/browser-integration-tests/utils/generatePage.ts b/packages/browser-integration-tests/utils/generatePage.ts index 47be50c707e4..917848f85f32 100644 --- a/packages/browser-integration-tests/utils/generatePage.ts +++ b/packages/browser-integration-tests/utils/generatePage.ts @@ -10,7 +10,7 @@ export async function generatePage( subjectPath: string, templatePath: string, outPath: string, - outPageName: string = 'index.html', + outPageName = 'index.html', ): Promise { const localPath = `${outPath}/dist`; const bundlePath = `${localPath}/${outPageName}}`; diff --git a/packages/browser-integration-tests/utils/generatePlugin.ts b/packages/browser-integration-tests/utils/generatePlugin.ts index af4da2e8b2b8..d35a1387ef39 100644 --- a/packages/browser-integration-tests/utils/generatePlugin.ts +++ b/packages/browser-integration-tests/utils/generatePlugin.ts @@ -130,10 +130,10 @@ function generateSentryAlias(): Record { class SentryScenarioGenerationPlugin { public requiredIntegrations: string[] = []; - public requiresWASMIntegration: boolean = false; + public requiresWASMIntegration = false; public localOutPath: string; - private _name: string = 'SentryScenarioGenerationPlugin'; + private _name = 'SentryScenarioGenerationPlugin'; public constructor(localOutPath: string) { this.localOutPath = localOutPath; diff --git a/packages/browser-integration-tests/webpack.config.ts b/packages/browser-integration-tests/webpack.config.ts index ddf31bc897c4..485912688de4 100644 --- a/packages/browser-integration-tests/webpack.config.ts +++ b/packages/browser-integration-tests/webpack.config.ts @@ -1,21 +1,19 @@ import type { Configuration } from 'webpack'; -const config = function (userConfig: Record): Configuration { - return { - ...userConfig, - mode: 'none', - module: { - rules: [ - { - test: /\.(js|ts)$/, - exclude: /node_modules/, - loader: 'babel-loader', - options: { presets: [['@babel/preset-typescript', { allowNamespaces: true }]] }, - }, - ], - }, - stats: 'errors-only', - }; -}; +const config = (userConfig: Record): Configuration => ({ + ...userConfig, + mode: 'none', + module: { + rules: [ + { + test: /\.(js|ts)$/, + exclude: /node_modules/, + loader: 'babel-loader', + options: { presets: [['@babel/preset-typescript', { allowNamespaces: true }]] }, + }, + ], + }, + stats: 'errors-only', +}); export default config; diff --git a/packages/browser/src/helpers.ts b/packages/browser/src/helpers.ts index 2ba47baa0c3b..9fe980b691b0 100644 --- a/packages/browser/src/helpers.ts +++ b/packages/browser/src/helpers.ts @@ -11,7 +11,7 @@ import { export const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window; -let ignoreOnError: number = 0; +let ignoreOnError = 0; /** * @hidden diff --git a/packages/browser/src/integrations/breadcrumbs.ts b/packages/browser/src/integrations/breadcrumbs.ts index cfcb255f5999..3e20f7b8e2f1 100644 --- a/packages/browser/src/integrations/breadcrumbs.ts +++ b/packages/browser/src/integrations/breadcrumbs.ts @@ -59,7 +59,7 @@ export class Breadcrumbs implements Integration { /** * @inheritDoc */ - public static id: string = 'Breadcrumbs'; + public static id = 'Breadcrumbs'; /** * @inheritDoc diff --git a/packages/browser/src/integrations/dedupe.ts b/packages/browser/src/integrations/dedupe.ts index 2d4b51f58767..68f8b2183c06 100644 --- a/packages/browser/src/integrations/dedupe.ts +++ b/packages/browser/src/integrations/dedupe.ts @@ -8,7 +8,7 @@ export class Dedupe implements Integration { /** * @inheritDoc */ - public static id: string = 'Dedupe'; + public static id = 'Dedupe'; /** * @inheritDoc diff --git a/packages/browser/src/integrations/globalhandlers.ts b/packages/browser/src/integrations/globalhandlers.ts index 0c3f3be60e2d..230531168fd8 100644 --- a/packages/browser/src/integrations/globalhandlers.ts +++ b/packages/browser/src/integrations/globalhandlers.ts @@ -26,7 +26,7 @@ export class GlobalHandlers implements Integration { /** * @inheritDoc */ - public static id: string = 'GlobalHandlers'; + public static id = 'GlobalHandlers'; /** * @inheritDoc @@ -236,8 +236,8 @@ function _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column // event.exception.values[0].stacktrace.frames const ev0sf = (ev0s.frames = ev0s.frames || []); - const colno = isNaN(parseInt(column, 10)) ? undefined : column; - const lineno = isNaN(parseInt(line, 10)) ? undefined : line; + const colno = Number.isNaN(parseInt(column, 10)) ? undefined : column; + const lineno = Number.isNaN(parseInt(line, 10)) ? undefined : line; const filename = isString(url) && url.length > 0 ? url : getLocationHref(); // event.exception.values[0].stacktrace.frames diff --git a/packages/browser/src/integrations/httpcontext.ts b/packages/browser/src/integrations/httpcontext.ts index 34e7029e504d..54343373dd80 100644 --- a/packages/browser/src/integrations/httpcontext.ts +++ b/packages/browser/src/integrations/httpcontext.ts @@ -7,7 +7,7 @@ export class HttpContext implements Integration { /** * @inheritDoc */ - public static id: string = 'HttpContext'; + public static id = 'HttpContext'; /** * @inheritDoc diff --git a/packages/browser/src/integrations/linkederrors.ts b/packages/browser/src/integrations/linkederrors.ts index b07b12c98263..138fc79a0d49 100644 --- a/packages/browser/src/integrations/linkederrors.ts +++ b/packages/browser/src/integrations/linkederrors.ts @@ -16,7 +16,7 @@ export class LinkedErrors implements Integration { /** * @inheritDoc */ - public static id: string = 'LinkedErrors'; + public static id = 'LinkedErrors'; /** * @inheritDoc diff --git a/packages/browser/src/integrations/trycatch.ts b/packages/browser/src/integrations/trycatch.ts index 03dc1fcd2a80..4b3971b15bb3 100644 --- a/packages/browser/src/integrations/trycatch.ts +++ b/packages/browser/src/integrations/trycatch.ts @@ -53,7 +53,7 @@ export class TryCatch implements Integration { /** * @inheritDoc */ - public static id: string = 'TryCatch'; + public static id = 'TryCatch'; /** * @inheritDoc @@ -148,14 +148,12 @@ function _wrapRAF(original: any): (callback: () => void) => any { function _wrapXHR(originalSend: () => void): () => void { // eslint-disable-next-line @typescript-eslint/no-explicit-any return function (this: XMLHttpRequest, ...args: any[]): void { - // eslint-disable-next-line @typescript-eslint/no-this-alias - const xhr = this; const xmlHttpRequestProps: XMLHttpRequestProp[] = ['onload', 'onerror', 'onprogress', 'onreadystatechange']; xmlHttpRequestProps.forEach(prop => { - if (prop in xhr && typeof xhr[prop] === 'function') { + if (prop in this && typeof this[prop] === 'function') { // eslint-disable-next-line @typescript-eslint/no-explicit-any - fill(xhr, prop, function (original: WrappedFunction): () => any { + fill(this, prop, (original: WrappedFunction): (() => any) => { const wrapOptions = { mechanism: { data: { @@ -195,69 +193,75 @@ function _wrapEventTarget(target: string): void { return; } - fill(proto, 'addEventListener', function (original: VoidFunction,): ( - eventName: string, - fn: EventListenerObject, - options?: boolean | AddEventListenerOptions, - ) => void { - return function ( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - this: any, - eventName: string, - fn: EventListenerObject, - options?: boolean | AddEventListenerOptions, - ): (eventName: string, fn: EventListenerObject, capture?: boolean, secure?: boolean) => void { - try { - if (typeof fn.handleEvent === 'function') { - // ESlint disable explanation: - // First, it is generally safe to call `wrap` with an unbound function. Furthermore, using `.bind()` would - // introduce a bug here, because bind returns a new function that doesn't have our - // flags(like __sentry_original__) attached. `wrap` checks for those flags to avoid unnecessary wrapping. - // Without those flags, every call to addEventListener wraps the function again, causing a memory leak. - // eslint-disable-next-line @typescript-eslint/unbound-method - fn.handleEvent = wrap(fn.handleEvent, { + fill( + proto, + 'addEventListener', + ( + original: VoidFunction, + ): ((eventName: string, fn: EventListenerObject, options?: boolean | AddEventListenerOptions) => void) => + function ( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + this: any, + eventName: string, + fn: EventListenerObject, + options?: boolean | AddEventListenerOptions, + ): (eventName: string, fn: EventListenerObject, capture?: boolean, secure?: boolean) => void { + try { + if (typeof fn.handleEvent === 'function') { + // ESlint disable explanation: + // First, it is generally safe to call `wrap` with an unbound function. Furthermore, using `.bind()` would + // introduce a bug here, because bind returns a new function that doesn't have our + // flags(like __sentry_original__) attached. `wrap` checks for those flags to avoid unnecessary wrapping. + // Without those flags, every call to addEventListener wraps the function again, causing a memory leak. + // eslint-disable-next-line @typescript-eslint/unbound-method + fn.handleEvent = wrap(fn.handleEvent, { + mechanism: { + data: { + function: 'handleEvent', + handler: getFunctionName(fn), + target, + }, + handled: false, + type: 'instrument', + }, + }); + } + } catch (err) { + // can sometimes get 'Permission denied to access property "handle Event' + } + + return original.apply(this, [ + eventName, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + wrap(fn as any as WrappedFunction, { mechanism: { data: { - function: 'handleEvent', + function: 'addEventListener', handler: getFunctionName(fn), target, }, handled: false, type: 'instrument', }, - }); - } - } catch (err) { - // can sometimes get 'Permission denied to access property "handle Event' - } - - return original.apply(this, [ - eventName, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - wrap(fn as any as WrappedFunction, { - mechanism: { - data: { - function: 'addEventListener', - handler: getFunctionName(fn), - target, - }, - handled: false, - type: 'instrument', - }, - }), - options, - ]); - }; - }); + }), + options, + ]); + }, + ); fill( proto, 'removeEventListener', - function ( + ( originalRemoveEventListener: () => void, // eslint-disable-next-line @typescript-eslint/no-explicit-any - ): (this: any, eventName: string, fn: EventListenerObject, options?: boolean | EventListenerOptions) => () => void { - return function ( + ): (( + this: any, + eventName: string, + fn: EventListenerObject, + options?: boolean | EventListenerOptions, + ) => () => void) => + function ( // eslint-disable-next-line @typescript-eslint/no-explicit-any this: any, eventName: string, @@ -291,7 +295,6 @@ function _wrapEventTarget(target: string): void { // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments } return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options); - }; - }, + }, ); } diff --git a/packages/browser/src/loader.js b/packages/browser/src/loader.js index 19d7bfb5a7e9..38b0f5c111bb 100644 --- a/packages/browser/src/loader.js +++ b/packages/browser/src/loader.js @@ -1,5 +1,5 @@ // biome-ignore format: Disabled due to trailing comma not working in IE10/11 -(function( +(( _window, _document, _script, @@ -10,7 +10,7 @@ _sdkBundleUrl, _config, _lazy -) { +) => { var lazy = _lazy; var forceLoad = false; @@ -30,7 +30,7 @@ // Create a namespace and attach function that will store captured exception // Because functions are also objects, we can attach the queue itself straight to it and save some bytes - var queue = function(content) { + var queue = (content) => { // content.e = error // content.p = promise rejection // content.f = function call the Sentry @@ -68,7 +68,7 @@ _newScriptTag.crossOrigin = 'anonymous'; // Once our SDK is loaded - _newScriptTag.addEventListener('load', function() { + _newScriptTag.addEventListener('load', () => { try { // Restore onerror/onunhandledrejection handlers _window[_onerror] = _oldOnerror; @@ -82,7 +82,7 @@ var oldInit = SDK.init; // Configure it using provided DSN and config object - SDK.init = function(options) { + SDK.init = (options) => { var target = _config; for (var key in options) { if (Object.prototype.hasOwnProperty.call(options, key)) { @@ -160,7 +160,7 @@ // We make sure we do not overwrite window.Sentry since there could be already integrations in there _window[_namespace] = _window[_namespace] || {}; - _window[_namespace].onLoad = function (callback) { + _window[_namespace].onLoad = (callback) => { onLoadCallbacks.push(callback); if (lazy && !forceLoad) { return; @@ -168,10 +168,10 @@ injectSdk(onLoadCallbacks); }; - _window[_namespace].forceLoad = function() { + _window[_namespace].forceLoad = () => { forceLoad = true; if (lazy) { - setTimeout(function() { + setTimeout(() => { injectSdk(onLoadCallbacks); }); } @@ -187,8 +187,8 @@ 'configureScope', 'withScope', 'showReportDialog' - ].forEach(function(f) { - _window[_namespace][f] = function() { + ].forEach((f) => { + _window[_namespace][f] = () => { queue({ f: f, a: arguments }); }; }); @@ -196,7 +196,7 @@ // Store reference to the old `onerror` handler and override it with our own function // that will just push exceptions to the queue and call through old handler if we found one var _oldOnerror = _window[_onerror]; - _window[_onerror] = function(message, source, lineno, colno, exception) { + _window[_onerror] = (message, source, lineno, colno, exception) => { // Use keys as "data type" to save some characters" queue({ e: [].slice.call(arguments) @@ -207,7 +207,7 @@ // Do the same store/queue/call operations for `onunhandledrejection` event var _oldOnunhandledrejection = _window[_onunhandledrejection]; - _window[_onunhandledrejection] = function(e) { + _window[_onunhandledrejection] = (e) => { queue({ p: 'reason' in e ? e.reason : 'detail' in e && 'reason' in e.detail ? e.detail.reason : e }); @@ -215,7 +215,7 @@ }; if (!lazy) { - setTimeout(function () { + setTimeout(() => { injectSdk(onLoadCallbacks); }); } diff --git a/packages/browser/src/profiling/integration.ts b/packages/browser/src/profiling/integration.ts index 326af29492cf..b37bfdf720f3 100644 --- a/packages/browser/src/profiling/integration.ts +++ b/packages/browser/src/profiling/integration.ts @@ -25,7 +25,7 @@ import { * @experimental */ export class BrowserProfilingIntegration implements Integration { - public static id: string = 'BrowserProfilingIntegration'; + public static id = 'BrowserProfilingIntegration'; public readonly name: string; diff --git a/packages/browser/src/profiling/utils.ts b/packages/browser/src/profiling/utils.ts index 3edb82e0b539..73bd1034b0fe 100644 --- a/packages/browser/src/profiling/utils.ts +++ b/packages/browser/src/profiling/utils.ts @@ -416,7 +416,7 @@ export function applyDebugMetadata(resource_paths: ReadonlyArray): Debug */ export function isValidSampleRate(rate: unknown): boolean { // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck - if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) { + if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && Number.isNaN(rate))) { DEBUG_BUILD && logger.warn( `[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify( @@ -462,7 +462,7 @@ function isValidProfile(profile: JSSelfProfile): profile is JSSelfProfile & { pr // Keep a flag value to avoid re-initializing the profiler constructor. If it fails // once, it will always fail and this allows us to early return. -let PROFILING_CONSTRUCTOR_FAILED: boolean = false; +let PROFILING_CONSTRUCTOR_FAILED = false; export const MAX_PROFILE_DURATION_MS = 30_000; /** diff --git a/packages/browser/src/transports/offline.ts b/packages/browser/src/transports/offline.ts index 099e6ad462c1..de28a3fa9316 100644 --- a/packages/browser/src/transports/offline.ts +++ b/packages/browser/src/transports/offline.ts @@ -107,7 +107,7 @@ function createIndexedDbStore(options: BrowserOfflineTransportOptions): OfflineS // Lazily create the store only when it's needed function getStore(): Store { - if (store == undefined) { + if (store === undefined) { store = createStore(options.dbName || 'sentry-offline', options.storeName || 'queue'); } diff --git a/packages/browser/test/integration/common/init.js b/packages/browser/test/integration/common/init.js index 8215232aadcc..0ac8d96a00d7 100644 --- a/packages/browser/test/integration/common/init.js +++ b/packages/browser/test/integration/common/init.js @@ -26,12 +26,12 @@ function initSDK() { attachStacktrace: true, ignoreErrors: ['ignoreErrorTest'], denyUrls: ['foo.js'], - beforeSend: function (event, eventHint) { + beforeSend: (event, eventHint) => { events.push(event); eventHints.push(eventHint); return event; }, - beforeBreadcrumb: function (breadcrumb, breadcrumbHint) { + beforeBreadcrumb: (breadcrumb, breadcrumbHint) => { // Filter console logs as we use them for debugging *a lot* and they are not *that* important // But allow then if we explicitly say so (for one of integration tests) if (breadcrumb.category === 'console' && !window.allowConsoleBreadcrumbs) { diff --git a/packages/browser/test/integration/common/triggers.js b/packages/browser/test/integration/common/triggers.js index e3775317a112..dc2bb5840d3b 100644 --- a/packages/browser/test/integration/common/triggers.js +++ b/packages/browser/test/integration/common/triggers.js @@ -23,7 +23,7 @@ function throwNonError() { } function throwError(message) { - // eslint-disable-next-line no-param-reassign + // biome-ignore lint/style/noParameterAssign: Disable message = message || 'foo'; try { throw new Error(message); @@ -46,7 +46,7 @@ function throwSameConsecutiveErrors(message) { } function captureMessage(message) { - // eslint-disable-next-line no-param-reassign + // biome-ignore lint/style/noParameterAssign: Disable message = message || 'message'; Sentry.captureMessage(message); } diff --git a/packages/browser/test/integration/common/utils.js b/packages/browser/test/integration/common/utils.js index fb267ee0126a..269adac17929 100644 --- a/packages/browser/test/integration/common/utils.js +++ b/packages/browser/test/integration/common/utils.js @@ -67,7 +67,7 @@ function waitForXHR(xhr, cb) { return cb(); } - setTimeout(function () { + setTimeout(() => { waitForXHR(xhr, cb); }, 1000 / 60); } diff --git a/packages/browser/test/integration/suites/api.js b/packages/browser/test/integration/suites/api.js index 9cb59277c6e0..3c09f71f57b6 100644 --- a/packages/browser/test/integration/suites/api.js +++ b/packages/browser/test/integration/suites/api.js @@ -1,44 +1,41 @@ -describe('API', function () { - it('should capture Sentry.captureMessage', function () { - return runInSandbox(sandbox, function () { +describe('API', () => { + it('should capture Sentry.captureMessage', () => + runInSandbox(sandbox, () => { Sentry.captureMessage('Hello'); - }).then(function (summary) { + }).then(summary => { assert.equal(summary.events[0].message, 'Hello'); - }); - }); + })); - it('should capture Sentry.captureException', function () { - return runInSandbox(sandbox, function () { + it('should capture Sentry.captureException', () => + runInSandbox(sandbox, () => { try { foo(); } catch (e) { Sentry.captureException(e); } - }).then(function (summary) { + }).then(summary => { assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 2); assert.isAtMost(summary.events[0].exception.values[0].stacktrace.frames.length, 4); - }); - }); + })); - it('should capture Sentry internal event as breadcrumbs for the following event sent', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should capture Sentry internal event as breadcrumbs for the following event sent', () => + runInSandbox(sandbox, { manual: true }, () => { window.allowSentryBreadcrumbs = true; Sentry.captureMessage('a'); Sentry.captureMessage('b'); // For the loader Sentry.flush && Sentry.flush(2000); window.finalizeManualTest(); - }).then(function (summary) { + }).then(summary => { assert.equal(summary.events.length, 2); assert.equal(summary.breadcrumbs.length, 2); assert.equal(summary.events[1].breadcrumbs[0].category, 'sentry.event'); assert.equal(summary.events[1].breadcrumbs[0].event_id, summary.events[0].event_id); assert.equal(summary.events[1].breadcrumbs[0].level, summary.events[0].level); - }); - }); + })); - it('should capture Sentry internal transaction as breadcrumbs for the following event sent', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should capture Sentry internal transaction as breadcrumbs for the following event sent', () => + runInSandbox(sandbox, { manual: true }, () => { window.allowSentryBreadcrumbs = true; Sentry.captureEvent({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', @@ -50,7 +47,7 @@ describe('API', function () { // For the loader Sentry.flush && Sentry.flush(2000); window.finalizeManualTest(); - }).then(function (summary) { + }).then(summary => { // We have a length of one here since transactions don't go through beforeSend // and we add events to summary in beforeSend assert.equal(summary.events.length, 1); @@ -58,26 +55,24 @@ describe('API', function () { assert.equal(summary.events[0].breadcrumbs[0].category, 'sentry.transaction'); assert.isNotEmpty(summary.events[0].breadcrumbs[0].event_id); assert.isUndefined(summary.events[0].breadcrumbs[0].level); - }); - }); + })); - it('should generate a synthetic trace for captureException w/ non-errors', function () { - return runInSandbox(sandbox, function () { + it('should generate a synthetic trace for captureException w/ non-errors', () => + runInSandbox(sandbox, () => { throwNonError(); - }).then(function (summary) { + }).then(summary => { assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 1); assert.isAtMost(summary.events[0].exception.values[0].stacktrace.frames.length, 3); - }); - }); + })); - it('should have correct stacktrace order', function () { - return runInSandbox(sandbox, function () { + it('should have correct stacktrace order', () => + runInSandbox(sandbox, () => { try { foo(); } catch (e) { Sentry.captureException(e); } - }).then(function (summary) { + }).then(summary => { assert.equal( summary.events[0].exception.values[0].stacktrace.frames[ summary.events[0].exception.values[0].stacktrace.frames.length - 1 @@ -86,20 +81,18 @@ describe('API', function () { ); assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 2); assert.isAtMost(summary.events[0].exception.values[0].stacktrace.frames.length, 4); - }); - }); + })); - it('should have exception with type and value', function () { - return runInSandbox(sandbox, function () { + it('should have exception with type and value', () => + runInSandbox(sandbox, () => { Sentry.captureException('this is my test exception'); - }).then(function (summary) { + }).then(summary => { assert.isNotEmpty(summary.events[0].exception.values[0].value); assert.isNotEmpty(summary.events[0].exception.values[0].type); - }); - }); + })); - it('should reject duplicate, back-to-back errors from captureException', function () { - return runInSandbox(sandbox, function () { + it('should reject duplicate, back-to-back errors from captureException', () => + runInSandbox(sandbox, () => { // Different exceptions, don't dedupe for (var i = 0; i < 2; i++) { throwRandomError(); @@ -122,7 +115,7 @@ describe('API', function () { type: 'transaction', }); throwError(); - }).then(function (summary) { + }).then(summary => { // We have a length of one here since transactions don't go through beforeSend // and we add events to summary in beforeSend assert.equal(summary.events.length, 6); @@ -132,11 +125,10 @@ describe('API', function () { assert.equal(summary.events[3].exception.values[0].value, 'bar'); assert.equal(summary.events[4].exception.values[0].value, 'bar'); assert.equal(summary.events[5].exception.values[0].value, 'foo'); - }); - }); + })); - it('should not reject back-to-back errors with different stack traces', function () { - return runInSandbox(sandbox, function () { + it('should not reject back-to-back errors with different stack traces', () => + runInSandbox(sandbox, () => { // same error message, but different stacks means that these are considered // different errors @@ -165,7 +157,7 @@ describe('API', function () { } catch (e) { Sentry.captureException(e); } - }).then(function (summary) { + }).then(summary => { // NOTE: regex because exact error message differs per-browser assert.match(summary.events[0].exception.values[0].value, /baz/); assert.equal(summary.events[0].exception.values[0].type, 'ReferenceError'); @@ -173,11 +165,10 @@ describe('API', function () { assert.equal(summary.events[1].exception.values[0].type, 'ReferenceError'); assert.match(summary.events[2].exception.values[0].value, /baz/); assert.equal(summary.events[2].exception.values[0].type, 'ReferenceError'); - }); - }); + })); - it('should reject duplicate, back-to-back messages from captureMessage', function () { - return runInSandbox(sandbox, function () { + it('should reject duplicate, back-to-back messages from captureMessage', () => + runInSandbox(sandbox, () => { // Different messages, don't dedupe for (var i = 0; i < 2; i++) { captureRandomMessage(); @@ -190,7 +181,7 @@ describe('API', function () { // Same messages, different stacktrace (different line number), don't dedupe captureSameConsecutiveMessages('same message, different stacktrace'); - }).then(function (summary) { + }).then(summary => { // On the async loader since we replay all messages from the same location, // so we actually only receive 4 summary.events assert.match(summary.events[0].message, /Message no \d+/); @@ -198,6 +189,5 @@ describe('API', function () { assert.equal(summary.events[2].message, 'same message, same stacktrace'); assert.equal(summary.events[3].message, 'same message, different stacktrace'); !IS_LOADER && assert.equal(summary.events[4].message, 'same message, different stacktrace'); - }); - }); + })); }); diff --git a/packages/browser/test/integration/suites/breadcrumbs.js b/packages/browser/test/integration/suites/breadcrumbs.js index f0a0395bbe3f..ccec21250059 100644 --- a/packages/browser/test/integration/suites/breadcrumbs.js +++ b/packages/browser/test/integration/suites/breadcrumbs.js @@ -1,15 +1,15 @@ -describe('breadcrumbs', function () { - it(optional('should record an XMLHttpRequest with a handler', IS_LOADER), function () { - return runInSandbox(sandbox, { manual: true }, function () { +describe('breadcrumbs', () => { + it(optional('should record an XMLHttpRequest with a handler', IS_LOADER), () => + runInSandbox(sandbox, { manual: true }, () => { var xhr = new XMLHttpRequest(); xhr.open('GET', '/base/subjects/example.json'); - xhr.onreadystatechange = function () {}; + xhr.onreadystatechange = () => {}; xhr.send(); - waitForXHR(xhr, function () { + waitForXHR(xhr, () => { Sentry.captureMessage('test'); window.finalizeManualTest(); }); - }).then(function (summary) { + }).then(summary => { // The async loader doesn't wrap XHR if (IS_LOADER) { return; @@ -18,22 +18,22 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].type, 'http'); assert.equal(summary.breadcrumbs[0].category, 'xhr'); assert.equal(summary.breadcrumbs[0].data.method, 'GET'); - }); - }); + }), + ); - it(optional('should record an XMLHttpRequest with a handler attached after send was called', IS_LOADER), function () { - return runInSandbox(sandbox, { manual: true }, function () { + it(optional('should record an XMLHttpRequest with a handler attached after send was called', IS_LOADER), () => + runInSandbox(sandbox, { manual: true }, () => { var xhr = new XMLHttpRequest(); xhr.open('GET', '/base/subjects/example.json'); xhr.send(); - xhr.onreadystatechange = function () { + xhr.onreadystatechange = () => { window.handlerCalled = true; }; - waitForXHR(xhr, function () { + waitForXHR(xhr, () => { Sentry.captureMessage('test'); window.finalizeManualTest(); }); - }).then(function (summary) { + }).then(summary => { // The async loader doesn't wrap XHR if (IS_LOADER) { return; @@ -45,19 +45,19 @@ describe('breadcrumbs', function () { assert.typeOf(summary.breadcrumbs[0].timestamp, 'number'); assert.isTrue(summary.window.handlerCalled); delete summary.window.handlerCalled; - }); - }); + }), + ); - it(optional('should record an XMLHttpRequest without any handlers set', IS_LOADER), function () { - return runInSandbox(sandbox, { manual: true }, function () { + it(optional('should record an XMLHttpRequest without any handlers set', IS_LOADER), () => + runInSandbox(sandbox, { manual: true }, () => { var xhr = new XMLHttpRequest(); xhr.open('get', '/base/subjects/example.json'); xhr.send(); - waitForXHR(xhr, function () { + waitForXHR(xhr, () => { Sentry.captureMessage('test'); window.finalizeManualTest(); }); - }).then(function (summary) { + }).then(summary => { // The async loader doesn't wrap XHR if (IS_LOADER) { return; @@ -69,19 +69,19 @@ describe('breadcrumbs', function () { assert.isUndefined(summary.breadcrumbs[0].data.input); // To make sure that we are not providing this key for non-post requests assert.equal(summary.breadcrumbHints[0].input, undefined); - }); - }); + }), + ); - it(optional('should give access to request body for XMLHttpRequest POST requests', IS_LOADER), function () { - return runInSandbox(sandbox, { manual: true }, function () { + it(optional('should give access to request body for XMLHttpRequest POST requests', IS_LOADER), () => + runInSandbox(sandbox, { manual: true }, () => { var xhr = new XMLHttpRequest(); xhr.open('POST', '/base/subjects/example.json'); xhr.send('{"foo":"bar"}'); - waitForXHR(xhr, function () { + waitForXHR(xhr, () => { Sentry.captureMessage('test'); window.finalizeManualTest(); }); - }).then(function (summary) { + }).then(summary => { // The async loader doesn't wrap XHR if (IS_LOADER) { return; @@ -92,29 +92,29 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].data.method, 'POST'); assert.isUndefined(summary.breadcrumbs[0].data.input); assert.equal(summary.breadcrumbHints[0].input, '{"foo":"bar"}'); - }); - }); + }), + ); - it('should record a fetch request', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should record a fetch request', () => + runInSandbox(sandbox, { manual: true }, () => { fetch('/base/subjects/example.json', { method: 'Get', }) .then( - function () { + () => { Sentry.captureMessage('test'); }, - function () { + () => { Sentry.captureMessage('test'); }, ) - .then(function () { + .then(() => { window.finalizeManualTest(); }) - .catch(function () { + .catch(() => { window.finalizeManualTest(); }); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap fetch, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -134,27 +134,26 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].data.url, '/base/subjects/example.json'); } } - }); - }); + })); - it('should record a fetch request with Request obj instead of URL string', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should record a fetch request with Request obj instead of URL string', () => + runInSandbox(sandbox, { manual: true }, () => { fetch(new Request('/base/subjects/example.json')) .then( - function () { + () => { Sentry.captureMessage('test'); }, - function () { + () => { Sentry.captureMessage('test'); }, ) - .then(function () { + .then(() => { window.finalizeManualTest(); }) - .catch(function () { + .catch(() => { window.finalizeManualTest(); }); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap fetch, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -175,27 +174,26 @@ describe('breadcrumbs', function () { assert.ok(summary.breadcrumbs[0].data.url.indexOf('/base/subjects/example.json') !== -1); } } - }); - }); + })); - it('should record a fetch request with an arbitrary type argument', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should record a fetch request with an arbitrary type argument', () => + runInSandbox(sandbox, { manual: true }, () => { fetch(123) .then( - function () { + () => { Sentry.captureMessage('test'); }, - function () { + () => { Sentry.captureMessage('test'); }, ) - .then(function () { + .then(() => { window.finalizeManualTest(); }) - .catch(function () { + .catch(() => { window.finalizeManualTest(); }); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap fetch, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -215,18 +213,17 @@ describe('breadcrumbs', function () { assert.ok(summary.breadcrumbs[0].data.url.indexOf('123') !== -1); } } - }); - }); + })); - it('should provide a hint for dom events that includes event name and event itself', function () { - return runInSandbox(sandbox, function () { + it('should provide a hint for dom events that includes event name and event itself', () => + runInSandbox(sandbox, () => { var input = document.getElementsByTagName('input')[0]; - var clickHandler = function () {}; + var clickHandler = () => {}; input.addEventListener('click', clickHandler); var click = new MouseEvent('click'); input.dispatchEvent(click); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -235,11 +232,10 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbHints[0].name, 'click'); assert.equal(summary.breadcrumbHints[0].event.target.tagName, 'INPUT'); } - }); - }); + })); - it('should not fail with click or keypress handler with no callback', function () { - return runInSandbox(sandbox, function () { + it('should not fail with click or keypress handler with no callback', () => + runInSandbox(sandbox, () => { var input = document.getElementsByTagName('input')[0]; input.addEventListener('click', undefined); input.addEventListener('keypress', undefined); @@ -251,7 +247,7 @@ describe('breadcrumbs', function () { input.dispatchEvent(keypress); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -264,13 +260,12 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[1].category, 'ui.input'); assert.equal(summary.breadcrumbs[1].message, 'body > form#foo-form > input[name="foo"]'); } - }); - }); + })); - it('should not fail with custom event', function () { - return runInSandbox(sandbox, function () { + it('should not fail with custom event', () => + runInSandbox(sandbox, () => { var input = document.getElementsByTagName('input')[0]; - input.addEventListener('build', function (evt) { + input.addEventListener('build', evt => { evt.stopPropagation(); }); @@ -278,18 +273,17 @@ describe('breadcrumbs', function () { input.dispatchEvent(customEvent); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); } else { assert.equal(summary.breadcrumbs.length, 0); } - }); - }); + })); - it('should not fail with custom event and handler with no callback', function () { - return runInSandbox(sandbox, function () { + it('should not fail with custom event and handler with no callback', () => + runInSandbox(sandbox, () => { var input = document.getElementsByTagName('input')[0]; input.addEventListener('build', undefined); @@ -297,23 +291,22 @@ describe('breadcrumbs', function () { input.dispatchEvent(customEvent); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); } else { assert.equal(summary.breadcrumbs.length, 0); } - }); - }); + })); - it('should record a mouse click on element WITH click handler present', function () { - return runInSandbox(sandbox, function () { + it('should record a mouse click on element WITH click handler present', () => + runInSandbox(sandbox, () => { // add an event listener to the input. we want to make sure that // our breadcrumbs still work even if the page has an event listener // on an element that cancels event bubbling var input = document.getElementsByTagName('input')[0]; - var clickHandler = function (evt) { + var clickHandler = evt => { evt.stopPropagation(); // don't bubble }; input.addEventListener('click', clickHandler); @@ -323,7 +316,7 @@ describe('breadcrumbs', function () { input.dispatchEvent(click); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -333,18 +326,17 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].category, 'ui.click'); assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]'); } - }); - }); + })); - it('should record a mouse click on element WITHOUT click handler present', function () { - return runInSandbox(sandbox, function () { + it('should record a mouse click on element WITHOUT click handler present', () => + runInSandbox(sandbox, () => { // click var click = new MouseEvent('click'); var input = document.getElementsByTagName('input')[0]; input.dispatchEvent(click); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -354,12 +346,11 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].category, 'ui.click'); assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]'); } - }); - }); + })); - it('should only record a SINGLE mouse click for a tree of elements with event listeners', function () { - return runInSandbox(sandbox, function () { - var clickHandler = function () {}; + it('should only record a SINGLE mouse click for a tree of elements with event listeners', () => + runInSandbox(sandbox, () => { + var clickHandler = () => {}; // mousemove event shouldnt clobber subsequent "breadcrumbed" events (see #724) document.querySelector('.a').addEventListener('mousemove', clickHandler); @@ -374,7 +365,7 @@ describe('breadcrumbs', function () { input.dispatchEvent(click); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -384,12 +375,11 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].category, 'ui.click'); assert.equal(summary.breadcrumbs[0].message, 'body > div.c > div.b > div.a'); } - }); - }); + })); - it('should bail out if accessing the `target` property of an event throws an exception', function () { + it('should bail out if accessing the `target` property of an event throws an exception', () => { // see: https://github.com/getsentry/sentry-javascript/issues/768 - return runInSandbox(sandbox, function () { + return runInSandbox(sandbox, () => { // click var click = new MouseEvent('click'); function kaboom() { @@ -401,7 +391,7 @@ describe('breadcrumbs', function () { Sentry.captureMessage('test'); input.dispatchEvent(click); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -413,8 +403,8 @@ describe('breadcrumbs', function () { }); }); - it('should record consecutive keypress events into a single "input" breadcrumb', function () { - return runInSandbox(sandbox, function () { + it('should record consecutive keypress events into a single "input" breadcrumb', () => + runInSandbox(sandbox, () => { // keypress twice var keypress1 = new KeyboardEvent('keypress'); var keypress2 = new KeyboardEvent('keypress'); @@ -424,7 +414,7 @@ describe('breadcrumbs', function () { input.dispatchEvent(keypress2); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -434,23 +424,22 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].category, 'ui.input'); assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]'); } - }); - }); + })); - it('should correctly capture multiple consecutive breadcrumbs if they are of different type', function () { - return runInSandbox(sandbox, function () { + it('should correctly capture multiple consecutive breadcrumbs if they are of different type', () => + runInSandbox(sandbox, () => { var input = document.getElementsByTagName('input')[0]; - var clickHandler = function () {}; + var clickHandler = () => {}; input.addEventListener('click', clickHandler); - var keypressHandler = function () {}; + var keypressHandler = () => {}; input.addEventListener('keypress', keypressHandler); input.dispatchEvent(new MouseEvent('click')); input.dispatchEvent(new KeyboardEvent('keypress')); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -464,16 +453,15 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbHints[0].global, false); assert.equal(summary.breadcrumbHints[1].global, false); } - }); - }); + })); - it('should debounce multiple consecutive identical breadcrumbs but allow for switching to a different type', function () { - return runInSandbox(sandbox, function () { + it('should debounce multiple consecutive identical breadcrumbs but allow for switching to a different type', () => + runInSandbox(sandbox, () => { var input = document.getElementsByTagName('input')[0]; - var clickHandler = function () {}; + var clickHandler = () => {}; input.addEventListener('click', clickHandler); - var keypressHandler = function () {}; + var keypressHandler = () => {}; input.addEventListener('keypress', keypressHandler); input.dispatchEvent(new MouseEvent('click')); @@ -484,7 +472,7 @@ describe('breadcrumbs', function () { input.dispatchEvent(new KeyboardEvent('keypress')); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -498,15 +486,14 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbHints[0].global, false); assert.equal(summary.breadcrumbHints[1].global, false); } - }); - }); + })); - it('should debounce multiple consecutive identical breadcrumbs but allow for switching to a different target', function () { - return runInSandbox(sandbox, function () { + it('should debounce multiple consecutive identical breadcrumbs but allow for switching to a different target', () => + runInSandbox(sandbox, () => { var input = document.querySelector('#foo-form input'); var div = document.querySelector('#foo-form div'); - var clickHandler = function () {}; + var clickHandler = () => {}; input.addEventListener('click', clickHandler); div.addEventListener('click', clickHandler); @@ -514,7 +501,7 @@ describe('breadcrumbs', function () { div.dispatchEvent(new MouseEvent('click')); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -528,17 +515,16 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbHints[0].global, false); assert.equal(summary.breadcrumbHints[1].global, false); } - }); - }); + })); - it(optional('should flush keypress breadcrumbs when an error is thrown', IS_LOADER), function () { - return runInSandbox(sandbox, function () { + it(optional('should flush keypress breadcrumbs when an error is thrown', IS_LOADER), () => + runInSandbox(sandbox, () => { // keypress var keypress = new KeyboardEvent('keypress'); var input = document.getElementsByTagName('input')[0]; input.dispatchEvent(keypress); foo(); // throw exception - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { return; } @@ -548,11 +534,11 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs.length, 1); assert.equal(summary.breadcrumbs[0].category, 'ui.input'); assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]'); - }); - }); + }), + ); - it('should flush keypress breadcrumb when input event occurs immediately after', function () { - return runInSandbox(sandbox, function () { + it('should flush keypress breadcrumb when input event occurs immediately after', () => + runInSandbox(sandbox, () => { // 1st keypress var keypress1 = new KeyboardEvent('keypress'); // click @@ -566,7 +552,7 @@ describe('breadcrumbs', function () { input.dispatchEvent(keypress2); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -582,11 +568,10 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[2].category, 'ui.input'); assert.equal(summary.breadcrumbs[2].message, 'body > form#foo-form > input[name="foo"]'); } - }); - }); + })); - it('should record consecutive keypress events in a contenteditable into a single "input" breadcrumb', function () { - return runInSandbox(sandbox, function () { + it('should record consecutive keypress events in a contenteditable into a single "input" breadcrumb', () => + runInSandbox(sandbox, () => { // keypress twice var keypress1 = new KeyboardEvent('keypress'); var keypress2 = new KeyboardEvent('keypress'); @@ -596,7 +581,7 @@ describe('breadcrumbs', function () { div.dispatchEvent(keypress2); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -606,23 +591,22 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].category, 'ui.input'); assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > div.contenteditable'); } - }); - }); + })); - it('should record click events that were handled using an object with handleEvent property and call original callback', function () { - return runInSandbox(sandbox, function () { + it('should record click events that were handled using an object with handleEvent property and call original callback', () => + runInSandbox(sandbox, () => { window.handleEventCalled = false; var input = document.getElementsByTagName('input')[0]; input.addEventListener('click', { - handleEvent: function () { + handleEvent: () => { window.handleEventCalled = true; }, }); input.dispatchEvent(new MouseEvent('click')); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -633,23 +617,22 @@ describe('breadcrumbs', function () { assert.equal(summary.window.handleEventCalled, true); } - }); - }); + })); - it('should record keypress events that were handled using an object with handleEvent property and call original callback', function () { - return runInSandbox(sandbox, function () { + it('should record keypress events that were handled using an object with handleEvent property and call original callback', () => + runInSandbox(sandbox, () => { window.handleEventCalled = false; var input = document.getElementsByTagName('input')[0]; input.addEventListener('keypress', { - handleEvent: function () { + handleEvent: () => { window.handleEventCalled = true; }, }); input.dispatchEvent(new KeyboardEvent('keypress')); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -660,22 +643,21 @@ describe('breadcrumbs', function () { assert.equal(summary.window.handleEventCalled, true); } - }); - }); + })); - it('should remove breadcrumb instrumentation when all event listeners are detached', function () { - return runInSandbox(sandbox, function () { + it('should remove breadcrumb instrumentation when all event listeners are detached', () => + runInSandbox(sandbox, () => { var input = document.getElementsByTagName('input')[0]; - var clickHandler = function () {}; - var otherClickHandler = function () {}; + var clickHandler = () => {}; + var otherClickHandler = () => {}; input.addEventListener('click', clickHandler); input.addEventListener('click', otherClickHandler); input.removeEventListener('click', clickHandler); input.removeEventListener('click', otherClickHandler); - var keypressHandler = function () {}; - var otherKeypressHandler = function () {}; + var keypressHandler = () => {}; + var otherKeypressHandler = () => {}; input.addEventListener('keypress', keypressHandler); input.addEventListener('keypress', otherKeypressHandler); input.removeEventListener('keypress', keypressHandler); @@ -685,7 +667,7 @@ describe('breadcrumbs', function () { input.dispatchEvent(new KeyboardEvent('keypress')); Sentry.captureMessage('test'); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); @@ -695,52 +677,48 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbHints[0].global, true); assert.equal(summary.breadcrumbHints[1].global, true); } - }); - }); - - it( - optional('should record history.[pushState|replaceState] changes as navigation breadcrumbs', IS_LOADER), - function () { - return runInSandbox(sandbox, function () { - history.pushState({}, '', '/foo'); - history.pushState({}, '', '/bar?a=1#fragment'); - history.pushState({}, '', {}); // pushState calls toString on non-string args - history.pushState({}, '', null); // does nothing / no-op - // can't call history.back() because it will change url of parent document - // (e.g. document running mocha) ... instead just "emulate" a back button - // press by calling replaceState - history.replaceState({}, '', '/bar?a=1#fragment'); - Sentry.captureMessage('test'); - }).then(function (summary) { - if (IS_LOADER) { - // The async loader doesn't wrap history - return; - } - assert.equal(summary.breadcrumbs.length, 4); - assert.equal(summary.breadcrumbs[0].category, 'navigation'); // (start) => foo - assert.equal(summary.breadcrumbs[1].category, 'navigation'); // foo => bar?a=1#fragment - assert.equal(summary.breadcrumbs[2].category, 'navigation'); // bar?a=1#fragment => [object%20Object] - assert.equal(summary.breadcrumbs[3].category, 'navigation'); // [object%20Object] => bar?a=1#fragment (back button) + })); + + it(optional('should record history.[pushState|replaceState] changes as navigation breadcrumbs', IS_LOADER), () => + runInSandbox(sandbox, () => { + history.pushState({}, '', '/foo'); + history.pushState({}, '', '/bar?a=1#fragment'); + history.pushState({}, '', {}); // pushState calls toString on non-string args + history.pushState({}, '', null); // does nothing / no-op + // can't call history.back() because it will change url of parent document + // (e.g. document running mocha) ... instead just "emulate" a back button + // press by calling replaceState + history.replaceState({}, '', '/bar?a=1#fragment'); + Sentry.captureMessage('test'); + }).then(summary => { + if (IS_LOADER) { + // The async loader doesn't wrap history + return; + } + assert.equal(summary.breadcrumbs.length, 4); + assert.equal(summary.breadcrumbs[0].category, 'navigation'); // (start) => foo + assert.equal(summary.breadcrumbs[1].category, 'navigation'); // foo => bar?a=1#fragment + assert.equal(summary.breadcrumbs[2].category, 'navigation'); // bar?a=1#fragment => [object%20Object] + assert.equal(summary.breadcrumbs[3].category, 'navigation'); // [object%20Object] => bar?a=1#fragment (back button) - assert.ok(/\/base\/variants\/.*\.html$/.test(summary.breadcrumbs[0].data.from), "'from' url is incorrect"); - assert.ok(/\/foo$/.test(summary.breadcrumbs[0].data.to), "'to' url is incorrect"); + assert.ok(/\/base\/variants\/.*\.html$/.test(summary.breadcrumbs[0].data.from), "'from' url is incorrect"); + assert.ok(/\/foo$/.test(summary.breadcrumbs[0].data.to), "'to' url is incorrect"); - assert.ok(/\/foo$/.test(summary.breadcrumbs[1].data.from), "'from' url is incorrect"); - assert.ok(/\/bar\?a=1#fragment$/.test(summary.breadcrumbs[1].data.to), "'to' url is incorrect"); + assert.ok(/\/foo$/.test(summary.breadcrumbs[1].data.from), "'from' url is incorrect"); + assert.ok(/\/bar\?a=1#fragment$/.test(summary.breadcrumbs[1].data.to), "'to' url is incorrect"); - assert.ok(/\/bar\?a=1#fragment$/.test(summary.breadcrumbs[2].data.from), "'from' url is incorrect"); - assert.ok(/\[object Object\]$/.test(summary.breadcrumbs[2].data.to), "'to' url is incorrect"); + assert.ok(/\/bar\?a=1#fragment$/.test(summary.breadcrumbs[2].data.from), "'from' url is incorrect"); + assert.ok(/\[object Object\]$/.test(summary.breadcrumbs[2].data.to), "'to' url is incorrect"); - assert.ok(/\[object Object\]$/.test(summary.breadcrumbs[3].data.from), "'from' url is incorrect"); - assert.ok(/\/bar\?a=1#fragment/.test(summary.breadcrumbs[3].data.to), "'to' url is incorrect"); - }); - }, + assert.ok(/\[object Object\]$/.test(summary.breadcrumbs[3].data.from), "'from' url is incorrect"); + assert.ok(/\/bar\?a=1#fragment/.test(summary.breadcrumbs[3].data.to), "'to' url is incorrect"); + }), ); - it(optional('should preserve native code detection compatibility', IS_LOADER), function () { - return runInSandbox(sandbox, { manual: true }, function () { + it(optional('should preserve native code detection compatibility', IS_LOADER), () => + runInSandbox(sandbox, { manual: true }, () => { window.resolveTest(); - }).then(function () { + }).then(() => { if (IS_LOADER) { // The async loader doesn't wrap anything return; @@ -753,19 +731,19 @@ describe('breadcrumbs', function () { if ('fetch' in window) { assert.include(Function.prototype.toString.call(window.fetch), '[native code]'); } - }); - }); + }), + ); - it('should capture console breadcrumbs', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should capture console breadcrumbs', () => + runInSandbox(sandbox, { manual: true }, () => { window.allowConsoleBreadcrumbs = true; var logs = document.createElement('script'); logs.src = '/base/subjects/console-logs.js'; - logs.onload = function () { + logs.onload = () => { window.finalizeManualTest(); }; document.head.appendChild(logs); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't capture breadcrumbs, but we should receive the event without them assert.lengthOf(summary.events, 1); @@ -781,6 +759,5 @@ describe('breadcrumbs', function () { assert.deepEqual(summary.breadcrumbs[1].data.arguments, ['Two', { a: 1 }]); assert.deepEqual(summary.breadcrumbs[2].data.arguments, ['Error 2', { b: { c: [] } }]); } - }); - }); + })); }); diff --git a/packages/browser/test/integration/suites/builtins.js b/packages/browser/test/integration/suites/builtins.js index 54f86cd4f636..0d3433c3a2a8 100644 --- a/packages/browser/test/integration/suites/builtins.js +++ b/packages/browser/test/integration/suites/builtins.js @@ -1,6 +1,6 @@ -describe('wrapped built-ins', function () { - it('should capture exceptions from event listeners', function () { - return runInSandbox(sandbox, function () { +describe('wrapped built-ins', () => { + it('should capture exceptions from event listeners', () => + runInSandbox(sandbox, () => { var div = document.createElement('div'); document.body.appendChild(div); div.addEventListener( @@ -14,40 +14,38 @@ describe('wrapped built-ins', function () { ); var click = new MouseEvent('click'); div.dispatchEvent(click); - }).then(function (summary) { + }).then(summary => { // Make sure we preserve the correct context assert.equal(summary.window.element, summary.window.context); delete summary.window.element; delete summary.window.context; assert.match(summary.events[0].exception.values[0].value, /baz/); - }); - }); + })); - it('should transparently remove event listeners from wrapped functions', function () { - return runInSandbox(sandbox, function () { + it('should transparently remove event listeners from wrapped functions', () => + runInSandbox(sandbox, () => { var div = document.createElement('div'); document.body.appendChild(div); - var fooFn = function () { + var fooFn = () => { foo(); }; - var barFn = function () { + var barFn = () => { bar(); }; div.addEventListener('click', fooFn); div.addEventListener('click', barFn); div.removeEventListener('click', barFn); div.dispatchEvent(new MouseEvent('click')); - }).then(function (summary) { + }).then(summary => { assert.lengthOf(summary.events, 1); - }); - }); + })); - it('should remove the original callback if it was registered before Sentry initialized (w. original method)', function () { - return runInSandbox(sandbox, function () { + it('should remove the original callback if it was registered before Sentry initialized (w. original method)', () => + runInSandbox(sandbox, () => { var div = document.createElement('div'); document.body.appendChild(div); window.capturedCall = false; - var captureFn = function () { + var captureFn = () => { window.capturedCall = true; }; // Use original addEventListener to simulate non-wrapped behavior (callback is attached without __sentry_wrapped__) @@ -56,73 +54,69 @@ describe('wrapped built-ins', function () { div.addEventListener('click', captureFn); div.removeEventListener('click', captureFn); div.dispatchEvent(new MouseEvent('click')); - }).then(function (summary) { + }).then(summary => { assert.equal(summary.window.capturedCall, false); delete summary.window.capturedCalls; - }); - }); + })); - it('should capture exceptions inside setTimeout', function () { - return runInSandbox(sandbox, function () { - setTimeout(function () { + it('should capture exceptions inside setTimeout', () => + runInSandbox(sandbox, () => { + setTimeout(() => { foo(); }); - }).then(function (summary) { + }).then(summary => { assert.match(summary.events[0].exception.values[0].value, /baz/); - }); - }); + })); - it('should capture exceptions inside setInterval', function () { - return runInSandbox(sandbox, function () { - var exceptionInterval = setInterval(function () { + it('should capture exceptions inside setInterval', () => + runInSandbox(sandbox, () => { + var exceptionInterval = setInterval(() => { clearInterval(exceptionInterval); foo(); }, 0); - }).then(function (summary) { + }).then(summary => { assert.match(summary.events[0].exception.values[0].value, /baz/); - }); - }); + })); - describe('requestAnimationFrame', function () { - it('should capture exceptions inside callback', function () { + describe('requestAnimationFrame', () => { + it('should capture exceptions inside callback', () => { // needs to be visible or requestAnimationFrame won't ever fire sandbox.style.display = 'block'; - return runInSandbox(sandbox, { manual: true }, function () { - requestAnimationFrame(function () { + return runInSandbox(sandbox, { manual: true }, () => { + requestAnimationFrame(() => { window.finalizeManualTest(); foo(); }); - }).then(function (summary) { + }).then(summary => { assert.match(summary.events[0].exception.values[0].value, /baz/); }); }); - it('wrapped callback should preserve correct context - window (not-bound)', function () { + it('wrapped callback should preserve correct context - window (not-bound)', () => { // needs to be visible or requestAnimationFrame won't ever fire sandbox.style.display = 'block'; - return runInSandbox(sandbox, { manual: true }, function () { + return runInSandbox(sandbox, { manual: true }, () => { requestAnimationFrame(function () { window.capturedCtx = this; window.finalizeManualTest(); }); - }).then(function (summary) { + }).then(summary => { assert.strictEqual(summary.window.capturedCtx, summary.window); delete summary.window.capturedCtx; }); }); - it('wrapped callback should preserve correct context - class bound method', function () { + it('wrapped callback should preserve correct context - class bound method', () => { // needs to be visible or requestAnimationFrame won't ever fire sandbox.style.display = 'block'; - return runInSandbox(sandbox, { manual: true }, function () { + return runInSandbox(sandbox, { manual: true }, () => { // TypeScript-transpiled class syntax - var Foo = (function () { + var Foo = (() => { function Foo() { - var _this = this; this.magicNumber = 42; - this.getThis = function () { - window.capturedCtx = _this; + this.getThis = () => { + window.capturedCtx = this; window.finalizeManualTest(); }; } @@ -130,30 +124,30 @@ describe('wrapped built-ins', function () { })(); var foo = new Foo(); requestAnimationFrame(foo.getThis); - }).then(function (summary) { + }).then(summary => { assert.strictEqual(summary.window.capturedCtx.magicNumber, 42); delete summary.window.capturedCtx; }); }); - it('wrapped callback should preserve correct context - `bind` bound method', function () { + it('wrapped callback should preserve correct context - `bind` bound method', () => { // needs to be visible or requestAnimationFrame won't ever fire sandbox.style.display = 'block'; - return runInSandbox(sandbox, { manual: true }, function () { + return runInSandbox(sandbox, { manual: true }, () => { function foo() { window.capturedCtx = this; window.finalizeManualTest(); } requestAnimationFrame(foo.bind({ magicNumber: 42 })); - }).then(function (summary) { + }).then(summary => { assert.strictEqual(summary.window.capturedCtx.magicNumber, 42); delete summary.window.capturedCtx; }); }); }); - it('should capture exceptions from XMLHttpRequest event handlers (e.g. onreadystatechange)', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should capture exceptions from XMLHttpRequest event handlers (e.g. onreadystatechange)', () => + runInSandbox(sandbox, { manual: true }, () => { var xhr = new XMLHttpRequest(); xhr.open('GET', '/base/subjects/example.json'); // intentionally assign event handlers *after* open, since this is what jQuery does @@ -161,11 +155,11 @@ describe('wrapped built-ins', function () { window.finalizeManualTest(); // replace onreadystatechange with no-op so exception doesn't // fire more than once as XHR changes loading state - xhr.onreadystatechange = function () {}; + xhr.onreadystatechange = () => {}; foo(); }; xhr.send(); - }).then(function (summary) { + }).then(summary => { assert.match(summary.events[0].exception.values[0].value, /baz/); if (IS_LOADER) { @@ -188,11 +182,10 @@ describe('wrapped built-ins', function () { }, }); } - }); - }); + })); - it('should not call XMLHttpRequest onreadystatechange more than once per state', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should not call XMLHttpRequest onreadystatechange more than once per state', () => + runInSandbox(sandbox, { manual: true }, () => { window.calls = {}; var xhr = new XMLHttpRequest(); xhr.open('GET', '/base/subjects/example.json'); @@ -203,7 +196,7 @@ describe('wrapped built-ins', function () { } }; xhr.send(); - }).then(function (summary) { + }).then(summary => { for (var state in summary.window.calls) { assert.equal(summary.window.calls[state], 1); } @@ -212,15 +205,14 @@ describe('wrapped built-ins', function () { assert.isAtLeast(Object.keys(summary.window.calls).length, 3); assert.isAtMost(Object.keys(summary.window.calls).length, 4); delete summary.window.calls; - }); - }); + })); - it(optional("should capture built-in's mechanism type as instrument", IS_LOADER), function () { - return runInSandbox(sandbox, function () { - setTimeout(function () { + it(optional("should capture built-in's mechanism type as instrument", IS_LOADER), () => + runInSandbox(sandbox, () => { + setTimeout(() => { foo(); }); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap setTimeout // so we don't receive the full mechanism @@ -240,11 +232,11 @@ describe('wrapped built-ins', function () { handled: false, }); } - }); - }); + }), + ); - it(optional("should capture built-in's handlers fn name in mechanism data", IS_LOADER), function () { - return runInSandbox(sandbox, function () { + it(optional("should capture built-in's handlers fn name in mechanism data", IS_LOADER), () => + runInSandbox(sandbox, () => { var div = document.createElement('div'); document.body.appendChild(div); div.addEventListener( @@ -256,7 +248,7 @@ describe('wrapped built-ins', function () { ); var click = new MouseEvent('click'); div.dispatchEvent(click); - }).then(function (summary) { + }).then(summary => { if (IS_LOADER) { // The async loader doesn't wrap addEventListener // so we don't receive the full mechanism @@ -283,44 +275,41 @@ describe('wrapped built-ins', function () { }, }); } - }); - }); + }), + ); - it( - optional('should fallback to fn name in mechanism data if one is unavailable', IS_LOADER), - function () { - return runInSandbox(sandbox, function () { - var div = document.createElement('div'); - document.body.appendChild(div); - div.addEventListener( - 'click', - function () { - foo(); - }, - false, - ); - var click = new MouseEvent('click'); - div.dispatchEvent(click); - }).then(function (summary) { - if (IS_LOADER) { - // The async loader doesn't wrap - assert.ok(summary.events[0].exception.values[0].mechanism); - } else { - var target = summary.events[0].exception.values[0].mechanism.data.target; - delete summary.events[0].exception.values[0].mechanism.data.target; + it(optional('should fallback to fn name in mechanism data if one is unavailable', IS_LOADER), () => + runInSandbox(sandbox, () => { + var div = document.createElement('div'); + document.body.appendChild(div); + div.addEventListener( + 'click', + () => { + foo(); + }, + false, + ); + var click = new MouseEvent('click'); + div.dispatchEvent(click); + }).then(summary => { + if (IS_LOADER) { + // The async loader doesn't wrap + assert.ok(summary.events[0].exception.values[0].mechanism); + } else { + var target = summary.events[0].exception.values[0].mechanism.data.target; + delete summary.events[0].exception.values[0].mechanism.data.target; - // IE vs. Rest of the world - assert.oneOf(target, ['Node', 'EventTarget']); - assert.deepEqual(summary.events[0].exception.values[0].mechanism, { - type: 'instrument', - handled: false, - data: { - function: 'addEventListener', - handler: '', - }, - }); - } - }); - }, + // IE vs. Rest of the world + assert.oneOf(target, ['Node', 'EventTarget']); + assert.deepEqual(summary.events[0].exception.values[0].mechanism, { + type: 'instrument', + handled: false, + data: { + function: 'addEventListener', + handler: '', + }, + }); + } + }), ); }); diff --git a/packages/browser/test/integration/suites/config.js b/packages/browser/test/integration/suites/config.js index 2637ea8c13b7..e42d656fea76 100644 --- a/packages/browser/test/integration/suites/config.js +++ b/packages/browser/test/integration/suites/config.js @@ -1,19 +1,18 @@ -describe('config', function () { - it('should allow to ignore specific errors', function () { - return runInSandbox(sandbox, function () { +describe('config', () => { + it('should allow to ignore specific errors', () => + runInSandbox(sandbox, () => { Sentry.captureException(new Error('foo')); Sentry.captureException(new Error('ignoreErrorTest')); Sentry.captureException(new Error('bar')); - }).then(function (summary) { + }).then(summary => { assert.equal(summary.events[0].exception.values[0].type, 'Error'); assert.equal(summary.events[0].exception.values[0].value, 'foo'); assert.equal(summary.events[1].exception.values[0].type, 'Error'); assert.equal(summary.events[1].exception.values[0].value, 'bar'); - }); - }); + })); - it('should allow to ignore specific urls', function () { - return runInSandbox(sandbox, function () { + it('should allow to ignore specific urls', () => + runInSandbox(sandbox, () => { /** * We always filter on the caller, not the cause of the error * @@ -46,10 +45,9 @@ describe('config', function () { Sentry.captureException(urlWithDeniedUrl); Sentry.captureException(urlWithoutDeniedUrl); - }).then(function (summary) { + }).then(summary => { assert.lengthOf(summary.events, 1); assert.equal(summary.events[0].exception.values[0].type, 'Error'); assert.equal(summary.events[0].exception.values[0].value, 'pass'); - }); - }); + })); }); diff --git a/packages/browser/test/integration/suites/helpers.js b/packages/browser/test/integration/suites/helpers.js index a4104df81750..fea4cbcc48e0 100644 --- a/packages/browser/test/integration/suites/helpers.js +++ b/packages/browser/test/integration/suites/helpers.js @@ -7,25 +7,25 @@ function evaluateInSandbox(sandbox, code) { function runInSandbox(sandbox, options, code) { if (typeof options === 'function') { - // eslint-disable-next-line no-param-reassign + // biome-ignore lint/style/noParameterAssign: Disable code = options; - // eslint-disable-next-line no-param-reassign + // biome-ignore lint/style/noParameterAssign: Disable options = {}; } var resolveTest; - var donePromise = new Promise(function (resolve) { + var donePromise = new Promise(resolve => { resolveTest = resolve; }); - sandbox.contentWindow.resolveTest = function (summary) { + sandbox.contentWindow.resolveTest = summary => { clearTimeout(lastResort); resolveTest(summary); }; // If by some unexplainable way we reach the timeout limit, try to finalize the test and pray for the best // NOTE: 5000 so it's easier to grep for all timeout instances (shell.js, loader-specific.js and here) - var lastResort = setTimeout(function () { - var force = function () { + var lastResort = setTimeout(() => { + var force = () => { window.resolveTest({ events: events, breadcrumbs: breadcrumbs, @@ -37,7 +37,7 @@ function runInSandbox(sandbox, options, code) { } }, 5000 - 500); - var finalize = function () { + var finalize = () => { var summary = { events: events, eventHints: eventHints, @@ -46,20 +46,20 @@ function runInSandbox(sandbox, options, code) { window: window, }; - Sentry.onLoad(function () { - setTimeout(function () { + Sentry.onLoad(() => { + setTimeout(() => { Sentry.flush() - .then(function () { + .then(() => { window.resolveTest(summary); }) - .catch(function () { + .catch(() => { window.resolveTest(summary); }); }); }); }; - sandbox.contentWindow.finalizeManualTest = function () { + sandbox.contentWindow.finalizeManualTest = () => { evaluateInSandbox(sandbox, finalize.toString()); }; @@ -76,7 +76,7 @@ function createSandbox(done, file) { var sandbox = document.createElement('iframe'); sandbox.style.display = 'none'; sandbox.src = '/base/variants/' + file + '.html'; - sandbox.onload = function () { + sandbox.onload = () => { done(); }; document.body.appendChild(sandbox); diff --git a/packages/browser/test/integration/suites/loader-specific.js b/packages/browser/test/integration/suites/loader-specific.js index 6ebfd3fb84ab..dfa612139d4e 100644 --- a/packages/browser/test/integration/suites/loader-specific.js +++ b/packages/browser/test/integration/suites/loader-specific.js @@ -1,25 +1,25 @@ var loaderVariants = ['loader-with-no-global-init', 'loader-with-no-global-init-lazy-no']; for (var idx in loaderVariants) { - (function () { + (() => { describe(loaderVariants[idx], function () { this.timeout(60000); this.retries(3); var sandbox; - beforeEach(function (done) { + beforeEach(done => { sandbox = createSandbox(done, loaderVariants[idx]); }); - afterEach(function () { + afterEach(() => { document.body.removeChild(sandbox); }); - describe('Loader Specific Tests - With no Global init() call', function () { - it('should add breadcrumb from onLoad callback from undefined error', function () { - return runInSandbox(sandbox, function () { - Sentry.onLoad(function () { + describe('Loader Specific Tests - With no Global init() call', () => { + it('should add breadcrumb from onLoad callback from undefined error', () => + runInSandbox(sandbox, () => { + Sentry.onLoad(() => { initSDK(); Sentry.addBreadcrumb({ category: 'auth', @@ -27,16 +27,15 @@ for (var idx in loaderVariants) { level: 'error', }); }); - setTimeout(function () { + setTimeout(() => { Sentry.captureMessage('test'); }); undefinedMethod(); - }).then(function (summary) { + }).then(summary => { assert.ok(summary.breadcrumbs); assert.lengthOf(summary.breadcrumbs, 1); assert.equal(summary.breadcrumbs[0].message, 'testing loader'); - }); - }); + })); }); }); })(); diff --git a/packages/browser/test/integration/suites/loader.js b/packages/browser/test/integration/suites/loader.js index 55809f81e383..c7760e40a90c 100644 --- a/packages/browser/test/integration/suites/loader.js +++ b/packages/browser/test/integration/suites/loader.js @@ -1,19 +1,19 @@ if (IS_LOADER) { - describe('Loader Specific Tests', function () { - it('should add breadcrumb from onLoad callback from undefined error', function () { - return runInSandbox(sandbox, function () { - Sentry.onLoad(function () { + describe('Loader Specific Tests', () => { + it('should add breadcrumb from onLoad callback from undefined error', () => + runInSandbox(sandbox, () => { + Sentry.onLoad(() => { Sentry.addBreadcrumb({ category: 'auth', message: 'testing loader', level: 'error', }); }); - setTimeout(function () { + setTimeout(() => { Sentry.captureMessage('test'); }); undefinedMethod(); - }).then(function (summary) { + }).then(summary => { if (IS_ASYNC_LOADER) { assert.notOk(summary.events[0].breadcrumbs); } else { @@ -26,12 +26,11 @@ if (IS_LOADER) { assert.notOk(summary.events[0].breadcrumbs); } } - }); - }); + })); - it('should add breadcrumb from onLoad callback from undefined error with custom init()', function () { - return runInSandbox(sandbox, function () { - Sentry.onLoad(function () { + it('should add breadcrumb from onLoad callback from undefined error with custom init()', () => + runInSandbox(sandbox, () => { + Sentry.onLoad(() => { Sentry.init({ debug: true }); Sentry.addBreadcrumb({ category: 'auth', @@ -39,27 +38,26 @@ if (IS_LOADER) { level: 'error', }); }); - setTimeout(function () { + setTimeout(() => { Sentry.captureMessage('test'); }); undefinedMethod(); // trigger error - }).then(function (summary) { + }).then(summary => { assert.ok(summary.events[0].breadcrumbs); assert.lengthOf(summary.events[0].breadcrumbs, 1); assert.equal(summary.events[0].breadcrumbs[0].message, 'testing loader'); - }); - }); + })); it('should set SENTRY_SDK_SOURCE value', () => { - return runInSandbox(sandbox, function () { - Sentry.onLoad(function () { + return runInSandbox(sandbox, () => { + Sentry.onLoad(() => { Sentry.init({ debug: true }); }); - setTimeout(function () { + setTimeout(() => { Sentry.captureMessage('test'); }); undefinedMethod(); // trigger error - }).then(function (summary) { + }).then(summary => { assert.equal(summary.events[0].sdk.packages[0].name, 'loader:@sentry/browser'); }); }); diff --git a/packages/browser/test/integration/suites/onerror.js b/packages/browser/test/integration/suites/onerror.js index 1352d51e0484..97ede0f01fa3 100644 --- a/packages/browser/test/integration/suites/onerror.js +++ b/packages/browser/test/integration/suites/onerror.js @@ -1,8 +1,8 @@ -describe('window.onerror', function () { - it('should catch syntax errors', function () { - return runInSandbox(sandbox, function () { +describe('window.onerror', () => { + it('should catch syntax errors', () => + runInSandbox(sandbox, () => { eval('foo{};'); - }).then(function (summary) { + }).then(summary => { // ¯\_(ツ)_/¯ if (summary.window.isBelowIE11()) { assert.equal(summary.events[0].exception.values[0].type, 'Error'); @@ -10,21 +10,20 @@ describe('window.onerror', function () { assert.match(summary.events[0].exception.values[0].type, /SyntaxError/); } assert.equal(summary.events[0].exception.values[0].stacktrace.frames.length, 1); // just one frame - }); - }); + })); - it('should catch thrown strings', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should catch thrown strings', () => + runInSandbox(sandbox, { manual: true }, () => { // intentionally loading this error via a script file to make // sure it is 1) not caught by instrumentation 2) doesn't trigger // "Script error" var script = document.createElement('script'); script.src = '/base/subjects/throw-string.js'; - script.onload = function () { + script.onload = () => { window.finalizeManualTest(); }; document.head.appendChild(script); - }).then(function (summary) { + }).then(summary => { assert.match(summary.events[0].exception.values[0].value, /stringError$/); assert.equal(summary.events[0].exception.values[0].stacktrace.frames.length, 1); // always 1 because thrown strings can't provide > 1 frame @@ -38,21 +37,20 @@ describe('window.onerror', function () { summary.events[0].exception.values[0].stacktrace.frames[0]['function'], /throwStringError|\?|global code/i, ); - }); - }); + })); - it('should catch thrown objects', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should catch thrown objects', () => + runInSandbox(sandbox, { manual: true }, () => { // intentionally loading this error via a script file to make // sure it is 1) not caught by instrumentation 2) doesn't trigger // "Script error" var script = document.createElement('script'); script.src = '/base/subjects/throw-object.js'; - script.onload = function () { + script.onload = () => { window.finalizeManualTest(); }; document.head.appendChild(script); - }).then(function (summary) { + }).then(summary => { assert.equal(summary.events[0].exception.values[0].type, 'Error'); // ¯\_(ツ)_/¯ @@ -76,21 +74,20 @@ describe('window.onerror', function () { summary.events[0].exception.values[0].stacktrace.frames[0]['function'], /throwStringError|\?|global code/i, ); - }); - }); + })); - it('should catch thrown errors', function () { - return runInSandbox(sandbox, { manual: true }, function () { + it('should catch thrown errors', () => + runInSandbox(sandbox, { manual: true }, () => { // intentionally loading this error via a script file to make // sure it is 1) not caught by instrumentation 2) doesn't trigger // "Script error" var script = document.createElement('script'); script.src = '/base/subjects/throw-error.js'; - script.onload = function () { + script.onload = () => { window.finalizeManualTest(); }; document.head.appendChild(script); - }).then(function (summary) { + }).then(summary => { // ¯\_(ツ)_/¯ if (summary.window.isBelowIE11()) { assert.equal(summary.events[0].exception.values[0].type, 'Error'); @@ -106,16 +103,15 @@ describe('window.onerror', function () { summary.events[0].exception.values[0].stacktrace.frames[0]['function'], /\?|global code|throwRealError/i, ); - }); - }); + })); - it('should onerror calls with non-string first argument gracefully', function () { - return runInSandbox(sandbox, function () { + it('should onerror calls with non-string first argument gracefully', () => + runInSandbox(sandbox, () => { window.onerror({ type: 'error', otherKey: 'hi', }); - }).then(function (summary) { + }).then(summary => { assert.equal(summary.events[0].exception.values[0].type, 'Error'); assert.equal( summary.events[0].exception.values[0].value, @@ -125,22 +121,20 @@ describe('window.onerror', function () { type: 'error', otherKey: 'hi', }); - }); - }); + })); - it('should NOT catch an exception already caught [but rethrown] via Sentry.captureException', function () { - return runInSandbox(sandbox, function () { + it('should NOT catch an exception already caught [but rethrown] via Sentry.captureException', () => + runInSandbox(sandbox, () => { try { foo(); } catch (e) { Sentry.captureException(e); throw e; // intentionally re-throw } - }).then(function (summary) { + }).then(summary => { // IE10 uses different type (Error instead of ReferenceError) for rethrown errors... if (!summary.window.isBelowIE11()) { assert.equal(summary.events.length, 1); } - }); - }); + })); }); diff --git a/packages/browser/test/integration/suites/onunhandledrejection.js b/packages/browser/test/integration/suites/onunhandledrejection.js index 5c57ed228d77..f2bb769d73d5 100644 --- a/packages/browser/test/integration/suites/onunhandledrejection.js +++ b/packages/browser/test/integration/suites/onunhandledrejection.js @@ -1,12 +1,12 @@ -describe('window.onunhandledrejection', function () { - it('should capture unhandledrejection with error', function () { - return runInSandbox(sandbox, function () { +describe('window.onunhandledrejection', () => { + it('should capture unhandledrejection with error', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { Promise.reject(new Error('test2')); } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { assert.equal(summary.events[0].exception.values[0].value, 'test2'); assert.equal(summary.events[0].exception.values[0].type, 'Error'); @@ -18,16 +18,15 @@ describe('window.onunhandledrejection', function () { assert.equal(summary.events[0].exception.values[0].mechanism.handled, false); assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection'); } - }); - }); + })); // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and // https://github.com/getsentry/sentry-javascript/issues/2380 - it('should capture PromiseRejectionEvent cast to CustomEvent with type unhandledrejection', function () { - return runInSandbox(sandbox, function () { + it('should capture PromiseRejectionEvent cast to CustomEvent with type unhandledrejection', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { // this isn't how it happens in real life, in that the promise and reason // values come from an actual PromiseRejectionEvent, but it's enough to test @@ -35,7 +34,7 @@ describe('window.onunhandledrejection', function () { window.dispatchEvent( new CustomEvent('unhandledrejection', { detail: { - promise: new Promise(function () {}), + promise: new Promise(() => {}), // we're testing with an error here but it could be anything - really // all we're testing is that it gets dug out correctly reason: new Error('test2'), @@ -45,7 +44,7 @@ describe('window.onunhandledrejection', function () { } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { assert.equal(summary.events[0].exception.values[0].value, 'test2'); assert.equal(summary.events[0].exception.values[0].type, 'Error'); @@ -60,19 +59,18 @@ describe('window.onunhandledrejection', function () { // come through this channel assert.equal(summary.events.length, 1); } - }); - }); + })); // there's no evidence that this actually happens, but it could, and our code correctly // handles it, so might as well prevent future regression on that score - it('should capture a random Event with type unhandledrejection', function () { - return runInSandbox(sandbox, function () { + it('should capture a random Event with type unhandledrejection', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { window.dispatchEvent(new Event('unhandledrejection')); } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { // non-error rejections don't provide stacktraces so we can skip that assertion assert.equal( @@ -86,17 +84,16 @@ describe('window.onunhandledrejection', function () { // come through this channel assert.equal(summary.events.length, 1); } - }); - }); + })); - it('should capture unhandledrejection with a string', function () { - return runInSandbox(sandbox, function () { + it('should capture unhandledrejection with a string', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { Promise.reject('test'); } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { // non-error rejections don't provide stacktraces so we can skip that assertion assert.equal( @@ -107,17 +104,16 @@ describe('window.onunhandledrejection', function () { assert.equal(summary.events[0].exception.values[0].mechanism.handled, false); assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection'); } - }); - }); + })); - it('should capture unhandledrejection with a monster string', function () { - return runInSandbox(sandbox, function () { + it('should capture unhandledrejection with a monster string', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { Promise.reject('test'.repeat(100)); } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { // non-error rejections don't provide stacktraces so we can skip that assertion assert.equal(summary.events[0].exception.values[0].value.length, 253); @@ -129,17 +125,16 @@ describe('window.onunhandledrejection', function () { assert.equal(summary.events[0].exception.values[0].mechanism.handled, false); assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection'); } - }); - }); + })); - it('should capture unhandledrejection with an object', function () { - return runInSandbox(sandbox, function () { + it('should capture unhandledrejection with an object', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { Promise.reject({ a: 'b', b: 'c', c: 'd' }); } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { // non-error rejections don't provide stacktraces so we can skip that assertion assert.equal( @@ -150,11 +145,10 @@ describe('window.onunhandledrejection', function () { assert.equal(summary.events[0].exception.values[0].mechanism.handled, false); assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection'); } - }); - }); + })); - it('should capture unhandledrejection with an monster object', function () { - return runInSandbox(sandbox, function () { + it('should capture unhandledrejection with an monster object', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { var a = { a: '1'.repeat('100'), @@ -167,7 +161,7 @@ describe('window.onunhandledrejection', function () { } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { // non-error rejections don't provide stacktraces so we can skip that assertion assert.equal( @@ -178,17 +172,16 @@ describe('window.onunhandledrejection', function () { assert.equal(summary.events[0].exception.values[0].mechanism.handled, false); assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection'); } - }); - }); + })); - it('should capture unhandledrejection with a number', function () { - return runInSandbox(sandbox, function () { + it('should capture unhandledrejection with a number', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { Promise.reject(1337); } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { // non-error rejections don't provide stacktraces so we can skip that assertion assert.equal( @@ -199,17 +192,16 @@ describe('window.onunhandledrejection', function () { assert.equal(summary.events[0].exception.values[0].mechanism.handled, false); assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection'); } - }); - }); + })); - it('should capture unhandledrejection with null', function () { - return runInSandbox(sandbox, function () { + it('should capture unhandledrejection with null', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { Promise.reject(null); } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { // non-error rejections don't provide stacktraces so we can skip that assertion assert.equal( @@ -220,17 +212,16 @@ describe('window.onunhandledrejection', function () { assert.equal(summary.events[0].exception.values[0].mechanism.handled, false); assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection'); } - }); - }); + })); - it('should capture unhandledrejection with an undefined', function () { - return runInSandbox(sandbox, function () { + it('should capture unhandledrejection with an undefined', () => + runInSandbox(sandbox, () => { if (supportsOnunhandledRejection()) { Promise.reject(undefined); } else { window.resolveTest({ window: window }); } - }).then(function (summary) { + }).then(summary => { if (summary.window.supportsOnunhandledRejection()) { // non-error rejections don't provide stacktraces so we can skip that assertion assert.equal( @@ -241,6 +232,5 @@ describe('window.onunhandledrejection', function () { assert.equal(summary.events[0].exception.values[0].mechanism.handled, false); assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection'); } - }); - }); + })); }); diff --git a/packages/browser/test/integration/suites/shell.js b/packages/browser/test/integration/suites/shell.js index d3d89ed4b798..bc4123212c43 100644 --- a/packages/browser/test/integration/suites/shell.js +++ b/packages/browser/test/integration/suites/shell.js @@ -11,11 +11,11 @@ function runVariant(variant) { var sandbox; - beforeEach(function (done) { + beforeEach(done => { sandbox = createSandbox(done, variant); }); - afterEach(function () { + afterEach(() => { document.body.removeChild(sandbox); }); @@ -33,7 +33,7 @@ function runVariant(variant) { } for (var idx in variants) { - (function () { + (() => { runVariant(variants[idx]); })(); } diff --git a/packages/browser/test/package/npm-build.js b/packages/browser/test/package/npm-build.js index c74fb5ba9831..b5db4b64d9de 100644 --- a/packages/browser/test/package/npm-build.js +++ b/packages/browser/test/package/npm-build.js @@ -43,7 +43,7 @@ function runTests() { const bundlePath = path.join(__dirname, 'tmp.js'); const { window } = new JSDOM('', { runScripts: 'dangerously' }); - window.onerror = function () { + window.onerror = () => { console.error('ERROR thrown in manual test:'); console.error(arguments); console.error('------------------'); diff --git a/packages/browser/test/unit/profiling/integration.test.ts b/packages/browser/test/unit/profiling/integration.test.ts index 515398638048..ba57e4668ee6 100644 --- a/packages/browser/test/unit/profiling/integration.test.ts +++ b/packages/browser/test/unit/profiling/integration.test.ts @@ -20,7 +20,7 @@ describe('BrowserProfilingIntegration', () => { }); class MockProfiler { - stopped: boolean = false; + stopped = false; constructor(_opts: { sampleInterval: number; maxBufferSize: number }) {} stop() { this.stopped = true; diff --git a/packages/bun/src/integrations/bunserver.ts b/packages/bun/src/integrations/bunserver.ts index 6644728c19b3..0d71f8b577f8 100644 --- a/packages/bun/src/integrations/bunserver.ts +++ b/packages/bun/src/integrations/bunserver.ts @@ -9,7 +9,7 @@ export class BunServer implements Integration { /** * @inheritDoc */ - public static id: string = 'BunServer'; + public static id = 'BunServer'; /** * @inheritDoc diff --git a/packages/core/src/baseclient.ts b/packages/core/src/baseclient.ts index 0ea80e229c58..026b9e057e1c 100644 --- a/packages/core/src/baseclient.ts +++ b/packages/core/src/baseclient.ts @@ -108,7 +108,7 @@ export abstract class BaseClient implements Client { /** Holds flushable */ private _outcomes: { [key: string]: number }; - // eslint-disable-next-line @typescript-eslint/ban-types + // biome-ignore lint/complexity/noBannedTypes: Ignore for next line. private _hooks: Record; private _eventProcessors: EventProcessor[]; @@ -516,7 +516,7 @@ export abstract class BaseClient implements Client { */ protected _isClientDoneProcessing(timeout?: number): PromiseLike { return new SyncPromise(resolve => { - let ticked: number = 0; + let ticked = 0; const tick: number = 1; const interval = setInterval(() => { diff --git a/packages/core/src/eventProcessors.ts b/packages/core/src/eventProcessors.ts index 0f5e0f0202fa..438fc62744eb 100644 --- a/packages/core/src/eventProcessors.ts +++ b/packages/core/src/eventProcessors.ts @@ -27,7 +27,7 @@ export function notifyEventProcessors( processors: EventProcessor[], event: Event | null, hint: EventHint, - index: number = 0, + index = 0, ): PromiseLike { return new SyncPromise((resolve, reject) => { const processor = processors[index]; diff --git a/packages/core/src/hub.ts b/packages/core/src/hub.ts index 13d5fd059e93..cf1c8878bccf 100644 --- a/packages/core/src/hub.ts +++ b/packages/core/src/hub.ts @@ -88,7 +88,7 @@ export interface Carrier { integrations?: Integration[]; extensions?: { /** Extension methods for the hub, which are bound to the current Hub instance */ - // eslint-disable-next-line @typescript-eslint/ban-types + // biome-ignore lint/complexity/noBannedTypes: Ignore for next line. [key: string]: Function; }; }; @@ -402,10 +402,11 @@ Sentry.init({...}); /** * @inheritDoc */ - public captureSession(endSession: boolean = false): void { + public captureSession(endSession = false): void { // both send the update and pull the session from the scope if (endSession) { - return this.endSession(); + this.endSession(); + return; } // only send the update diff --git a/packages/core/src/integrations/functiontostring.ts b/packages/core/src/integrations/functiontostring.ts index b1db3224bc64..115381dddd26 100644 --- a/packages/core/src/integrations/functiontostring.ts +++ b/packages/core/src/integrations/functiontostring.ts @@ -8,7 +8,7 @@ export class FunctionToString implements Integration { /** * @inheritDoc */ - public static id: string = 'FunctionToString'; + public static id = 'FunctionToString'; /** * @inheritDoc diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index 9d348a4b4d23..0d695874bd6b 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -33,7 +33,7 @@ export class InboundFilters implements Integration { /** * @inheritDoc */ - public static id: string = 'InboundFilters'; + public static id = 'InboundFilters'; /** * @inheritDoc diff --git a/packages/core/src/integrations/linkederrors.ts b/packages/core/src/integrations/linkederrors.ts index 1b3ef1c39a19..76b14c9cd12f 100644 --- a/packages/core/src/integrations/linkederrors.ts +++ b/packages/core/src/integrations/linkederrors.ts @@ -9,7 +9,7 @@ export class LinkedErrors implements Integration { /** * @inheritDoc */ - public static id: string = 'LinkedErrors'; + public static id = 'LinkedErrors'; /** * @inheritDoc diff --git a/packages/core/src/integrations/metadata.ts b/packages/core/src/integrations/metadata.ts index caa9ad972e7d..818bcbf590aa 100644 --- a/packages/core/src/integrations/metadata.ts +++ b/packages/core/src/integrations/metadata.ts @@ -16,7 +16,7 @@ export class ModuleMetadata implements Integration { /* * @inheritDoc */ - public static id: string = 'ModuleMetadata'; + public static id = 'ModuleMetadata'; /** * @inheritDoc diff --git a/packages/core/src/integrations/requestdata.ts b/packages/core/src/integrations/requestdata.ts index 4481501d8b8c..c00e4ae91ed5 100644 --- a/packages/core/src/integrations/requestdata.ts +++ b/packages/core/src/integrations/requestdata.ts @@ -49,7 +49,7 @@ export class RequestData implements Integration { /** * @inheritDoc */ - public static id: string = 'RequestData'; + public static id = 'RequestData'; /** * @inheritDoc diff --git a/packages/core/src/scope.ts b/packages/core/src/scope.ts index ae6fe70e3185..af22ac427046 100644 --- a/packages/core/src/scope.ts +++ b/packages/core/src/scope.ts @@ -356,7 +356,7 @@ export class Scope implements ScopeInterface { this._propagationContext = captureContext._propagationContext; } } else if (isPlainObject(captureContext)) { - // eslint-disable-next-line no-param-reassign + // biome-ignore lint/style/noParameterAssign: Disable captureContext = captureContext as ScopeContext; this._tags = { ...this._tags, ...captureContext.tags }; this._extra = { ...this._extra, ...captureContext.extra }; diff --git a/packages/core/src/tracing/sampling.ts b/packages/core/src/tracing/sampling.ts index 6c6ab19bf7c9..846c9fecff21 100644 --- a/packages/core/src/tracing/sampling.ts +++ b/packages/core/src/tracing/sampling.ts @@ -1,5 +1,5 @@ import type { Options, SamplingContext } from '@sentry/types'; -import { isNaN, logger } from '@sentry/utils'; +import { logger } from '@sentry/utils'; import { DEBUG_BUILD } from '../debug-build'; import { hasTracingEnabled } from '../utils/hasTracingEnabled'; @@ -103,7 +103,7 @@ export function sampleTransaction( function isValidSampleRate(rate: unknown): boolean { // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck // eslint-disable-next-line @typescript-eslint/no-explicit-any - if (isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) { + if (Number.isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) { DEBUG_BUILD && logger.warn( `[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify( diff --git a/packages/core/src/tracing/span.ts b/packages/core/src/tracing/span.ts index 4b341a71e2c2..05afe3b41c2a 100644 --- a/packages/core/src/tracing/span.ts +++ b/packages/core/src/tracing/span.ts @@ -23,7 +23,7 @@ export class SpanRecorder { private readonly _maxlen: number; - public constructor(maxlen: number = 1000) { + public constructor(maxlen = 1000) { this._maxlen = maxlen; this.spans = []; } diff --git a/packages/core/src/tracing/transaction.ts b/packages/core/src/tracing/transaction.ts index be2e7324769a..1baefc0e02d1 100644 --- a/packages/core/src/tracing/transaction.ts +++ b/packages/core/src/tracing/transaction.ts @@ -98,7 +98,7 @@ export class Transaction extends SpanClass implements TransactionInterface { * Attaches SpanRecorder to the span itself * @param maxlen maximum number of spans that can be recorded */ - public initSpanRecorder(maxlen: number = 1000): void { + public initSpanRecorder(maxlen = 1000): void { if (!this.spanRecorder) { this.spanRecorder = new SpanRecorder(maxlen); } diff --git a/packages/core/test/lib/integration.test.ts b/packages/core/test/lib/integration.test.ts index 54bd426abb5c..9f6d60ce4e8d 100644 --- a/packages/core/test/lib/integration.test.ts +++ b/packages/core/test/lib/integration.test.ts @@ -330,7 +330,7 @@ describe('getIntegrationsToSetup', () => { }); describe('setupIntegration', () => { - beforeEach(function () { + beforeEach(() => { // Reset the (global!) list of installed integrations installedIntegrations.splice(0, installedIntegrations.length); }); @@ -601,7 +601,7 @@ describe('setupIntegration', () => { }); describe('addIntegration', () => { - beforeEach(function () { + beforeEach(() => { // Reset the (global!) list of installed integrations installedIntegrations.splice(0, installedIntegrations.length); }); diff --git a/packages/core/test/lib/tracing/trace.test.ts b/packages/core/test/lib/tracing/trace.test.ts index a9ea12ef89c0..381c1cb907a9 100644 --- a/packages/core/test/lib/tracing/trace.test.ts +++ b/packages/core/test/lib/tracing/trace.test.ts @@ -6,7 +6,7 @@ beforeAll(() => { addTracingExtensions(); }); -const enum Type { +enum Type { Sync = 'sync', Async = 'async', } diff --git a/packages/core/test/mocks/integration.ts b/packages/core/test/mocks/integration.ts index ce95d04520a7..340aae3ba31a 100644 --- a/packages/core/test/mocks/integration.ts +++ b/packages/core/test/mocks/integration.ts @@ -3,9 +3,9 @@ import type { Event, EventProcessor, Integration } from '@sentry/types'; import { configureScope, getCurrentHub } from '../../src'; export class TestIntegration implements Integration { - public static id: string = 'TestIntegration'; + public static id = 'TestIntegration'; - public name: string = 'TestIntegration'; + public name = 'TestIntegration'; public setupOnce(): void { const eventProcessor: EventProcessor = (event: Event) => { @@ -25,9 +25,9 @@ export class TestIntegration implements Integration { } export class AddAttachmentTestIntegration implements Integration { - public static id: string = 'AddAttachmentTestIntegration'; + public static id = 'AddAttachmentTestIntegration'; - public name: string = 'AddAttachmentTestIntegration'; + public name = 'AddAttachmentTestIntegration'; public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void { addGlobalEventProcessor((event, hint) => { @@ -38,9 +38,9 @@ export class AddAttachmentTestIntegration implements Integration { } export class AdHocIntegration implements Integration { - public static id: string = 'AdHockIntegration'; + public static id = 'AdHockIntegration'; - public name: string = 'AdHockIntegration'; + public name = 'AdHockIntegration'; public setupOnce(): void { // Noop diff --git a/packages/core/test/mocks/transport.ts b/packages/core/test/mocks/transport.ts index e2338327be16..ed06f5557329 100644 --- a/packages/core/test/mocks/transport.ts +++ b/packages/core/test/mocks/transport.ts @@ -8,7 +8,7 @@ async function sleep(delay: number): Promise { return new SyncPromise(resolve => setTimeout(resolve, delay)); } -export function makeFakeTransport(delay: number = 2000): { +export function makeFakeTransport(delay = 2000): { makeTransport: () => Transport; getSendCalled: () => number; getSentCount: () => number; diff --git a/packages/deno/src/integrations/normalizepaths.ts b/packages/deno/src/integrations/normalizepaths.ts index ab705a3a20a0..98b61efadaa3 100644 --- a/packages/deno/src/integrations/normalizepaths.ts +++ b/packages/deno/src/integrations/normalizepaths.ts @@ -42,7 +42,7 @@ function getCwd(): string | undefined { const permission = Deno.permissions.querySync({ name: 'read', path: './' }); try { - if (permission.state == 'granted') { + if (permission.state === 'granted') { return Deno.cwd(); } } catch (_) { diff --git a/packages/deno/test/normalize.ts b/packages/deno/test/normalize.ts index 64295932e00d..9b9a003464f2 100644 --- a/packages/deno/test/normalize.ts +++ b/packages/deno/test/normalize.ts @@ -71,8 +71,8 @@ function normalizeEvent(event: sentryTypes.Event): sentryTypes.Event { event.sdk.version = '{{version}}'; } - if (event?.sdk?.packages) { - for (const pkg of event?.sdk?.packages) { + if (event.sdk?.packages) { + for (const pkg of event.sdk.packages) { if (pkg.version) { pkg.version = '{{version}}'; } @@ -91,10 +91,8 @@ function normalizeEvent(event: sentryTypes.Event): sentryTypes.Event { event.contexts.v8.version = '{{version}}'; } - if (event.contexts?.runtime) { - if (event.contexts.runtime?.version) { - event.contexts.runtime.version = '{{version}}'; - } + if (event.contexts?.runtime?.version) { + event.contexts.runtime.version = '{{version}}'; } if (event.contexts?.device?.arch) { diff --git a/packages/e2e-tests/test-applications/create-react-app/src/App.tsx b/packages/e2e-tests/test-applications/create-react-app/src/App.tsx index 76b10d9085e2..95c572033e33 100644 --- a/packages/e2e-tests/test-applications/create-react-app/src/App.tsx +++ b/packages/e2e-tests/test-applications/create-react-app/src/App.tsx @@ -12,6 +12,7 @@ function App() {
{error.toString()}
{componentStack}