Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update typescript-eslint monorepo to v8 (major) #4388

Merged
merged 5 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@ module.exports = {
"@typescript-eslint/ban-ts-comment": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",

// The non-TypeScript rule produces false positives
"func-call-spacing": "off",
"@typescript-eslint/func-call-spacing": ["error"],
// We do this sometimes to brand interfaces
"@typescript-eslint/no-empty-object-type": "off",

"quotes": "off",
// We use a `logger` intermediary module
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@
"@babel/preset-typescript": "^7.12.7",
"@casualbot/jest-sonar-reporter": "2.2.7",
"@peculiar/webcrypto": "^1.4.5",
"@stylistic/eslint-plugin": "^2.9.0",
"@types/bs58": "^4.0.1",
"@types/content-type": "^1.1.5",
"@types/debug": "^4.1.7",
"@types/jest": "^29.0.0",
"@types/node": "18",
"@types/sdp-transform": "^2.4.5",
"@types/uuid": "10",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"babel-jest": "^29.0.0",
"babel-plugin-search-and-replace": "^1.1.1",
"debug": "^4.3.4",
Expand All @@ -100,7 +101,7 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^28.0.0",
"eslint-plugin-jsdoc": "^50.0.0",
"eslint-plugin-matrix-org": "^1.0.0",
"eslint-plugin-matrix-org": "^2.0.1",
"eslint-plugin-n": "^14.0.0",
"eslint-plugin-tsdoc": "^0.3.0",
"eslint-plugin-unicorn": "^56.0.0",
Expand Down
4 changes: 2 additions & 2 deletions spec/integ/crypto/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3499,7 +3499,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
return client;
}

function mkEncryptionEvent(content: Object) {
function mkEncryptionEvent(content: object) {
return mkEventCustom({
sender: persistentStoreClient.getSafeUserId(),
type: "m.room.encryption",
Expand All @@ -3512,7 +3512,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
*
* @param stateEvents - Additional state events for the test room
*/
function getSyncResponseWithState(stateEvents: Array<Object>) {
function getSyncResponseWithState(stateEvents: Array<object>) {
const roomResponse = {
state: {
events: [
Expand Down
1 change: 1 addition & 0 deletions spec/integ/crypto/verification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ beforeAll(async () => {

// load the rust library. This can take a few seconds on a slow GH worker.
beforeAll(async () => {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const RustSdkCryptoJs = await require("@matrix-org/matrix-sdk-crypto-wasm");
await RustSdkCryptoJs.initAsync();
}, 10000);
Expand Down
4 changes: 2 additions & 2 deletions spec/integ/rendezvous/MSC4108SignInWithQR.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ describe("MSC4108SignInWithQR", () => {

it("should abort if device doesn't come up by timeout", async () => {
jest.spyOn(global, "setTimeout").mockImplementation((fn) => {
(<Function>fn)();
fn();
// TODO: mock timers properly
return -1 as any;
});
Expand Down Expand Up @@ -320,7 +320,7 @@ describe("MSC4108SignInWithQR", () => {

it("should not send secrets if user cancels", async () => {
jest.spyOn(global, "setTimeout").mockImplementation((fn) => {
(<Function>fn)();
fn();
// TODO: mock timers properly
return -1 as any;
});
Expand Down
2 changes: 1 addition & 1 deletion spec/olm-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { logger } from "../src/logger";

// try to load the olm library.
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
globalThis.Olm = require("@matrix-org/olm");
logger.log("loaded libolm");
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions spec/test-utils/AccountDataAccumulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class AccountDataAccumulator {
* Will be updated when fetchMock intercepts calls to PUT `/_matrix/client/v3/user/:userId/account_data/`.
* Will be used by `sendSyncResponseWithUpdatedAccountData`
*/
public accountDataEvents: Map<String, any> = new Map();
public accountDataEvents: Map<string, any> = new Map();

/**
* Intercept requests to set a particular type of account data.
Expand Down Expand Up @@ -101,7 +101,7 @@ export class AccountDataAccumulator {
})),
},
});
} catch (err) {
} catch {
// Might fail with "Cannot queue more than one /sync response" if called too often.
// It's ok if it fails here, the sync response is cumulative and will contain
// the latest account data.
Expand Down
2 changes: 1 addition & 1 deletion spec/test-utils/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function mock<T>(constr: { new (...args: any[]): T }, name: string): T {
if (constr.prototype[key] instanceof Function) {
result[key] = jest.fn();
}
} catch (ex) {
} catch {
// Direct access to some non-function fields of DOM prototypes may
// cause exceptions.
// Overwriting will not work either in that case.
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/ToDeviceMessageQueue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { defer } from "../../src/utils";

describe("onResumedSync", () => {
let batch: IndexedToDeviceBatch | null;
let shouldFailSendToDevice: Boolean;
let shouldFailSendToDevice: boolean;
let onSendToDeviceFailure: () => void;
let onSendToDeviceSuccess: () => void;
let resumeSync: (newState: SyncState, oldState: SyncState) => void;
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ describe("Crypto", function () {
event.claimedEd25519Key = null;
try {
await bobClient.crypto!.decryptEvent(event);
} catch (e) {
} catch {
// we expect this to fail because we don't have the
// decryption keys yet
}
Expand Down
10 changes: 4 additions & 6 deletions spec/unit/crypto/cross-signing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ describe("Cross Signing", function () {
});
}

const error = new MatrixError(errorResponse);
error.httpStatus == 401;
throw error;
throw new MatrixError(errorResponse, 401);
};
alice.uploadKeySignatures = async () => ({ failures: {} });
alice.setAccountData = async () => ({});
Expand Down Expand Up @@ -827,7 +825,7 @@ describe("Cross Signing", function () {
});

it("should offer to upgrade device verifications to cross-signing", async function () {
let upgradeResolveFunc: Function;
let upgradeResolveFunc: () => void;

const { client: alice } = await makeTestClient(
{ userId: "@alice:example.com", deviceId: "Osborne2" },
Expand Down Expand Up @@ -866,7 +864,7 @@ describe("Cross Signing", function () {
// cross-signing key is signed by his Dynabook, which alice has
// verified, and ask if the device verification should be upgraded to a
// cross-signing verification
let upgradePromise = new Promise((resolve) => {
let upgradePromise = new Promise<void>((resolve) => {
upgradeResolveFunc = resolve;
});
await resetCrossSigningKeys(alice);
Expand All @@ -885,7 +883,7 @@ describe("Cross Signing", function () {
expect(bobTrust2.isCrossSigningVerified()).toBeFalsy();
expect(bobTrust2.isTofu()).toBeTruthy();

upgradePromise = new Promise((resolve) => {
upgradePromise = new Promise<void>((resolve) => {
upgradeResolveFunc = resolve;
});
alice.crypto!.deviceList.emit(CryptoEvent.UserCrossSigningUpdated, "@bob:example.com");
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/crypto/verification/sas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ describe("SAS verification", function () {
let bobSasEvent: ISasEvent | null;
let aliceVerifier: SAS;
let bobPromise: Promise<void>;
let clearTestClientTimeouts: Function;
let clearTestClientTimeouts: () => void;

beforeEach(async function () {
[[alice, bob], clearTestClientTimeouts] = await makeTestClients(
Expand Down
22 changes: 11 additions & 11 deletions spec/unit/matrix-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type HttpLookup = {
error?: object;
expectBody?: Record<string, any>;
expectQueryParams?: QueryDict;
thenCall?: Function;
thenCall?: () => void;
};

interface Options extends ICreateRoomOpts {
Expand Down Expand Up @@ -403,7 +403,7 @@ describe("MatrixClient", function () {
async function assertRequestsMade(
responses: {
prefix?: string;
error?: { httpStatus: Number; errcode: string };
error?: { httpStatus: number; errcode: string };
data?: { event_id: string };
}[],
expectRejects = false,
Expand Down Expand Up @@ -1515,7 +1515,7 @@ describe("MatrixClient", function () {
});

describe("emitted sync events", function () {
function syncChecker(expectedStates: [string, string | null][], done: Function) {
function syncChecker(expectedStates: [string, string | null][], done: () => void) {
return function syncListener(state: SyncState, old: SyncState | null) {
const expected = expectedStates.shift();
logger.log("'sync' curr=%s old=%s EXPECT=%s", state, old, expected);
Expand All @@ -1537,7 +1537,7 @@ describe("MatrixClient", function () {
it("should transition null -> PREPARED after the first /sync", async () => {
const expectedStates: [string, string | null][] = [];
expectedStates.push(["PREPARED", null]);
const didSyncPromise = new Promise((resolve) => {
const didSyncPromise = new Promise<void>((resolve) => {
client.on(ClientEvent.Sync, syncChecker(expectedStates, resolve));
});
await client.startClient();
Expand All @@ -1554,7 +1554,7 @@ describe("MatrixClient", function () {
error: { errcode: "NOPE_NOPE_NOPE" },
});
expectedStates.push(["ERROR", null]);
const didSyncPromise = new Promise((resolve) => {
const didSyncPromise = new Promise<void>((resolve) => {
client.on(ClientEvent.Sync, syncChecker(expectedStates, resolve));
});
await client.startClient();
Expand Down Expand Up @@ -1594,7 +1594,7 @@ describe("MatrixClient", function () {
expectedStates.push(["RECONNECTING", null]);
expectedStates.push(["ERROR", "RECONNECTING"]);
expectedStates.push(["CATCHUP", "ERROR"]);
const didSyncPromise = new Promise((resolve) => {
const didSyncPromise = new Promise<void>((resolve) => {
client.on(ClientEvent.Sync, syncChecker(expectedStates, resolve));
});
await client.startClient();
Expand All @@ -1605,7 +1605,7 @@ describe("MatrixClient", function () {
const expectedStates: [string, string | null][] = [];
expectedStates.push(["PREPARED", null]);
expectedStates.push(["SYNCING", "PREPARED"]);
const didSyncPromise = new Promise((resolve) => {
const didSyncPromise = new Promise<void>((resolve) => {
client.on(ClientEvent.Sync, syncChecker(expectedStates, resolve));
});
await client.startClient();
Expand All @@ -1630,7 +1630,7 @@ describe("MatrixClient", function () {
expectedStates.push(["SYNCING", "PREPARED"]);
expectedStates.push(["RECONNECTING", "SYNCING"]);
expectedStates.push(["ERROR", "RECONNECTING"]);
const didSyncPromise = new Promise((resolve) => {
const didSyncPromise = new Promise<void>((resolve) => {
client.on(ClientEvent.Sync, syncChecker(expectedStates, resolve));
});
await client.startClient();
Expand All @@ -1649,7 +1649,7 @@ describe("MatrixClient", function () {
expectedStates.push(["PREPARED", null]);
expectedStates.push(["SYNCING", "PREPARED"]);
expectedStates.push(["ERROR", "SYNCING"]);
const didSyncPromise = new Promise((resolve) => {
const didSyncPromise = new Promise<void>((resolve) => {
client.on(ClientEvent.Sync, syncChecker(expectedStates, resolve));
});
await client.startClient();
Expand All @@ -1664,7 +1664,7 @@ describe("MatrixClient", function () {
expectedStates.push(["PREPARED", null]);
expectedStates.push(["SYNCING", "PREPARED"]);
expectedStates.push(["SYNCING", "SYNCING"]);
const didSyncPromise = new Promise((resolve) => {
const didSyncPromise = new Promise<void>((resolve) => {
client.on(ClientEvent.Sync, syncChecker(expectedStates, resolve));
});
await client.startClient();
Expand Down Expand Up @@ -1695,7 +1695,7 @@ describe("MatrixClient", function () {
expectedStates.push(["RECONNECTING", "SYNCING"]);
expectedStates.push(["ERROR", "RECONNECTING"]);
expectedStates.push(["ERROR", "ERROR"]);
const didSyncPromise = new Promise((resolve) => {
const didSyncPromise = new Promise<void>((resolve) => {
client.on(ClientEvent.Sync, syncChecker(expectedStates, resolve));
});
await client.startClient();
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/rust-crypto/OutgoingRequestProcessor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe("OutgoingRequestProcessor", () => {
const outgoingRequest = new UploadSigningKeysRequest(JSON.stringify(testReq));

// also create a UIA callback
const authCallback: UIAuthCallback<Object> = async (makeRequest) => {
const authCallback: UIAuthCallback<object> = async (makeRequest) => {
return await makeRequest({ type: "test" });
};

Expand Down Expand Up @@ -458,7 +458,7 @@ describe("OutgoingRequestProcessor", () => {
throw new Error("Failed to fetch");
}
});
const authCallback: UIAuthCallback<Object> = async (makeRequest) => {
const authCallback: UIAuthCallback<object> = async (makeRequest) => {
return await makeRequest({ type: "test" });
};
const requestPromise = processor.makeOutgoingRequest(outgoingRequest, authCallback);
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/rust-crypto/secret-storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe("secret-storage", () => {
} else if (secretName == "secretE") {
return { aaaa: {}, bbbb: {} };
} else {
null;
return null;
}
}),
getDefaultKeyId: jest.fn().mockResolvedValue("aaaa"),
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/scheduler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jest.useFakeTimers();

describe("MatrixScheduler", function () {
let scheduler: MatrixScheduler<Record<string, boolean>>;
let retryFn: Function | null;
let retryFn: ((event: MatrixEvent | null, attempt: number, err: MatrixError) => number) | null;
let queueFn: ((event: MatrixEvent) => string | null) | null;
let deferred: IDeferred<Record<string, boolean>>;
const roomId = "!foo:bar";
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/webrtc/call.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ describe("Call", function () {
});

describe("Screen sharing", () => {
const waitNegotiateFunc = (resolve: Function): void => {
const waitNegotiateFunc = (resolve: () => void): void => {
mockSendEvent.mockImplementationOnce(() => {
// Note that the peer connection here is a dummy one and always returns
// dummy SDP, so there's not much point returning the content: the SDP will
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/webrtc/callFeed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe("CallFeed", () => {
it.each([
[CallState.Connected, true],
[CallState.Connecting, false],
])("should react to call state, when !isLocal()", (state: CallState, expected: Boolean) => {
])("should react to call state, when !isLocal()", (state: CallState, expected: boolean) => {
call.emit(CallEvent.State, state, CallState.InviteSent, call.typed());

expect(feed.connected).toBe(expected);
Expand Down
2 changes: 1 addition & 1 deletion src/browser-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ globalThis.__js_sdk_entrypoint = true;
let indexedDB: IDBFactory | undefined;
try {
indexedDB = globalThis.indexedDB;
} catch (e) {}
} catch {}

// if our browser (appears to) support indexeddb, use an indexeddb crypto store.
if (indexedDB) {
Expand Down
6 changes: 3 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
try {
indexedDB = global.indexedDB;
if (!indexedDB) return; // No indexedDB support
} catch (e) {
} catch {
// No indexedDB support
return;
}
Expand Down Expand Up @@ -3648,7 +3648,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
try {
decodeRecoveryKey(recoveryKey);
return true;
} catch (e) {
} catch {
return false;
}
}
Expand Down Expand Up @@ -7828,7 +7828,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
list: determineFeatureSupport(listStable, listUnstable),
fwdPagination: determineFeatureSupport(fwdPaginationStable, fwdPaginationUnstable),
};
} catch (e) {
} catch {
return {
threads: FeatureSupport.None,
list: FeatureSupport.None,
Expand Down
4 changes: 2 additions & 2 deletions src/crypto-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,8 +1080,8 @@ export interface OwnDeviceKeys {
}

export * from "./verification.ts";
export * from "./keybackup.ts";
export type * from "./keybackup.ts";
export * from "./recovery-key.ts";
export * from "./key-passphrase.ts";
export * from "./CryptoEvent.ts";
export * from "./CryptoEventHandlerMap.ts";
export type * from "./CryptoEventHandlerMap.ts";
Loading
Loading