Skip to content

Commit 2df21da

Browse files
committed
ref: Remove tslint-disable comments
1 parent 19c8d29 commit 2df21da

File tree

22 files changed

+54
-48
lines changed

22 files changed

+54
-48
lines changed

.eslintrc.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,21 @@ module.exports = {
1616
},
1717
{
1818
// Configuration for typescript files
19-
files: ['*.ts', '*.tsx'],
19+
files: ['*.ts', '*.tsx', '*.d.ts'],
2020
extends: ['plugin:@typescript-eslint/recommended', 'prettier/@typescript-eslint'],
2121
plugins: ['@typescript-eslint'],
2222
parser: '@typescript-eslint/parser',
23+
parserOptions: {
24+
project: './tsconfig.json',
25+
},
2326
rules: {
24-
// We want to prevent async await usage in our files to prevent uncessary bundle size.
27+
// We want to prevent async await usage in our files to prevent uncessary bundle size. Turned off in tests.
2528
'sentry-sdk/no-async-await': 'error',
2629

27-
// Make sure variables marked with _ are ignored (ex. _varName)
30+
// Unused variables should be removed unless they are marked with and underscore (ex. _varName).
2831
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
2932

30-
// Make sure that all ts-ignore comments are given a description
33+
// Make sure that all ts-ignore comments are given a description.
3134
'@typescript-eslint/ban-ts-comment': [
3235
'warn',
3336
{
@@ -37,7 +40,7 @@ module.exports = {
3740

3841
// Types usage should be explicit as possible, so we prevent usage of inferrable types.
3942
// This is especially important because we have a public API, so usage needs to be as
40-
// easy to understand as possible
43+
// easy to understand as possible.
4144
'@typescript-eslint/no-inferrable-types': 'off',
4245

4346
// Enforce type annotations to maintain consistency. This is especially important as
@@ -48,6 +51,10 @@ module.exports = {
4851
// Consistent ordering of fields, methods and constructors for classes should be enforced
4952
'@typescript-eslint/member-ordering': 'error',
5053

54+
// Enforce that unbound methods are called within an expected scope. As we frequently pass data between classes
55+
// in SDKs, we should make sure that we are correctly preserving class scope.
56+
'@typescript-eslint/unbound-method': 'error',
57+
5158
// Private and protected members of a class should be prefixed with a leading underscore
5259
'@typescript-eslint/naming-convention': [
5360
'error',
@@ -65,7 +72,8 @@ module.exports = {
6572
},
6673
],
6774

68-
// JSDOC comments are required for classes and methods
75+
// JSDOC comments are required for classes and methods. As we have a public facing codebase, documentation,
76+
// even if it may seems excessive at times, is important to emphasize. Turned off in tests.
6977
'jsdoc/require-jsdoc': [
7078
'error',
7179
{ require: { ClassDeclaration: true, MethodDefinition: true }, checkConstructors: false },
@@ -81,6 +89,7 @@ module.exports = {
8189
rules: {
8290
'sentry-sdk/no-async-await': 'off',
8391
'jsdoc/require-jsdoc': 'off',
92+
'max-lines': 'off',
8493
},
8594
},
8695
{
@@ -97,8 +106,19 @@ module.exports = {
97106
// We want to prevent usage of unary operators outside of for loops
98107
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
99108

100-
// disallow usage of console and alert
109+
// Disallow usage of console and alert
101110
'no-console': 'error',
102111
'no-alert': 'error',
112+
113+
// Prevent reassignment of function parameters, but still allow object properties to be
114+
// reassigned. We want to enforce immutability when possible, but we shouldn't sacrifice
115+
// too much efficiency
116+
'no-param-reassign': ['error', { props: false }],
117+
118+
// Prefer use of template expression over string literal concatenation
119+
'prefer-template': 'error',
120+
121+
// Limit maximum file size to reduce complexity. Turned off in tests.
122+
'max-lines': 'error',
103123
},
104124
};

packages/browser/.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ module.exports = {
1010
extends: ['../../.eslintrc.js'],
1111
ignorePatterns: ['build/**/*', 'dist/**/*', 'esm/**/*', 'examples/**/*', 'scripts/**/*', 'src/loader.js'],
1212
overrides: [
13+
{
14+
files: ['*.ts', '*.tsx', '*.d.ts'],
15+
parserOptions: {
16+
project: './tsconfig.json',
17+
},
18+
},
1319
{
1420
files: ['test/**/*'],
1521
rules: {
1622
'jsdoc/require-jsdoc': 'off',
1723
'no-console': 'off',
24+
'max-lines': 'off',
25+
'prefer-template': 'off',
1826
},
1927
},
2028
{

packages/browser/src/eventbuilder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export function eventFromUnknownInput(
7171
if (isErrorEvent(exception as ErrorEvent) && (exception as ErrorEvent).error) {
7272
// If it is an ErrorEvent with `error` property, extract it to get actual Error
7373
const errorEvent = exception as ErrorEvent;
74+
// eslint-disable-next-line no-param-reassign
7475
exception = errorEvent.error;
7576
event = eventFromStacktrace(computeStackTrace(exception as Error));
7677
return event;

packages/browser/src/helpers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export function wrap(
3838
before?: WrappedFunction,
3939
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4040
): any {
41-
// tslint:disable-next-line:strict-type-predicates
4241
if (typeof fn !== 'function') {
4342
return fn;
4443
}
@@ -65,9 +64,7 @@ export function wrap(
6564
const sentryWrapped: WrappedFunction = function(this: any): void {
6665
const args = Array.prototype.slice.call(arguments);
6766

68-
// tslint:disable:no-unsafe-any
6967
try {
70-
// tslint:disable-next-line:strict-type-predicates
7168
if (before && typeof before === 'function') {
7269
before.apply(this, arguments);
7370
}
@@ -87,7 +84,6 @@ export function wrap(
8784
// means the sentry.javascript SDK caught an error invoking your application code. This
8885
// is expected behavior and NOT indicative of a bug with sentry.javascript.
8986
return fn.apply(this, wrappedArguments);
90-
// tslint:enable:no-unsafe-any
9187
} catch (ex) {
9288
ignoreNextOnError();
9389

@@ -211,6 +207,7 @@ export function injectReportDialog(options: ReportDialogOptions = {}): void {
211207
script.src = new API(options.dsn).getReportDialogEndpoint(options);
212208

213209
if (options.onLoad) {
210+
// eslint-disable-next-line @typescript-eslint/unbound-method
214211
script.onload = options.onLoad;
215212
}
216213

packages/browser/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import * as Transports from './transports';
99
let windowIntegrations = {};
1010

1111
// This block is needed to add compatibility with the integrations packages when used with a CDN
12-
// tslint:disable: no-unsafe-any
1312
const _window = getGlobalObject<Window>();
1413
if (_window.Sentry && _window.Sentry.Integrations) {
1514
windowIntegrations = _window.Sentry.Integrations;
1615
}
17-
// tslint:enable: no-unsafe-any
1816

1917
const INTEGRATIONS = {
2018
...windowIntegrations,

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-lines */
12
import { getCurrentHub } from '@sentry/core';
23
import { Event, Integration, Severity } from '@sentry/types';
34
import {
@@ -291,11 +292,9 @@ export class Breadcrumbs implements Integration {
291292
// Use only the path component of the URL if the URL matches the current
292293
// document (almost all the time when using pushState)
293294
if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) {
294-
// tslint:disable-next-line:no-parameter-reassignment
295295
to = parsedTo.relative;
296296
}
297297
if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) {
298-
// tslint:disable-next-line:no-parameter-reassignment
299298
from = parsedFrom.relative;
300299
}
301300

packages/browser/src/integrations/trycatch.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ export class TryCatch implements Integration {
162162
options?: boolean | AddEventListenerOptions,
163163
): (eventName: string, fn: EventListenerObject, capture?: boolean, secure?: boolean) => void {
164164
try {
165-
// tslint:disable-next-line:no-unbound-method strict-type-predicates
166165
if (typeof fn.handleEvent === 'function') {
167166
fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
168167
mechanism: {

packages/browser/src/integrations/tslint.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/browser/src/parsers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export function exceptionFromStacktrace(stacktrace: TraceKitStackTrace): Excepti
2222
exception.stacktrace = { frames };
2323
}
2424

25-
// tslint:disable-next-line:strict-type-predicates
2625
if (exception.type === undefined && exception.value === '') {
2726
exception.value = 'Unrecoverable error caught';
2827
}

packages/browser/src/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,5 @@ export function close(timeout?: number): PromiseLike<boolean> {
164164
*/
165165
// eslint-disable-next-line @typescript-eslint/no-explicit-any
166166
export function wrap(fn: (...args: any) => any): any {
167-
return internalWrap(fn)(); // tslint:disable-line:no-unsafe-any
167+
return internalWrap(fn)();
168168
}

packages/browser/src/transports/base.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export abstract class BaseTransport implements Transport {
1717

1818
public constructor(public options: TransportOptions) {
1919
this._api = new API(this.options.dsn);
20-
// tslint:disable-next-line:deprecation
2120
this.url = this._api.getStoreEndpointWithUrlEncodedAuth();
2221
}
2322

packages/browser/test/integration/common/triggers.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function throwNonError() {
2323
}
2424

2525
function throwError(message) {
26+
// eslint-disable-next-line no-param-reassign
2627
message = message || "foo";
2728
try {
2829
throw new Error(message);
@@ -45,6 +46,7 @@ function throwSameConsecutiveErrors(message) {
4546
}
4647

4748
function captureMessage(message) {
49+
// eslint-disable-next-line no-param-reassign
4850
message = message || "message";
4951
Sentry.captureMessage(message);
5052
}

packages/browser/test/integration/polyfills/events.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
if (typeof window.CustomEvent === "function") return false;
8888

8989
function CustomEvent(event, params) {
90+
// eslint-disable-next-line no-param-reassign
9091
params = params || { bubbles: false, cancelable: false, detail: null };
9192
var evt = document.createEvent("CustomEvent");
9293
evt.initCustomEvent(

packages/browser/test/integration/polyfills/fetch.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
function normalizeName(name) {
6363
if (typeof name !== "string") {
64+
// eslint-disable-next-line no-param-reassign
6465
name = String(name);
6566
}
6667
if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
@@ -71,6 +72,7 @@
7172

7273
function normalizeValue(value) {
7374
if (typeof value !== "string") {
75+
// eslint-disable-next-line no-param-reassign
7476
value = String(value);
7577
}
7678
return value;
@@ -113,7 +115,9 @@
113115
}
114116

115117
Headers.prototype.append = function(name, value) {
118+
// eslint-disable-next-line no-param-reassign
116119
name = normalizeName(name);
120+
// eslint-disable-next-line no-param-reassign
117121
value = normalizeValue(value);
118122
var oldValue = this.map[name];
119123
this.map[name] = oldValue ? oldValue + ", " + value : value;
@@ -124,6 +128,7 @@
124128
};
125129

126130
Headers.prototype.get = function(name) {
131+
// eslint-disable-next-line no-param-reassign
127132
name = normalizeName(name);
128133
return this.has(name) ? this.map[name] : null;
129134
};
@@ -252,6 +257,7 @@
252257
) {
253258
this._bodyArrayBuffer = bufferClone(body);
254259
} else {
260+
// eslint-disable-next-line no-param-reassign
255261
this._bodyText = body = Object.prototype.toString.call(body);
256262
}
257263

@@ -338,6 +344,7 @@
338344
}
339345

340346
function Request(input, options) {
347+
// eslint-disable-next-line no-param-reassign
341348
options = options || {};
342349
var body = options.body;
343350

@@ -416,6 +423,7 @@
416423

417424
function Response(bodyInit, options) {
418425
if (!options) {
426+
// eslint-disable-next-line no-param-reassign
419427
options = {};
420428
}
421429

packages/browser/test/integration/suites/helpers.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ function evaluateInSandbox(sandbox, code) {
1111

1212
function runInSandbox(sandbox, options, code) {
1313
if (typeof options === "function") {
14+
// eslint-disable-next-line no-param-reassign
1415
code = options;
16+
// eslint-disable-next-line no-param-reassign
1517
options = {};
1618
}
1719

packages/browser/test/tslint.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/browser/test/unit/integrations/helpers.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ describe('internal wrap()', () => {
166166
expect(this).equal(context);
167167
};
168168

169-
// tslint:disable-next-line:no-unbound-method
169+
// eslint-disable-next-line @typescript-eslint/unbound-method
170170
const wrappedFn = wrap(context.fn);
171-
// tslint:disable-next-line:no-unbound-method
171+
// eslint-disable-next-line @typescript-eslint/unbound-method
172172
const wrappedEventFn = wrap(context.eventFn);
173173

174174
wrappedFn.call(context);

packages/browser/test/unit/tracekit/original.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// tslint:disable:prefer-template
2-
// tslint:disable:object-literal-sort-keys
3-
// tslint:disable:max-file-line-count
4-
51
import { expect } from 'chai';
62

73
import { computeStackTrace } from '../../../src/tracekit';

packages/browser/test/unit/tracekit/originalfixtures.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// tslint:disable:prefer-template
2-
// tslint:disable:object-literal-sort-keys
3-
41
export const OPERA_854 = {
52
name: 'foo',
63
message:

packages/browser/test/unit/transports/base.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('BaseTransport', () => {
1919

2020
it('has correct endpoint url', () => {
2121
const transport = new SimpleTransport({ dsn: testDsn });
22-
// tslint:disable-next-line:deprecation
2322
expect(transport.url).equal('https://sentry.io/api/42/store/?sentry_key=123&sentry_version=7');
2423
});
2524
});

packages/browser/test/unit/transports/fetch.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ describe('FetchTransport', () => {
2727
});
2828

2929
it('inherits composeEndpointUrl() implementation', () => {
30-
// tslint:disable-next-line:deprecation
3130
expect(transport.url).equal(transportUrl);
3231
});
3332

packages/browser/test/unit/transports/xhr.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ describe('XHRTransport', () => {
2828
});
2929

3030
it('inherits composeEndpointUrl() implementation', () => {
31-
// tslint:disable-next-line:deprecation
3231
expect(transport.url).equal(transportUrl);
3332
});
3433

0 commit comments

Comments
 (0)