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
}

0 commit comments

Comments
 (0)