diff --git a/.eslintignore b/.eslintignore index 56cfd5d3dd6a..f52cb1b45b89 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,15 +2,11 @@ # THIS WILL BE REMOVED AFTER WE FINISH ESLINT UPGRADE packages/apm/**/* -packages/core/**/* packages/ember/**/* packages/gatsby/**/* -packages/hub/**/* packages/integrations/**/* -packages/minimal/**/* packages/node/**/* packages/react/**/* packages/tracing/**/* -packages/types/**/* packages/typescript/**/* packages/utils/**/* diff --git a/.eslintrc.js b/.eslintrc.js index 5c19200dc232..722b72439983 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -93,6 +93,8 @@ module.exports = { files: ['*.test.ts', '*.test.tsx', '*.test.js', '*.test.jsx'], rules: { 'max-lines': 'off', + + '@typescript-eslint/explicit-function-return-type': 'off', }, }, { @@ -123,5 +125,8 @@ module.exports = { // Limit maximum file size to reduce complexity. Turned off in tests. 'max-lines': 'error', + + // We should require a whitespace beginning a comment + 'spaced-comment': 'error', }, }; diff --git a/dangerfile.ts b/dangerfile.ts index 96373cabebd3..56f90cf5c0e9 100644 --- a/dangerfile.ts +++ b/dangerfile.ts @@ -6,7 +6,7 @@ import tslint from 'danger-plugin-tslint'; import { prettyResults } from 'danger-plugin-tslint/dist/prettyResults'; import { CLIEngine } from 'eslint'; -const PACKAGES = ['apm', 'core', 'hub', 'integrations', 'minimal', 'node', 'types', 'utils']; +const PACKAGES = ['apm', 'integrations', 'node', 'utils']; const EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx']; /** diff --git a/packages/browser/src/helpers.ts b/packages/browser/src/helpers.ts index a3df57e153ac..ef6663621cbd 100644 --- a/packages/browser/src/helpers.ts +++ b/packages/browser/src/helpers.ts @@ -153,9 +153,8 @@ export function wrap( }, }); } - } catch (_oO) { - /*no-empty*/ - } + // eslint-disable-next-line no-empty + } catch (_oO) {} return sentryWrapped; } diff --git a/packages/browser/test/integration/common/utils.js b/packages/browser/test/integration/common/utils.js index c876766af509..68b4314b0f6d 100644 --- a/packages/browser/test/integration/common/utils.js +++ b/packages/browser/test/integration/common/utils.js @@ -50,6 +50,7 @@ function supportsOnunhandledRejection() { } function isBelowIE11() { + // eslint-disable-next-line spaced-comment return /*@cc_on!@*/ false == !false; } diff --git a/packages/browser/test/integration/polyfills/fetch.js b/packages/browser/test/integration/polyfills/fetch.js index fcb4cbc4fd9f..3611142c0683 100644 --- a/packages/browser/test/integration/polyfills/fetch.js +++ b/packages/browser/test/integration/polyfills/fetch.js @@ -1,4 +1,4 @@ -/*! +/* ! * @overview whatwg-fetch - an implementation of Fetch API. * @copyright Copyright (c) 2014-2016 GitHub, Inc. * @license Licensed under MIT license diff --git a/packages/browser/test/integration/polyfills/promise.js b/packages/browser/test/integration/polyfills/promise.js index 8afc15ba3dd6..5082e75d5820 100644 --- a/packages/browser/test/integration/polyfills/promise.js +++ b/packages/browser/test/integration/polyfills/promise.js @@ -1,4 +1,4 @@ -/*! +/* ! * @overview es6-promise - an implementation of Promise API. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @license Licensed under MIT license @@ -222,7 +222,7 @@ `value` */ function resolve$1(object) { - /*jshint validthis:true */ + /* jshint validthis:true */ var Constructor = this; if ( @@ -722,7 +722,7 @@ promise to settle. */ function race(entries) { - /*jshint validthis:true */ + /* jshint validthis:true */ var Constructor = this; if (!isArray(entries)) { @@ -774,7 +774,7 @@ @return {Promise} a promise rejected with the given `reason`. */ function reject$1(reason) { - /*jshint validthis:true */ + /* jshint validthis:true */ var Constructor = this; var promise = new Constructor(noop); reject(promise, reason); diff --git a/packages/browser/test/integration/suites/loader.js b/packages/browser/test/integration/suites/loader.js index 0bac4e9d9590..3099417ae3de 100644 --- a/packages/browser/test/integration/suites/loader.js +++ b/packages/browser/test/integration/suites/loader.js @@ -45,7 +45,7 @@ if (IS_LOADER) { setTimeout(function() { Sentry.captureMessage("test"); }); - undefinedMethod(); //trigger error + undefinedMethod(); // trigger error }).then(function(summary) { assert.ok(summary.events[0].breadcrumbs); assert.lengthOf(summary.events[0].breadcrumbs, 1); diff --git a/packages/core/.eslintrc.js b/packages/core/.eslintrc.js new file mode 100644 index 000000000000..06e1cc905a45 --- /dev/null +++ b/packages/core/.eslintrc.js @@ -0,0 +1,26 @@ +module.exports = { + root: true, + env: { + es6: true, + }, + parserOptions: { + ecmaVersion: 2018, + }, + extends: ['../../.eslintrc.js'], + ignorePatterns: ['build/**/*', 'dist/**/*', 'esm/**/*', 'examples/**/*', 'scripts/**/*'], + overrides: [ + { + files: ['*.ts', '*.tsx', '*.d.ts'], + parserOptions: { + project: './tsconfig.json', + }, + }, + { + files: ['test/**/*'], + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + }, + }, + ], +}; diff --git a/packages/core/package.json b/packages/core/package.json index 9e7b65b4b9ce..28b4c5b3e431 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -28,7 +28,6 @@ "prettier": "^1.17.0", "prettier-check": "^2.0.0", "rimraf": "^2.6.3", - "tslint": "5.16.0", "typescript": "3.4.5" }, "scripts": { @@ -40,13 +39,13 @@ "build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput", "clean": "rimraf dist coverage", "link:yarn": "yarn link", - "lint": "run-s lint:prettier lint:tslint", + "lint": "run-s lint:prettier lint:eslint", "lint:prettier": "prettier-check \"{src,test}/**/*.ts\"", - "lint:tslint": "tslint -t stylish -p .", - "lint:tslint:json": "tslint --format json -p . | tee lint-results.json", - "fix": "run-s fix:tslint fix:prettier", + "lint:eslint": "eslint . --format stylish", + "lint:eslint:json": "eslint . --format json | tee lint-results.json", + "fix": "run-s fix:eslint fix:prettier", "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"", - "fix:tslint": "tslint --fix -t stylish -p .", + "fix:eslint": "lint:eslint --fix", "test": "jest", "test:watch": "jest --watch" }, diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index 37061881f7a1..ebef51f1e587 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -30,18 +30,6 @@ export class API { return this._getIngestEndpoint('store'); } - /** Returns the envelope endpoint URL. */ - private _getEnvelopeEndpoint(): string { - return this._getIngestEndpoint('envelope'); - } - - /** Returns the ingest API endpoint for target. */ - private _getIngestEndpoint(target: 'store' | 'envelope'): string { - const base = this.getBaseApiEndpoint(); - const dsn = this._dsnObject; - return `${base}${dsn.projectId}/${target}/`; - } - /** * Returns the store endpoint URL with auth in the query string. * @@ -60,18 +48,6 @@ export class API { return `${this._getEnvelopeEndpoint()}?${this._encodedAuth()}`; } - /** Returns a URL-encoded string with auth config suitable for a query string. */ - private _encodedAuth(): string { - const dsn = this._dsnObject; - const auth = { - // We send only the minimum set of required information. See - // https://github.com/getsentry/sentry-javascript/issues/2572. - sentry_key: dsn.user, - sentry_version: SENTRY_API_VERSION, - }; - return urlEncode(auth); - } - /** Returns only the path component for the store endpoint. */ public getStoreEndpointPath(): string { const dsn = this._dsnObject; @@ -99,6 +75,7 @@ export class API { /** Returns the url to the report dialog endpoint. */ public getReportDialogEndpoint( dialogOptions: { + // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; user?: { name?: string; email?: string }; } = {}, @@ -129,4 +106,28 @@ export class API { return endpoint; } + + /** Returns the envelope endpoint URL. */ + private _getEnvelopeEndpoint(): string { + return this._getIngestEndpoint('envelope'); + } + + /** Returns the ingest API endpoint for target. */ + private _getIngestEndpoint(target: 'store' | 'envelope'): string { + const base = this.getBaseApiEndpoint(); + const dsn = this._dsnObject; + return `${base}${dsn.projectId}/${target}/`; + } + + /** Returns a URL-encoded string with auth config suitable for a query string. */ + private _encodedAuth(): string { + const dsn = this._dsnObject; + const auth = { + // We send only the minimum set of required information. See + // https://github.com/getsentry/sentry-javascript/issues/2572. + sentry_key: dsn.user, + sentry_version: SENTRY_API_VERSION, + }; + return urlEncode(auth); + } } diff --git a/packages/core/src/basebackend.ts b/packages/core/src/basebackend.ts index ddbb7d039581..ca6081bb9be0 100644 --- a/packages/core/src/basebackend.ts +++ b/packages/core/src/basebackend.ts @@ -25,6 +25,7 @@ import { NoopTransport } from './transports/noop'; */ export interface Backend { /** Creates a {@link Event} from an exception. */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any eventFromException(exception: any, hint?: EventHint): PromiseLike; /** Creates a {@link Event} from a plain message. */ @@ -68,16 +69,10 @@ export abstract class BaseBackend implements Backend { this._transport = this._setupTransport(); } - /** - * Sets up the transport so it can be used later to send requests. - */ - protected _setupTransport(): Transport { - return new NoopTransport(); - } - /** * @inheritDoc */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types public eventFromException(_exception: any, _hint?: EventHint): PromiseLike { throw new SentryError('Backend has to implement `eventFromException` method'); } @@ -104,4 +99,11 @@ export abstract class BaseBackend implements Backend { public getTransport(): Transport { return this._transport; } + + /** + * Sets up the transport so it can be used later to send requests. + */ + protected _setupTransport(): Transport { + return new NoopTransport(); + } } diff --git a/packages/core/src/baseclient.ts b/packages/core/src/baseclient.ts index 9dd23ec7213c..e37878f12c6c 100644 --- a/packages/core/src/baseclient.ts +++ b/packages/core/src/baseclient.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-lines */ import { Scope } from '@sentry/hub'; import { Client, Event, EventHint, Integration, IntegrationClass, Options, Severity } from '@sentry/types'; import { @@ -85,6 +86,7 @@ export abstract class BaseClient implement /** * @inheritDoc */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types public captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined { let eventId: string | undefined = hint && hint.event_id; this._processing = true; @@ -276,7 +278,6 @@ export abstract class BaseClient implement } return result.then(evt => { - // tslint:disable-next-line:strict-type-predicates if (typeof normalizeDepth === 'number' && normalizeDepth > 0) { return this._normalizeEvent(evt, normalizeDepth); } @@ -299,7 +300,6 @@ export abstract class BaseClient implement return null; } - // tslint:disable:no-unsafe-any const normalized = { ...event, ...(event.breadcrumbs && { @@ -403,6 +403,7 @@ export abstract class BaseClient implement * @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send. */ protected _processEvent(event: Event, hint?: EventHint, scope?: Scope): PromiseLike { + // eslint-disable-next-line @typescript-eslint/unbound-method const { beforeSend, sampleRate } = this.getOptions(); if (!this._isEnabled()) { @@ -427,7 +428,8 @@ export abstract class BaseClient implement let finalEvent: Event | null = prepared; - const isInternalException = hint && hint.data && (hint.data as { [key: string]: any }).__sentry__ === true; + const isInternalException = + hint && hint.data && (hint.data as { [key: string]: unknown }).__sentry__ === true; // We skip beforeSend in case of transactions if (isInternalException || !beforeSend || isTransaction) { this._sendEvent(finalEvent); @@ -436,7 +438,6 @@ export abstract class BaseClient implement } const beforeSendResult = beforeSend(prepared, hint); - // tslint:disable-next-line:strict-type-predicates if (typeof beforeSendResult === 'undefined') { logger.error('`beforeSend` method has to return `null` or a valid event.'); } else if (isThenable(beforeSendResult)) { diff --git a/packages/core/src/integrations/functiontostring.ts b/packages/core/src/integrations/functiontostring.ts index db2a53408d21..96ced9c46130 100644 --- a/packages/core/src/integrations/functiontostring.ts +++ b/packages/core/src/integrations/functiontostring.ts @@ -7,22 +7,23 @@ export class FunctionToString implements Integration { /** * @inheritDoc */ - public name: string = FunctionToString.id; + public static id: string = 'FunctionToString'; /** * @inheritDoc */ - public static id: string = 'FunctionToString'; + public name: string = FunctionToString.id; /** * @inheritDoc */ public setupOnce(): void { + // eslint-disable-next-line @typescript-eslint/unbound-method originalFunctionToString = Function.prototype.toString; + // eslint-disable-next-line @typescript-eslint/no-explicit-any Function.prototype.toString = function(this: WrappedFunction, ...args: any[]): string { const context = this.__sentry_original__ || this; - // tslint:disable-next-line:no-unsafe-any return originalFunctionToString.apply(context, args); }; } diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index 5d868ebc50d6..76922e49e8d5 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -24,11 +24,12 @@ export class InboundFilters implements Integration { /** * @inheritDoc */ - public name: string = InboundFilters.id; + public static id: string = 'InboundFilters'; + /** * @inheritDoc */ - public static id: string = 'InboundFilters'; + public name: string = InboundFilters.id; public constructor(private readonly _options: Partial = {}) {} @@ -139,7 +140,6 @@ export class InboundFilters implements Integration { /** JSDoc */ private _mergeOptions(clientOptions: Partial = {}): Partial { - // tslint:disable:deprecation return { allowUrls: [ ...(this._options.whitelistUrls || []), diff --git a/packages/core/test/lib/api.test.ts b/packages/core/test/lib/api.test.ts index b83b61b1cfbf..f25ae992abff 100644 --- a/packages/core/test/lib/api.test.ts +++ b/packages/core/test/lib/api.test.ts @@ -16,13 +16,11 @@ describe('API', () => { }); test('getRequestHeaders', () => { - // tslint:disable-next-line:deprecation expect(new API(dsnPublic).getRequestHeaders('a', '1.0')).toMatchObject({ 'Content-Type': 'application/json', 'X-Sentry-Auth': expect.stringMatching(/^Sentry sentry_version=\d, sentry_client=a\/1\.0, sentry_key=abc$/), }); - // tslint:disable-next-line:deprecation expect(new API(legacyDsn).getRequestHeaders('a', '1.0')).toMatchObject({ 'Content-Type': 'application/json', 'X-Sentry-Auth': expect.stringMatching( diff --git a/packages/core/test/lib/base.test.ts b/packages/core/test/lib/base.test.ts index 10c99f37a230..cfab857f25d2 100644 --- a/packages/core/test/lib/base.test.ts +++ b/packages/core/test/lib/base.test.ts @@ -8,6 +8,7 @@ import { TestIntegration } from '../mocks/integration'; import { FakeTransport } from '../mocks/transport'; const PUBLIC_DSN = 'https://username@domain/123'; +// eslint-disable-next-line no-var declare var global: any; jest.mock('@sentry/utils', () => { @@ -18,7 +19,7 @@ jest.mock('@sentry/utils', () => { uuid4(): string { return '42'; }, - getGlobalObject(): object { + getGlobalObject(): any { return { console: { log(): void { diff --git a/packages/core/test/lib/integration.test.ts b/packages/core/test/lib/integration.test.ts index 03c777dd3dc9..606c09ecb01f 100644 --- a/packages/core/test/lib/integration.test.ts +++ b/packages/core/test/lib/integration.test.ts @@ -1,14 +1,15 @@ -// tslint:disable:deprecation import { Integration } from '@sentry/types'; import { getIntegrationsToSetup } from '../../src/integration'; /** JSDoc */ class MockIntegration implements Integration { + public name: string; + public constructor(name: string) { this.name = name; } - public name: string; + public setupOnce(): void { // noop } diff --git a/packages/core/test/lib/sdk.test.ts b/packages/core/test/lib/sdk.test.ts index f18e904a54b0..3ab908ec25b1 100644 --- a/packages/core/test/lib/sdk.test.ts +++ b/packages/core/test/lib/sdk.test.ts @@ -1,23 +1,24 @@ -import { Integration } from '@sentry/types'; +import { Integration, Client } from '@sentry/types'; import { installedIntegrations } from '../../src/integration'; import { initAndBind } from '../../src/sdk'; import { TestClient } from '../mocks/client'; +// eslint-disable-next-line no-var declare var global: any; const PUBLIC_DSN = 'https://username@domain/123'; jest.mock('@sentry/hub', () => ({ getCurrentHub(): { - bindClient(client: any): boolean; + bindClient(client: Client): boolean; getClient(): boolean; } { return { getClient(): boolean { return false; }, - bindClient(client: any): boolean { + bindClient(client: Client): boolean { client.setupIntegrations(); return true; }, @@ -26,11 +27,11 @@ jest.mock('@sentry/hub', () => ({ })); class MockIntegration implements Integration { + public name: string; + public setupOnce: () => void = jest.fn(); public constructor(name: string) { this.name = name; } - public name: string; - public setupOnce: () => void = jest.fn(); } describe('SDK', () => { diff --git a/packages/core/test/mocks/backend.ts b/packages/core/test/mocks/backend.ts index ed079bfae607..a719b55c0fd3 100644 --- a/packages/core/test/mocks/backend.ts +++ b/packages/core/test/mocks/backend.ts @@ -20,23 +20,7 @@ export class TestBackend extends BaseBackend { TestBackend.instance = this; } - protected _setupTransport(): Transport { - if (!this._options.dsn) { - // We return the noop transport here in case there is no Dsn. - return super._setupTransport(); - } - - const transportOptions = this._options.transportOptions - ? this._options.transportOptions - : { dsn: this._options.dsn }; - - if (this._options.transport) { - return new this._options.transport(transportOptions); - } - - return super._setupTransport(); - } - + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types public eventFromException(exception: any): PromiseLike { return SyncPromise.resolve({ exception: { @@ -60,7 +44,23 @@ export class TestBackend extends BaseBackend { super.sendEvent(event); return; } - // tslint:disable-next-line TestBackend.sendEventCalled && TestBackend.sendEventCalled(event); } + + protected _setupTransport(): Transport { + if (!this._options.dsn) { + // We return the noop transport here in case there is no Dsn. + return super._setupTransport(); + } + + const transportOptions = this._options.transportOptions + ? this._options.transportOptions + : { dsn: this._options.dsn }; + + if (this._options.transport) { + return new this._options.transport(transportOptions); + } + + return super._setupTransport(); + } } diff --git a/packages/core/test/mocks/integration.ts b/packages/core/test/mocks/integration.ts index 7e03da10281b..465fac64576a 100644 --- a/packages/core/test/mocks/integration.ts +++ b/packages/core/test/mocks/integration.ts @@ -3,9 +3,10 @@ import { configureScope } from '@sentry/minimal'; import { Event, Integration } from '@sentry/types'; export class TestIntegration implements Integration { - public name: string = 'TestIntegration'; public static id: string = 'TestIntegration'; + public name: string = 'TestIntegration'; + public setupOnce(): void { configureScope(scope => { scope.addEventProcessor((event: Event) => { @@ -13,11 +14,7 @@ export class TestIntegration implements Integration { return event; } - if (true) { - return null; - } - - // return event; + return null; }); }); } diff --git a/packages/core/test/mocks/transport.ts b/packages/core/test/mocks/transport.ts index fecebec88fd2..e437427fd357 100644 --- a/packages/core/test/mocks/transport.ts +++ b/packages/core/test/mocks/transport.ts @@ -6,13 +6,13 @@ async function sleep(delay: number): Promise { } export class FakeTransport implements Transport { - /** A simple buffer holding all requests. */ - protected readonly _buffer: PromiseBuffer = new PromiseBuffer(9999); - public sendCalled: number = 0; public sentCount: number = 0; public delay: number = 2000; + /** A simple buffer holding all requests. */ + protected readonly _buffer: PromiseBuffer = new PromiseBuffer(9999); + public sendEvent(_event: Event): PromiseLike { this.sendCalled += 1; return this._buffer.add( diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 165bfebc2d23..55b38e135ae2 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "./tsconfig.build.json", - "include": ["src/**/*.ts", "test/**/*.ts", "../integrations/test/dedupe.test.ts"], + "include": ["src/**/*.ts", "test/**/*.ts"], "exclude": ["dist"], "compilerOptions": { "rootDir": ".", diff --git a/packages/core/tslint.json b/packages/core/tslint.json deleted file mode 100644 index 3016a27a85cc..000000000000 --- a/packages/core/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "@sentry/typescript/tslint" -} diff --git a/packages/hub/.eslintrc.js b/packages/hub/.eslintrc.js new file mode 100644 index 000000000000..06e1cc905a45 --- /dev/null +++ b/packages/hub/.eslintrc.js @@ -0,0 +1,26 @@ +module.exports = { + root: true, + env: { + es6: true, + }, + parserOptions: { + ecmaVersion: 2018, + }, + extends: ['../../.eslintrc.js'], + ignorePatterns: ['build/**/*', 'dist/**/*', 'esm/**/*', 'examples/**/*', 'scripts/**/*'], + overrides: [ + { + files: ['*.ts', '*.tsx', '*.d.ts'], + parserOptions: { + project: './tsconfig.json', + }, + }, + { + files: ['test/**/*'], + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + }, + }, + ], +}; diff --git a/packages/hub/package.json b/packages/hub/package.json index 546c2651c3e3..593f37e07728 100644 --- a/packages/hub/package.json +++ b/packages/hub/package.json @@ -26,7 +26,6 @@ "prettier": "^1.17.0", "prettier-check": "^2.0.0", "rimraf": "^2.6.3", - "tslint": "5.16.0", "typescript": "3.4.5" }, "scripts": { @@ -38,13 +37,13 @@ "build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput", "clean": "rimraf dist coverage", "link:yarn": "yarn link", - "lint": "run-s lint:prettier lint:tslint", + "lint": "run-s lint:prettier lint:eslint", "lint:prettier": "prettier-check \"{src,test}/**/*.ts\"", - "lint:tslint": "tslint -t stylish -p .", - "lint:tslint:json": "tslint --format json -p . | tee lint-results.json", - "fix": "run-s fix:tslint fix:prettier", + "lint:eslint": "eslint . --format stylish", + "lint:eslint:json": "eslint . --format json | tee lint-results.json", + "fix": "run-s fix:eslint fix:prettier", "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"", - "fix:tslint": "tslint --fix -t stylish -p .", + "fix:eslint": "lint:eslint --fix", "test": "jest", "test:watch": "jest --watch" }, diff --git a/packages/hub/src/hub.ts b/packages/hub/src/hub.ts index e84f19f1e2a9..43dc3ad754dd 100644 --- a/packages/hub/src/hub.ts +++ b/packages/hub/src/hub.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-lines */ import { Breadcrumb, BreadcrumbHint, @@ -66,19 +67,6 @@ export class Hub implements HubInterface { this.bindClient(client); } - /** - * Internal helper function to call a method on the top client if it exists. - * - * @param method The method to call on the client. - * @param args Arguments to pass to the client function. - */ - private _invokeClient(method: M, ...args: any[]): void { - const top = this.getStackTop(); - if (top && top.client && top.client[method]) { - (top.client as any)[method](...args, top.scope); - } - } - /** * @inheritDoc */ @@ -156,6 +144,7 @@ export class Hub implements HubInterface { /** * @inheritDoc */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types public captureException(exception: any, hint?: EventHint): string { const eventId = (this._lastEventId = uuid4()); let finalHint = hint; @@ -244,6 +233,7 @@ export class Hub implements HubInterface { return; } + // eslint-disable-next-line @typescript-eslint/unbound-method const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } = (top.client.getOptions && top.client.getOptions()) || {}; @@ -322,6 +312,7 @@ export class Hub implements HubInterface { /** * @inheritDoc */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any public setContext(name: string, context: { [key: string]: any } | null): void { const top = this.getStackTop(); if (!top.scope) { @@ -389,14 +380,29 @@ export class Hub implements HubInterface { return this._callExtensionMethod<{ [key: string]: string }>('traceHeaders'); } + /** + * Internal helper function to call a method on the top client if it exists. + * + * @param method The method to call on the client. + * @param args Arguments to pass to the client function. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + private _invokeClient(method: M, ...args: any[]): void { + const top = this.getStackTop(); + if (top && top.client && top.client[method]) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (top.client as any)[method](...args, top.scope); + } + } + /** * Calls global extension method and binding current instance to the function call */ - // @ts-ignore + // @ts-ignore Function lacks ending return statement and return type does not include 'undefined'. ts(2366) + // eslint-disable-next-line @typescript-eslint/no-explicit-any private _callExtensionMethod(method: string, ...args: any[]): T { const carrier = getMainCarrier(); const sentry = carrier.__SENTRY__; - // tslint:disable-next-line: strict-type-predicates if (sentry && sentry.extensions && typeof sentry.extensions[method] === 'function') { return sentry.extensions[method].apply(this, args); } @@ -459,10 +465,10 @@ function getHubFromActiveDomain(registry: Carrier): Hub { const property = 'domain'; const carrier = getMainCarrier(); const sentry = carrier.__SENTRY__; - // tslint:disable-next-line: strict-type-predicates if (!sentry || !sentry.extensions || !sentry.extensions[property]) { return getHubFromCarrier(registry); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any const domain = sentry.extensions[property] as any; const activeDomain = domain.active; diff --git a/packages/hub/src/interfaces.ts b/packages/hub/src/interfaces.ts index 529389aaf915..c1585bbe1916 100644 --- a/packages/hub/src/interfaces.ts +++ b/packages/hub/src/interfaces.ts @@ -22,6 +22,7 @@ export interface Carrier { /** * These are extension methods for the hub, the current instance of the hub will be bound to it */ + // eslint-disable-next-line @typescript-eslint/ban-types extensions?: { [key: string]: Function }; }; } diff --git a/packages/hub/src/scope.ts b/packages/hub/src/scope.ts index f6298fa56dfd..82d470a265db 100644 --- a/packages/hub/src/scope.ts +++ b/packages/hub/src/scope.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-lines */ import { Breadcrumb, CaptureContext, @@ -39,9 +40,11 @@ export class Scope implements ScopeInterface { protected _tags: { [key: string]: string } = {}; /** Extra */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any protected _extra: { [key: string]: any } = {}; /** Contexts */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any protected _contexts: { [key: string]: any } = {}; /** Fingerprint */ @@ -56,6 +59,27 @@ export class Scope implements ScopeInterface { /** Span */ protected _span?: Span; + /** + * Inherit values from the parent scope. + * @param scope to clone. + */ + public static clone(scope?: Scope): Scope { + const newScope = new Scope(); + if (scope) { + newScope._breadcrumbs = [...scope._breadcrumbs]; + newScope._tags = { ...scope._tags }; + newScope._extra = { ...scope._extra }; + newScope._contexts = { ...scope._contexts }; + newScope._user = scope._user; + newScope._level = scope._level; + newScope._span = scope._span; + newScope._transactionName = scope._transactionName; + newScope._fingerprint = scope._fingerprint; + newScope._eventProcessors = [...scope._eventProcessors]; + } + return newScope; + } + /** * Add internal on change listener. Used for sub SDKs that need to store the scope. * @hidden @@ -72,50 +96,6 @@ export class Scope implements ScopeInterface { return this; } - /** - * This will be called on every set call. - */ - protected _notifyScopeListeners(): void { - if (!this._notifyingListeners) { - this._notifyingListeners = true; - setTimeout(() => { - this._scopeListeners.forEach(callback => { - callback(this); - }); - this._notifyingListeners = false; - }); - } - } - - /** - * This will be called after {@link applyToEvent} is finished. - */ - protected _notifyEventProcessors( - processors: EventProcessor[], - event: Event | null, - hint?: EventHint, - index: number = 0, - ): PromiseLike { - return new SyncPromise((resolve, reject) => { - const processor = processors[index]; - // tslint:disable-next-line:strict-type-predicates - if (event === null || typeof processor !== 'function') { - resolve(event); - } else { - const result = processor({ ...event }, hint) as Event | null; - if (isThenable(result)) { - (result as PromiseLike) - .then(final => this._notifyEventProcessors(processors, final, hint, index + 1).then(resolve)) - .then(null, reject); - } else { - this._notifyEventProcessors(processors, result, hint, index + 1) - .then(resolve) - .then(null, reject); - } - } - }); - } - /** * @inheritDoc */ @@ -205,6 +185,7 @@ export class Scope implements ScopeInterface { /** * @inheritDoc */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any public setContext(key: string, context: { [key: string]: any } | null): this { this._contexts = { ...this._contexts, [key]: context }; this._notifyScopeListeners(); @@ -238,27 +219,6 @@ export class Scope implements ScopeInterface { return undefined; } - /** - * Inherit values from the parent scope. - * @param scope to clone. - */ - public static clone(scope?: Scope): Scope { - const newScope = new Scope(); - if (scope) { - newScope._breadcrumbs = [...scope._breadcrumbs]; - newScope._tags = { ...scope._tags }; - newScope._extra = { ...scope._extra }; - newScope._contexts = { ...scope._contexts }; - newScope._user = scope._user; - newScope._level = scope._level; - newScope._span = scope._span; - newScope._transactionName = scope._transactionName; - newScope._fingerprint = scope._fingerprint; - newScope._eventProcessors = [...scope._eventProcessors]; - } - return newScope; - } - /** * @inheritDoc */ @@ -286,7 +246,7 @@ export class Scope implements ScopeInterface { this._fingerprint = captureContext._fingerprint; } } else if (isPlainObject(captureContext)) { - // tslint:disable-next-line:no-parameter-reassignment + // eslint-disable-next-line no-param-reassign captureContext = captureContext as ScopeContext; this._tags = { ...this._tags, ...captureContext.tags }; this._extra = { ...this._extra, ...captureContext.extra }; @@ -348,29 +308,6 @@ export class Scope implements ScopeInterface { return this; } - /** - * Applies fingerprint from the scope to the event if there's one, - * uses message if there's one instead or get rid of empty fingerprint - */ - private _applyFingerprint(event: Event): void { - // Make sure it's an array first and we actually have something in place - event.fingerprint = event.fingerprint - ? Array.isArray(event.fingerprint) - ? event.fingerprint - : [event.fingerprint] - : []; - - // If we have something on the scope, then merge it with event - if (this._fingerprint) { - event.fingerprint = event.fingerprint.concat(this._fingerprint); - } - - // If we have no data at all, remove empty array default - if (event.fingerprint && !event.fingerprint.length) { - delete event.fingerprint; - } - } - /** * Applies the current context and fingerprint to the event. * Note that breadcrumbs will be added by the client. @@ -412,6 +349,72 @@ export class Scope implements ScopeInterface { return this._notifyEventProcessors([...getGlobalEventProcessors(), ...this._eventProcessors], event, hint); } + + /** + * This will be called after {@link applyToEvent} is finished. + */ + protected _notifyEventProcessors( + processors: EventProcessor[], + event: Event | null, + hint?: EventHint, + index: number = 0, + ): PromiseLike { + return new SyncPromise((resolve, reject) => { + const processor = processors[index]; + if (event === null || typeof processor !== 'function') { + resolve(event); + } else { + const result = processor({ ...event }, hint) as Event | null; + if (isThenable(result)) { + (result as PromiseLike) + .then(final => this._notifyEventProcessors(processors, final, hint, index + 1).then(resolve)) + .then(null, reject); + } else { + this._notifyEventProcessors(processors, result, hint, index + 1) + .then(resolve) + .then(null, reject); + } + } + }); + } + + /** + * This will be called on every set call. + */ + protected _notifyScopeListeners(): void { + if (!this._notifyingListeners) { + this._notifyingListeners = true; + setTimeout(() => { + this._scopeListeners.forEach(callback => { + callback(this); + }); + this._notifyingListeners = false; + }); + } + } + + /** + * Applies fingerprint from the scope to the event if there's one, + * uses message if there's one instead or get rid of empty fingerprint + */ + private _applyFingerprint(event: Event): void { + // Make sure it's an array first and we actually have something in place + event.fingerprint = event.fingerprint + ? Array.isArray(event.fingerprint) + ? event.fingerprint + : [event.fingerprint] + : []; + + // If we have something on the scope, then merge it with event + if (this._fingerprint) { + event.fingerprint = event.fingerprint.concat(this._fingerprint); + } + + // If we have no data at all, remove empty array default + if (event.fingerprint && !event.fingerprint.length) { + delete event.fingerprint; + } + } } /** diff --git a/packages/hub/test/global.test.ts b/packages/hub/test/global.test.ts index 069c992d1c2d..9265dc0200a2 100644 --- a/packages/hub/test/global.test.ts +++ b/packages/hub/test/global.test.ts @@ -23,8 +23,8 @@ describe('global', () => { test('hub extension methods receive correct hub instance', () => { const newestHub = new Hub(undefined, undefined, 999999); (global as any).__SENTRY__.hub = newestHub; - // tslint:disable-next-line: typedef const fn = jest.fn().mockImplementation(function(...args: []) { + // @ts-ignore typescript complains that this can be `any` expect(this).toBe(newestHub); expect(args).toEqual([1, 2, 3]); }); diff --git a/packages/hub/test/hub.test.ts b/packages/hub/test/hub.test.ts index 87bb10717cb4..f89c7041c3bd 100644 --- a/packages/hub/test/hub.test.ts +++ b/packages/hub/test/hub.test.ts @@ -13,7 +13,6 @@ describe('Hub', () => { test('call bindClient with provided client when constructing new instance', () => { const testClient: any = { setupIntegrations: jest.fn() }; const spy = jest.spyOn(Hub.prototype, 'bindClient'); - // tslint:disable-next-line:no-unused-expression new Hub(testClient); expect(spy).toHaveBeenCalledWith(testClient); }); @@ -30,7 +29,7 @@ describe('Hub', () => { test("don't invoke client sync with wrong func", () => { const hub = new Hub(clientFn); - // @ts-ignore + // @ts-ignore we want to able to call private method hub._invokeClient('funca', true); expect(clientFn).not.toHaveBeenCalled(); }); @@ -195,6 +194,7 @@ describe('Hub', () => { const hub = new Hub(); const spy = jest.spyOn(hub as any, '_invokeClient'); hub.captureException('a'); + // @ts-ignore Says mock object is type unknown expect(spy.mock.calls[0][2].event_id).toBeTruthy(); }); @@ -203,8 +203,11 @@ describe('Hub', () => { const spy = jest.spyOn(hub as any, '_invokeClient'); const ex = new Error('foo'); hub.captureException(ex); + // @ts-ignore Says mock object is type unknown expect(spy.mock.calls[0][2].originalException).toBe(ex); + // @ts-ignore Says mock object is type unknown expect(spy.mock.calls[0][2].syntheticException).toBeInstanceOf(Error); + // @ts-ignore Says mock object is type unknown expect(spy.mock.calls[0][2].syntheticException.message).toBe('Sentry syntheticException'); }); }); @@ -223,6 +226,7 @@ describe('Hub', () => { const hub = new Hub(); const spy = jest.spyOn(hub as any, '_invokeClient'); hub.captureMessage('a'); + // @ts-ignore Says mock object is type unknown expect(spy.mock.calls[0][3].event_id).toBeTruthy(); }); @@ -230,8 +234,11 @@ describe('Hub', () => { const hub = new Hub(); const spy = jest.spyOn(hub as any, '_invokeClient'); hub.captureMessage('foo'); + // @ts-ignore Says mock object is type unknown expect(spy.mock.calls[0][3].originalException).toBe('foo'); + // @ts-ignore Says mock object is type unknown expect(spy.mock.calls[0][3].syntheticException).toBeInstanceOf(Error); + // @ts-ignore Says mock object is type unknown expect(spy.mock.calls[0][3].syntheticException.message).toBe('foo'); }); }); @@ -256,6 +263,7 @@ describe('Hub', () => { const hub = new Hub(); const spy = jest.spyOn(hub as any, '_invokeClient'); hub.captureEvent(event); + // @ts-ignore Says mock object is type unknown expect(spy.mock.calls[0][2].event_id).toBeTruthy(); }); }); @@ -302,6 +310,7 @@ describe('Hub', () => { expect(appliedEvent!.breadcrumbs![1]).toHaveProperty('timestamp'); }) .then(null, e => { + // eslint-disable-next-line no-console console.error(e); }); }); diff --git a/packages/hub/test/scope.test.ts b/packages/hub/test/scope.test.ts index ecaffb29e485..f1c158a78df5 100644 --- a/packages/hub/test/scope.test.ts +++ b/packages/hub/test/scope.test.ts @@ -209,13 +209,13 @@ describe('Scope', () => { const scope = new Scope(); const event: Event = {}; - // @ts-ignore + // @ts-ignore we want to be able to assign string value event.fingerprint = 'foo'; await scope.applyToEvent(event).then(processedEvent => { expect(processedEvent!.fingerprint).toEqual(['foo']); }); - // @ts-ignore + // @ts-ignore we want to be able to assign string value event.fingerprint = 'bar'; await scope.applyToEvent(event).then(processedEvent => { expect(processedEvent!.fingerprint).toEqual(['bar']); @@ -337,7 +337,7 @@ describe('Scope', () => { }); test('given neither function, Scope or plain object, returns original scope', () => { - // @ts-ignore + // @ts-ignore we want to be able to update scope with string const updatedScope = scope.update('wat'); expect(updatedScope).toEqual(scope); }); @@ -361,7 +361,7 @@ describe('Scope', () => { }); test('given callback function, when it doesnt return instanceof Scope, ignore it and return original scope', () => { - const cb = jest.fn().mockImplementationOnce(v => 'wat'); + const cb = jest.fn().mockImplementationOnce(_v => 'wat'); const updatedScope = scope.update(cb); expect(cb).toHaveBeenCalledWith(scope); expect(updatedScope).toEqual(scope); diff --git a/packages/hub/test/tslint.json b/packages/hub/test/tslint.json deleted file mode 100644 index 5e75d30192eb..000000000000 --- a/packages/hub/test/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": ["../tslint.json"], - "rules": { - "no-non-null-assertion": false - } -} diff --git a/packages/hub/tslint.json b/packages/hub/tslint.json deleted file mode 100644 index c0d88b083053..000000000000 --- a/packages/hub/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "@sentry/typescript/tslint", - "rules": { - "no-unsafe-any": false - } -} diff --git a/packages/minimal/.eslintrc.js b/packages/minimal/.eslintrc.js new file mode 100644 index 000000000000..06e1cc905a45 --- /dev/null +++ b/packages/minimal/.eslintrc.js @@ -0,0 +1,26 @@ +module.exports = { + root: true, + env: { + es6: true, + }, + parserOptions: { + ecmaVersion: 2018, + }, + extends: ['../../.eslintrc.js'], + ignorePatterns: ['build/**/*', 'dist/**/*', 'esm/**/*', 'examples/**/*', 'scripts/**/*'], + overrides: [ + { + files: ['*.ts', '*.tsx', '*.d.ts'], + parserOptions: { + project: './tsconfig.json', + }, + }, + { + files: ['test/**/*'], + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + }, + }, + ], +}; diff --git a/packages/minimal/package.json b/packages/minimal/package.json index 727b70adde62..3a07c3aef6fd 100644 --- a/packages/minimal/package.json +++ b/packages/minimal/package.json @@ -26,7 +26,6 @@ "prettier": "^1.17.0", "prettier-check": "^2.0.0", "rimraf": "^2.6.3", - "tslint": "5.16.0", "typescript": "3.4.5" }, "scripts": { @@ -38,13 +37,13 @@ "build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput", "clean": "rimraf dist coverage", "link:yarn": "yarn link", - "lint": "run-s lint:prettier lint:tslint", + "lint": "run-s lint:prettier lint:eslint", "lint:prettier": "prettier-check \"{src,test}/**/*.ts\"", - "lint:tslint": "tslint -t stylish -p .", - "lint:tslint:json": "tslint --format json -p . | tee lint-results.json", - "fix": "run-s fix:tslint fix:prettier", + "lint:eslint": "eslint . --format stylish", + "lint:eslint:json": "eslint . --format json | tee lint-results.json", + "fix": "run-s fix:eslint fix:prettier", "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"", - "fix:tslint": "tslint --fix -t stylish -p .", + "fix:eslint": "lint:eslint --fix", "test": "jest", "test:watch": "jest --watch" }, diff --git a/packages/minimal/src/index.ts b/packages/minimal/src/index.ts index 5625cbd2e73d..fb744ef0d390 100644 --- a/packages/minimal/src/index.ts +++ b/packages/minimal/src/index.ts @@ -16,10 +16,11 @@ import { * @param method function to call on hub. * @param args to pass to function. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function callOnHub(method: string, ...args: any[]): T { const hub = getCurrentHub(); if (hub && hub[method as keyof Hub]) { - // tslint:disable-next-line:no-unsafe-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (hub[method as keyof Hub] as any)(...args); } throw new Error(`No hub defined or ${method} was not found on the hub, please open a bug report.`); @@ -31,6 +32,7 @@ function callOnHub(method: string, ...args: any[]): T { * @param exception An exception-like object. * @returns The generated eventId. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types export function captureException(exception: any, captureContext?: CaptureContext): string { let syntheticException: Error; try { @@ -107,6 +109,7 @@ export function addBreadcrumb(breadcrumb: Breadcrumb): void { * @param name of the context * @param context Any kind of data. This data will be normalized. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function setContext(name: string, context: { [key: string]: any } | null): void { callOnHub('setContext', name, context); } @@ -132,7 +135,6 @@ export function setTags(tags: { [key: string]: string }): void { * @param key String of extra * @param extra Any kind of data. This data will be normalized. */ - export function setExtra(key: string, extra: Extra): void { callOnHub('setExtra', key, extra); } @@ -182,6 +184,7 @@ export function withScope(callback: (scope: Scope) => void): void { * @param args Arguments to pass to the client/fontend. * @hidden */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function _callOnClient(method: string, ...args: any[]): void { callOnHub('_invokeClient', method, ...args); } diff --git a/packages/minimal/test/lib/minimal.test.ts b/packages/minimal/test/lib/minimal.test.ts index bcadc4ba93d3..9e25bb0a46df 100644 --- a/packages/minimal/test/lib/minimal.test.ts +++ b/packages/minimal/test/lib/minimal.test.ts @@ -17,6 +17,7 @@ import { } from '../../src'; import { init, TestClient, TestClient2 } from '../mocks/client'; +// eslint-disable-next-line no-var declare var global: any; describe('Minimal', () => { diff --git a/packages/minimal/test/mocks/client.ts b/packages/minimal/test/mocks/client.ts index 2e04f2645bca..813fd694c38a 100644 --- a/packages/minimal/test/mocks/client.ts +++ b/packages/minimal/test/mocks/client.ts @@ -3,7 +3,7 @@ import { getCurrentHub } from '@sentry/hub'; export class TestClient { public static instance?: TestClient; - public constructor(public options: object) { + public constructor(public options: Record) { TestClient.instance = this; } @@ -14,6 +14,6 @@ export class TestClient { export class TestClient2 {} -export function init(options: object): void { +export function init(options: Record): void { getCurrentHub().bindClient(new TestClient(options) as any); } diff --git a/packages/minimal/test/tslint.json b/packages/minimal/test/tslint.json deleted file mode 100644 index f2c15a212b8f..000000000000 --- a/packages/minimal/test/tslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": ["../tslint.json"], - "rules": { - "completed-docs": false, - "max-classes-per-file": false, - "no-non-null-assertion": false, - "no-implicit-dependencies": [true, "dev"], - "no-unused-expression": false, - "no-unsafe-any": false - } -} diff --git a/packages/minimal/tsconfig.json b/packages/minimal/tsconfig.json index 7f080cf686bc..55b38e135ae2 100644 --- a/packages/minimal/tsconfig.json +++ b/packages/minimal/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "./tsconfig.build.json", - "include": ["src/**/*.ts"], + "include": ["src/**/*.ts", "test/**/*.ts"], "exclude": ["dist"], "compilerOptions": { "rootDir": ".", diff --git a/packages/minimal/tslint.json b/packages/minimal/tslint.json deleted file mode 100644 index 3016a27a85cc..000000000000 --- a/packages/minimal/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "@sentry/typescript/tslint" -} diff --git a/packages/types/.eslintrc.js b/packages/types/.eslintrc.js new file mode 100644 index 000000000000..e0d7645dfc16 --- /dev/null +++ b/packages/types/.eslintrc.js @@ -0,0 +1,22 @@ +module.exports = { + root: true, + env: { + es6: true, + }, + parserOptions: { + ecmaVersion: 2018, + }, + extends: ['../../.eslintrc.js'], + ignorePatterns: ['build/**/*', 'dist/**/*', 'esm/**/*', 'examples/**/*', 'scripts/**/*'], + overrides: [ + { + files: ['*.ts', '*.tsx', '*.d.ts'], + parserOptions: { + project: './tsconfig.json', + }, + }, + ], + rules: { + '@typescript-eslint/no-explicit-any': 'off', + }, +}; diff --git a/packages/types/package.json b/packages/types/package.json index ab2ec34d2943..6868b9f1fab4 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -19,7 +19,6 @@ "npm-run-all": "^4.1.2", "prettier": "^1.17.0", "prettier-check": "^2.0.0", - "tslint": "5.16.0", "typescript": "3.4.5" }, "scripts": { @@ -30,13 +29,13 @@ "build:watch:es5": "tsc -p tsconfig.build.json -w --preserveWatchOutput", "build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput", "link:yarn": "yarn link", - "lint": "run-s lint:prettier lint:tslint", + "lint": "run-s lint:prettier lint:eslint", "lint:prettier": "prettier-check \"{src,test}/**/*.ts\"", - "lint:tslint": "tslint -t stylish -p .", - "lint:tslint:json": "tslint --format json -p . | tee lint-results.json", - "fix": "run-s fix:tslint fix:prettier", + "lint:eslint": "eslint . --format stylish", + "lint:eslint:json": "eslint . --format json | tee lint-results.json", + "fix": "run-s fix:eslint fix:prettier", "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"", - "fix:tslint": "tslint --fix -t stylish -p ." + "fix:eslint": "eslint . --format stylish --fix" }, "sideEffects": false } diff --git a/packages/types/src/event.ts b/packages/types/src/event.ts index b96d10730288..fc1b4205611b 100644 --- a/packages/types/src/event.ts +++ b/packages/types/src/event.ts @@ -32,7 +32,7 @@ export interface Event { stacktrace?: Stacktrace; breadcrumbs?: Breadcrumb[]; contexts?: { - [key: string]: object; + [key: string]: Record; }; tags?: { [key: string]: string }; extra?: { [key: string]: any }; diff --git a/packages/types/src/integration.ts b/packages/types/src/integration.ts index 0621ec577ce9..251c135973fd 100644 --- a/packages/types/src/integration.ts +++ b/packages/types/src/integration.ts @@ -3,11 +3,12 @@ import { Hub } from './hub'; /** Integration Class Interface */ export interface IntegrationClass { - new (...args: any[]): T; /** * Property that holds the integration name */ id: string; + + new (...args: any[]): T; } /** Integration interface */ diff --git a/packages/types/src/options.ts b/packages/types/src/options.ts index f16574967bcf..13e1932a027e 100644 --- a/packages/types/src/options.ts +++ b/packages/types/src/options.ts @@ -105,6 +105,19 @@ export interface Options { */ normalizeDepth?: number; + /** + * Controls how many milliseconds to wait before shutting down. The default is + * SDK-specific but typically around 2 seconds. Setting this too low can cause + * problems for sending events from command line applications. Setting it too + * high can cause the application to block for users with network connectivity + * problems. + */ + shutdownTimeout?: number; + + _experiments?: { + [key: string]: any; + }; + /** * A callback invoked during event submission, allowing to optionally modify * the event before it is sent to Sentry. @@ -131,17 +144,4 @@ export interface Options { * @returns The breadcrumb that will be added | null. */ beforeBreadcrumb?(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Breadcrumb | null; - - /** - * Controls how many milliseconds to wait before shutting down. The default is - * SDK-specific but typically around 2 seconds. Setting this too low can cause - * problems for sending events from command line applications. Setting it too - * high can cause the application to block for users with network connectivity - * problems. - */ - shutdownTimeout?: number; - - _experiments?: { - [key: string]: any; - }; } diff --git a/packages/types/src/severity.ts b/packages/types/src/severity.ts index 5139899d1685..e9a4c940a80b 100644 --- a/packages/types/src/severity.ts +++ b/packages/types/src/severity.ts @@ -15,8 +15,8 @@ export enum Severity { /** JSDoc */ Critical = 'critical', } -// tslint:disable:completed-docs -// tslint:disable:no-unnecessary-qualifier no-namespace + +// eslint-disable-next-line @typescript-eslint/no-namespace export namespace Severity { /** * Converts a string-based level into a {@link Severity}. diff --git a/packages/types/src/status.ts b/packages/types/src/status.ts index ae7884726751..ef9b1c27bdbd 100644 --- a/packages/types/src/status.ts +++ b/packages/types/src/status.ts @@ -13,8 +13,8 @@ export enum Status { /** A server-side error ocurred during submission. */ Failed = 'failed', } -// tslint:disable:completed-docs -// tslint:disable:no-unnecessary-qualifier no-namespace + +// eslint-disable-next-line @typescript-eslint/no-namespace export namespace Status { /** * Converts a HTTP status code into a {@link Status}. diff --git a/packages/types/tslint.json b/packages/types/tslint.json deleted file mode 100644 index 3016a27a85cc..000000000000 --- a/packages/types/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "@sentry/typescript/tslint" -}