Migrate to stylistic

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2024-10-16 16:43:07 +01:00
parent d8052e6a73
commit 6c6bf811a6
No known key found for this signature in database
GPG key ID: A2B008A5F49F5D0D
124 changed files with 239 additions and 196 deletions

View file

@ -35,6 +35,7 @@ beforeEach(() => {
//
// These are also require() calls to make sure they get called
// synchronously.
/* eslint-disable @typescript-eslint/no-require-imports */
require("./setup/setupManualMocks"); // must be first
require("./setup/setupLanguage");
require("./setup/setupConfig");

View file

@ -669,7 +669,7 @@ export function mkServerConfig(
// These methods make some use of some private methods on the AsyncStoreWithClient to simplify getting into a consistent
// ready state without needing to wire up a dispatcher and pretend to be a js-sdk client.
export const setupAsyncStoreWithClient = async <T extends Object = any>(
export const setupAsyncStoreWithClient = async <T extends object = any>(
store: AsyncStoreWithClient<T>,
client: MatrixClient,
) => {
@ -679,7 +679,7 @@ export const setupAsyncStoreWithClient = async <T extends Object = any>(
await store.onReady();
};
export const resetAsyncStoreWithClient = async <T extends Object = any>(store: AsyncStoreWithClient<T>) => {
export const resetAsyncStoreWithClient = async <T extends object = any>(store: AsyncStoreWithClient<T>) => {
// @ts-ignore protected access
await store.onNotReady();
};

View file

@ -86,7 +86,6 @@ describe("Terms", function () {
policy_the_first: POLICY_ONE,
},
});
mockClient.agreeToTerms;
const interactionCallback = jest.fn();
await startTermsFlow(mockClient, [IM_SERVICE_ONE], interactionCallback);

View file

@ -18,7 +18,7 @@ import dispatcher from "../../../../../src/dispatcher/dispatcher";
import { Action } from "../../../../../src/dispatcher/actions";
jest.mock("../../../../../src/stores/OwnBeaconStore", () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const EventEmitter = require("events");
class MockOwnBeaconStore extends EventEmitter {
public getLiveBeaconIdsWithLocationPublishError = jest.fn().mockReturnValue([]);

View file

@ -15,7 +15,6 @@ import { makePollStartEvent, mockIntlDateTimeFormat, unmockIntlDateTimeFormat }
describe("<PollListItem />", () => {
const event = makePollStartEvent("Question?", "@me:domain.org");
event.getContent().origin;
const defaultProps = { event, onClick: jest.fn() };
const getComponent = (props = {}) => render(<PollListItem {...defaultProps} {...props} />);

View file

@ -247,11 +247,11 @@ describe("MessageComposer", () => {
});
describe("UIStore interactions", () => {
let resizeCallback: Function;
let resizeCallback: (key: string, data: object) => void;
beforeEach(() => {
jest.spyOn(UIStore.instance, "on").mockImplementation(
(_event: string | symbol, listener: Function): any => {
(_event: string | symbol, listener: (key: string, data: object) => void): any => {
resizeCallback = listener;
},
);

View file

@ -564,7 +564,7 @@ describe("RoomHeader", () => {
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);
render(<RoomHeader room={room} />, getWrapper()).container;
render(<RoomHeader room={room} />, getWrapper());
expect(getByLabelText(document.body, _t("voip|get_call_link"))).toBeInTheDocument();
});

View file

@ -210,7 +210,6 @@ describe("RoomList", () => {
beforeEach(async () => {
cleanup();
const rooms: Room[] = [];
RoomListStore.instance;
testUtils.mkRoom(client, videoRoomPrivate, rooms);
testUtils.mkRoom(client, videoRoomPublic, rooms);
testUtils.mkRoom(client, videoRoomKnock, rooms);

View file

@ -100,7 +100,7 @@ describe("<RoomPreviewBar />", () => {
afterEach(() => {
const container = document.body.firstChild;
container && document.body.removeChild(container);
if (container) document.body.removeChild(container);
});
it("renders joining message", () => {

View file

@ -85,7 +85,7 @@ const drop = async (element: HTMLElement) => {
};
jest.mock("../../../../../src/stores/spaces/SpaceStore", () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const EventEmitter = require("events");
class MockSpaceStore extends EventEmitter {
invitedSpaces: SpaceKey[] = [];

View file

@ -21,7 +21,7 @@ import { StaticNotificationState } from "../../../../../src/stores/notifications
import { NotificationLevel } from "../../../../../src/stores/notifications/NotificationLevel";
jest.mock("../../../../../src/stores/spaces/SpaceStore", () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const EventEmitter = require("events");
class MockSpaceStore extends EventEmitter {
activeSpace: SpaceKey = "!space1";

View file

@ -40,15 +40,11 @@ describe("SdkContextClass", () => {
});
it("userProfilesStore should raise an error without a client", () => {
expect(() => {
sdkContext.userProfilesStore;
}).toThrow("Unable to create UserProfilesStore without a client");
expect(() => sdkContext.userProfilesStore).toThrow("Unable to create UserProfilesStore without a client");
});
it("oidcClientStore should raise an error without a client", () => {
expect(() => {
sdkContext.oidcClientStore;
}).toThrow("Unable to create OidcClientStore without a client");
expect(() => sdkContext.oidcClientStore).toThrow("Unable to create OidcClientStore without a client");
});
describe("when SDKContext has a client", () => {

View file

@ -358,12 +358,12 @@ describe("JitsiCall", () => {
new CustomEvent("widgetapirequest", { detail: {} }),
);
await waitFor(() => {
expect(callback).toHaveBeenNthCalledWith(1, ConnectionState.Disconnected, ConnectionState.Connected),
expect(callback).toHaveBeenNthCalledWith(
2,
ConnectionState.WidgetLoading,
ConnectionState.Disconnected,
);
expect(callback).toHaveBeenNthCalledWith(1, ConnectionState.Disconnected, ConnectionState.Connected);
expect(callback).toHaveBeenNthCalledWith(
2,
ConnectionState.WidgetLoading,
ConnectionState.Disconnected,
);
expect(callback).toHaveBeenNthCalledWith(3, ConnectionState.Connecting, ConnectionState.WidgetLoading);
});
// in video rooms we expect the call to immediately reconnect

View file

@ -49,7 +49,7 @@ describe("BreadcrumbsStore", () => {
it("passes through the dynamic room precessors flag", () => {
mocked(client.getVisibleRooms).mockReturnValue(fakeRooms(25));
store.meetsRoomRequirement;
expect(store.meetsRoomRequirement).toBeTruthy();
expect(client.getVisibleRooms).toHaveBeenCalledWith(true);
});
});
@ -57,7 +57,7 @@ describe("BreadcrumbsStore", () => {
describe("And the feature_dynamic_room_predecessors is not enabled", () => {
it("passes through the dynamic room precessors flag", () => {
mocked(client.getVisibleRooms).mockReturnValue(fakeRooms(25));
store.meetsRoomRequirement;
expect(store.meetsRoomRequirement).toBeTruthy();
expect(client.getVisibleRooms).toHaveBeenCalledWith(false);
});
});

View file

@ -70,7 +70,7 @@ describe("OwnProfileStore", () => {
);
try {
await ownProfileStore.start();
} catch (ignore) {}
} catch {}
expect(onUpdate).not.toHaveBeenCalled();
expect(ownProfileStore.displayName).toBe(client.getSafeUserId());

View file

@ -465,7 +465,7 @@ describe("RoomViewStore", function () {
try {
expect(setRoomVisible.mock.calls[i][0]).toEqual(v[0]);
expect(setRoomVisible.mock.calls[i][1]).toEqual(v[1]);
} catch (err) {
} catch {
throw new Error(`i=${i} got ${setRoomVisible.mock.calls[i]} want ${v}`);
}
});

View file

@ -353,7 +353,6 @@ describe("RoomListStore", () => {
const videoRoomKnock = "!videoRoomKnock_server";
const rooms: Room[] = [];
RoomListStore.instance;
mkRoom(client, videoRoomPrivate, rooms);
mkRoom(client, videoRoomPublic, rooms);
mkRoom(client, videoRoomKnock, rooms);

View file

@ -17,7 +17,7 @@ import SpaceStore from "../../../../../src/stores/spaces/SpaceStore";
jest.mock("../../../../../src/settings/SettingsStore");
jest.mock("../../../../../src/stores/spaces/SpaceStore", () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const EventEmitter = require("events");
class MockSpaceStore extends EventEmitter {
isRoomInSpace = jest.fn();

View file

@ -74,6 +74,7 @@ describe("MegolmExportEncryption", function () {
subtle: webCrypto.subtle,
},
});
// eslint-disable-next-line @typescript-eslint/no-require-imports
MegolmExportEncryption = require("../../../src/utils/MegolmExportEncryption");
});

View file

@ -218,7 +218,9 @@ describe("SessionLock", () => {
const window2 = createWindow();
// import the dependencies of getSessionLock into the new context
// eslint-disable-next-line @typescript-eslint/no-require-imports
window2._uuid = require("uuid");
// eslint-disable-next-line @typescript-eslint/no-require-imports
window2._logger = require("matrix-js-sdk/src/logger");
window2.SESSION_LOCK_CONSTANTS = SESSION_LOCK_CONSTANTS;

View file

@ -14,7 +14,7 @@ describe("Singleflight", () => {
});
it("should throw for bad context variables", () => {
const permutations: [Object | null, string | null][] = [
const permutations: [object | null, string | null][] = [
[null, null],
[{}, null],
[null, "test"],

View file

@ -47,7 +47,9 @@ describe("ElectronPlatform", () => {
setupLanguageMock();
});
const getElectronEventHandlerCall = (eventType: string): [type: string, handler: Function] | undefined =>
const getElectronEventHandlerCall = (
eventType: string,
): [type: string, handler: (...args: any) => void] | undefined =>
mockElectron.on.mock.calls.find(([type]) => type === eventType);
it("flushes rageshake before quitting", () => {

View file

@ -162,7 +162,11 @@ describe("VoiceBroadcastPlayback", () => {
jest.spyOn(playback, "removeAllListeners");
jest.spyOn(playback, "destroy");
playback.on(VoiceBroadcastPlaybackEvent.StateChanged, onStateChanged);
fakeTimers ? await flushPromisesWithFakeTimers() : await flushPromises();
if (fakeTimers) {
await flushPromisesWithFakeTimers();
} else {
await flushPromises();
}
return playback;
};

View file

@ -453,7 +453,7 @@ describe("VoiceBroadcastRecording", () => {
describe.each([
["pause", async () => voiceBroadcastRecording.pause()],
["toggle", async () => voiceBroadcastRecording.toggle()],
])("and calling %s", (_case: string, action: Function) => {
])("and calling %s", (_case: string, action: () => Promise<void>) => {
beforeEach(async () => {
await action();
});
@ -480,7 +480,7 @@ describe("VoiceBroadcastRecording", () => {
describe.each([
["pause", async () => voiceBroadcastRecording.pause()],
["toggle", async () => voiceBroadcastRecording.toggle()],
])("and calling %s", (_case: string, action: Function) => {
])("and calling %s", (_case: string, action: () => Promise<void>) => {
beforeEach(async () => {
await action();
});
@ -590,7 +590,7 @@ describe("VoiceBroadcastRecording", () => {
describe.each([
["resume", async () => voiceBroadcastRecording.resume()],
["toggle", async () => voiceBroadcastRecording.toggle()],
])("and calling %s", (_case: string, action: Function) => {
])("and calling %s", (_case: string, action: () => Promise<void>) => {
beforeEach(async () => {
await action();
});