Skip to content

Commit d65bc03

Browse files
committed
Turned on more linting rules + fixes
1 parent cdbd395 commit d65bc03

File tree

9 files changed

+15
-29
lines changed

9 files changed

+15
-29
lines changed

.eslintrc.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,11 @@ module.exports = {
3838
"example"
3939
],
4040
rules: {
41-
// TODO: Fix rule errors.
42-
"@typescript-eslint/explicit-module-boundary-types": "off",
43-
"@typescript-eslint/no-empty-function": "off",
44-
"@typescript-eslint/no-explicit-any": "off",
45-
"@typescript-eslint/no-for-in-array": "off",
4641
"@typescript-eslint/no-inferrable-types": "off",
47-
"@typescript-eslint/no-unused-vars": "off",
4842
"@typescript-eslint/no-unsafe-assignment": "off",
4943
"@typescript-eslint/no-unsafe-call": "off",
5044
"@typescript-eslint/no-unsafe-member-access": "off",
5145
"@typescript-eslint/no-unsafe-return": "off",
52-
"@typescript-eslint/no-var-requires": "off",
5346
"@typescript-eslint/restrict-plus-operands": "off",
54-
"@typescript-eslint/restrict-template-expressions": "off",
55-
"no-undef": "off",
56-
"no-var": "off"
5747
}
5848
};

packages/browser/src/plugins/BrowserGlobalHandlerPlugin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
PluginContext
55
} from "@exceptionless/core";
66

7-
declare let $: (document: Document) => { (): any; new(): any; ajaxError: { (document: (event: Event, xhr: { responseText: string; status: number; }, settings: { data: unknown; url: string; }, error: string) => void): void; new(): any; }; };
7+
declare let $: (document: Document) => { ajaxError: { (document: (event: Event, xhr: { responseText: string; status: number; }, settings: { data: unknown; url: string; }, error: string) => void): void; }; };
88

99
export class BrowserGlobalHandlerPlugin implements IEventPlugin {
1010
public priority: number = 100;
@@ -28,7 +28,7 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
2828
let error = event.reason;
2929
try {
3030
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
31-
const reason = (<any>event).detail?.reason;
31+
const reason = (<{ detail?: { reason: string} }>event).detail?.reason;
3232
if (reason) {
3333
error = reason;
3434
}
@@ -62,7 +62,7 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
6262
private getError(event: ErrorEvent): Error {
6363
const { error, message, filename, lineno, colno } = event;
6464
if (typeof error === "object") {
65-
return error;
65+
return error as Error;
6666
}
6767

6868
let name: string = "Error";
@@ -71,7 +71,7 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
7171
const errorNameRegex: RegExp = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Aggregate|Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
7272
const regexResult = errorNameRegex.exec(msg);
7373
if (regexResult) {
74-
const [_, errorName, errorMessage] = regexResult;
74+
const [, errorName, errorMessage] = regexResult;
7575
if (errorName) {
7676
name = errorName;
7777
}
@@ -83,7 +83,7 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
8383

8484
const ex = new Error(msg || "Script error.");
8585
ex.name = name;
86-
ex.stack = `at ${filename || ""}:${!isNaN(lineno) ? lineno : 0}${!isNaN(colno) ? ":" + colno : ""}`;
86+
ex.stack = `at ${filename || ""}:${!isNaN(lineno) ? lineno : 0}${!isNaN(colno) ? `:${colno}` : ""}`;
8787
return ex;
8888
}
8989
}

packages/core/src/plugins/default/EventExclusionPlugin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ export class EventExclusionPlugin implements IEventPlugin {
9595
const sortedKeys = Object.keys(configSettings).sort((a, b) =>
9696
b.length - a.length || a.localeCompare(b)
9797
);
98-
for (const index in sortedKeys) {
99-
const key: string = sortedKeys[index];
98+
for (const key of sortedKeys) {
10099
if (!startsWith(key.toLowerCase(), sourcePrefix)) {
101100
continue;
102101
}

packages/core/src/storage/InMemoryStorage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { IStorage } from "./IStorage.js";
33
export class InMemoryStorage implements IStorage {
44
private items = new Map<string, string>();
55

6-
constructor() { }
7-
86
public length(): Promise<number> {
97
return Promise.resolve(this.items.size);
108
}

packages/core/src/submission/DefaultSubmissionClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class DefaultSubmissionClient implements ISubmissionClient {
4848
}
4949

5050
public async submitHeartbeat(sessionIdOrUserId: string, closeSession: boolean): Promise<Response<void>> {
51-
const url = `${this.config.heartbeatServerUrl}/api/v2/events/session/heartbeat?id=${sessionIdOrUserId}&close=${closeSession}`;
51+
const url = `${this.config.heartbeatServerUrl}/api/v2/events/session/heartbeat?id=${sessionIdOrUserId}&close=${closeSession + ""}`;
5252
return await this.apiFetch<void>(url, {
5353
method: "GET",
5454
});

packages/core/test/Utils.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ describe("Utils", () => {
6161
});
6262

6363
test("circular reference", () => {
64-
const aFoo: any = { a: "foo" };
64+
const aFoo: { a: string, b?: unknown } = { a: "foo" };
6565
aFoo.b = aFoo;
6666

6767
expect(stringify(aFoo)).toBe("{\"a\":\"foo\"}");
6868
expect(stringify([{ one: aFoo, two: aFoo }])).toBe("[{\"one\":{\"a\":\"foo\"}}]");
6969
});
7070

7171
test.skip("deep circular reference", () => {
72-
const a: any = {};
73-
const b: any = {};
74-
const c: any = { d: "test" };
72+
const a: { b?: unknown } = {};
73+
const b: { c?: unknown } = {};
74+
const c: { a?: unknown, d: string } = { d: "test" };
7575

7676
a.b = b;
7777
b.c = c;
@@ -84,7 +84,7 @@ describe("Utils", () => {
8484
});
8585

8686
describe("should behave like JSON.stringify", () => {
87-
[new Date(), 1, true, null, undefined, () => { }, user].forEach((value) => {
87+
[new Date(), 1, true, null, undefined, () => { return undefined; }, user].forEach((value) => {
8888
test("for " + typeof (value), () => {
8989
expect(stringify(value)).toBe(JSON.stringify(value));
9090
});

packages/core/test/storage/StorageTestBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function describeStorage(
55
storageFactory: () => IStorage,
66
afterEachCallback?: () => void,
77
beforeEachCallback?: () => void
8-
) {
8+
): void {
99
describe(name, () => {
1010
if (beforeEachCallback) {
1111
beforeEach(beforeEachCallback);
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Response } from "../../src/submission/Response.js";
22
import {
3-
FetchOptions,
43
DefaultSubmissionClient
54
} from "../../src/submission/DefaultSubmissionClient.js";
65

76
export class TestSubmissionClient extends DefaultSubmissionClient {
8-
public apiFetch<T>(_url: string, _options: FetchOptions): Promise<Response<T>> {
7+
public apiFetch<T>(): Promise<Response<T>> {
98
throw new Error("Missing mock");
109
}
1110
}

packages/node/src/plugins/NodeGlobalHandlerPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class NodeGlobalHandlerPlugin implements IEventPlugin {
2222
void this._client?.submitUnhandledException(error, "uncaughtException");
2323
});
2424

25-
process.addListener("unhandledRejection", (reason: unknown | null | undefined, _: Promise<any>) => {
25+
process.addListener("unhandledRejection", (reason: unknown | null | undefined) => {
2626
void this._client?.submitUnhandledException(<Error>reason, "unhandledRejection");
2727
});
2828

0 commit comments

Comments
 (0)