1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-07-31 15:24:23 +03:00

Pre-lint format

This commit is contained in:
Travis Ralston
2021-06-09 21:55:06 -06:00
parent b3a11030f2
commit bcccc909c5
4 changed files with 34 additions and 34 deletions

View File

@ -128,10 +128,10 @@ describe("MSC3089Branch", () => {
it('should be able to return event information', async () => {
const mxcLatter = "example.org/file";
const fileContent = {isFile: "not quite", url: "mxc://" + mxcLatter};
const fileContent = { isFile: "not quite", url: "mxc://" + mxcLatter };
const eventsArr = [
{getId: () => "$not-file", getContent: () => ({})},
{getId: () => fileEventId, getContent: () => ({file: fileContent})},
{ getId: () => "$not-file", getContent: () => ({}) },
{ getId: () => fileEventId, getContent: () => ({ file: fileContent }) },
];
client.getEventTimeline = () => Promise.resolve({
getEvents: () => eventsArr,

View File

@ -21,7 +21,7 @@ import { EventType, MsgType, UNSTABLE_MSC3089_BRANCH, UNSTABLE_MSC3089_LEAF } fr
import {
DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
MSC3089TreeSpace,
TreePermissions
TreePermissions,
} from "../../../src/models/MSC3089TreeSpace";
import { DEFAULT_ALPHABET } from "../../../src/utils";
import { MockBlob } from "../../MockBlob";
@ -87,7 +87,7 @@ describe("MSC3089TreeSpace", () => {
expect(stateRoomId).toEqual(roomId);
expect(eventType).toEqual(EventType.RoomName);
expect(stateKey).toEqual("");
expect(content).toMatchObject({name: newName});
expect(content).toMatchObject({ name: newName });
return Promise.resolve();
});
client.sendStateEvent = fn;
@ -208,7 +208,7 @@ describe("MSC3089TreeSpace", () => {
expect(eventType).toEqual(EventType.SpaceChild);
expect(stateKey).toEqual(subspaceId);
}
expect(content).toMatchObject({via: [domain]});
expect(content).toMatchObject({ via: [domain] });
// return value not used
});
@ -223,7 +223,7 @@ describe("MSC3089TreeSpace", () => {
expect(createFn).toHaveBeenCalledTimes(1);
expect(sendStateFn).toHaveBeenCalledTimes(2);
const content = expect.objectContaining({via: [domain]});
const content = expect.objectContaining({ via: [domain] });
expect(sendStateFn).toHaveBeenCalledWith(subspaceId, EventType.SpaceParent, content, tree.roomId);
expect(sendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, content, subspaceId);
});
@ -238,9 +238,9 @@ describe("MSC3089TreeSpace", () => {
expect(stateKey).toBeUndefined();
return [
// Partial implementations of Room
{getStateKey: () => firstChildRoom},
{getStateKey: () => secondChildRoom},
{getStateKey: () => thirdChildRoom},
{ getStateKey: () => firstChildRoom },
{ getStateKey: () => secondChildRoom },
{ getStateKey: () => thirdChildRoom },
];
},
};
@ -270,9 +270,9 @@ describe("MSC3089TreeSpace", () => {
client.getRoom = () => ({} as Room); // to appease the TreeSpace constructor
// Only mocking used API
const firstSubdirectory = {roomId: "!first:example.org"} as any as MSC3089TreeSpace;
const searchedSubdirectory = {roomId: "!find_me:example.org"} as any as MSC3089TreeSpace;
const thirdSubdirectory = {roomId: "!third:example.org"} as any as MSC3089TreeSpace;
const firstSubdirectory = { roomId: "!first:example.org" } as any as MSC3089TreeSpace;
const searchedSubdirectory = { roomId: "!find_me:example.org" } as any as MSC3089TreeSpace;
const thirdSubdirectory = { roomId: "!third:example.org" } as any as MSC3089TreeSpace;
tree.getDirectories = () => [firstSubdirectory, searchedSubdirectory, thirdSubdirectory];
let result = tree.getDirectory(searchedSubdirectory.roomId);
@ -284,10 +284,10 @@ describe("MSC3089TreeSpace", () => {
it('should be able to delete itself', async () => {
const delete1 = jest.fn().mockImplementation(() => Promise.resolve());
const subdir1 = {delete: delete1} as any as MSC3089TreeSpace; // mock tested bits
const subdir1 = { delete: delete1 } as any as MSC3089TreeSpace; // mock tested bits
const delete2 = jest.fn().mockImplementation(() => Promise.resolve());
const subdir2 = {delete: delete2} as any as MSC3089TreeSpace; // mock tested bits
const subdir2 = { delete: delete2 } as any as MSC3089TreeSpace; // mock tested bits
const joinMemberId = "@join:example.org";
const knockMemberId = "@knock:example.org";
@ -303,14 +303,14 @@ describe("MSC3089TreeSpace", () => {
expect(stateKey).toBeUndefined();
return [
// Partial implementations
{getContent: () => ({membership: "join"}), getStateKey: () => joinMemberId},
{getContent: () => ({membership: "knock"}), getStateKey: () => knockMemberId},
{getContent: () => ({membership: "invite"}), getStateKey: () => inviteMemberId},
{getContent: () => ({membership: "leave"}), getStateKey: () => leaveMemberId},
{getContent: () => ({membership: "ban"}), getStateKey: () => banMemberId},
{ getContent: () => ({ membership: "join" }), getStateKey: () => joinMemberId },
{ getContent: () => ({ membership: "knock" }), getStateKey: () => knockMemberId },
{ getContent: () => ({ membership: "invite" }), getStateKey: () => inviteMemberId },
{ getContent: () => ({ membership: "leave" }), getStateKey: () => leaveMemberId },
{ getContent: () => ({ membership: "ban" }), getStateKey: () => banMemberId },
// ensure we don't kick ourselves
{getContent: () => ({membership: "join"}), getStateKey: () => selfUserId},
{ getContent: () => ({ membership: "join" }), getStateKey: () => selfUserId },
]
},
};
@ -337,12 +337,12 @@ describe("MSC3089TreeSpace", () => {
// Danger: these are partial implementations for testing purposes only
// @ts-ignore - "MatrixEvent is a value but used as a type", which is true but not important
let childState: {[roomId: string]: MatrixEvent[]} = {};
let childState: { [roomId: string]: MatrixEvent[] } = {};
// @ts-ignore - "MatrixEvent is a value but used as a type", which is true but not important
let parentState: MatrixEvent[] = [];
let parentRoom: Room;
let childTrees: MSC3089TreeSpace[];
let rooms: {[roomId: string]: Room};
let rooms: { [roomId: string]: Room };
let clientSendStateFn: jest.MockedFunction<typeof client.sendStateEvent>;
const staticDomain = "static.example.org";
@ -771,7 +771,7 @@ describe("MSC3089TreeSpace", () => {
[UNSTABLE_MSC3089_LEAF.unstable]: {}, // test to ensure we're definitely using unstable
});
return Promise.resolve({event_id: fileEventId}); // eslint-disable-line camelcase
return Promise.resolve({ event_id: fileEventId }); // eslint-disable-line camelcase
});
client.sendMessage = sendMsgFn;
@ -800,7 +800,7 @@ describe("MSC3089TreeSpace", () => {
it('should support getting files', () => {
const fileEventId = "$file";
const fileEvent = {forTest: true}; // MatrixEvent mock
const fileEvent = { forTest: true }; // MatrixEvent mock
room.currentState = {
getStateEvents: (eventType: string, stateKey?: string) => {
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test to ensure we're definitely using unstable
@ -829,8 +829,8 @@ describe("MSC3089TreeSpace", () => {
});
it('should list files', () => {
const firstFile = {getContent: () => ({active: true})};
const secondFile = {getContent: () => ({active: false})}; // deliberately inactive
const firstFile = { getContent: () => ({ active: true }) };
const secondFile = { getContent: () => ({ active: false }) }; // deliberately inactive
room.currentState = {
getStateEvents: (eventType: string, stateKey?: string) => {
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test to ensure we're definitely using unstable

View File

@ -92,7 +92,7 @@ export class MSC3089Branch {
if (!event) throw new Error("Failed to find event");
// Sometimes the event context doesn't decrypt for us, so do that.
await this.client.decryptEventIfNeeded(event, {emit: false, isRetry: false});
await this.client.decryptEventIfNeeded(event, { emit: false, isRetry: false });
const file = event.getContent()['file'];
const httpUrl = this.client.mxcUrlToHttp(file['url']);

View File

@ -101,7 +101,7 @@ export class MSC3089TreeSpace {
* @returns {Promise<void>} Resolves when complete.
*/
public setName(name: string): Promise<void> {
return this.client.sendStateEvent(this.roomId, EventType.RoomName, {name}, "");
return this.client.sendStateEvent(this.roomId, EventType.RoomName, { name }, "");
}
/**
@ -220,9 +220,9 @@ export class MSC3089TreeSpace {
await this.client.leave(this.roomId);
}
private getOrderedChildren(children: MatrixEvent[]): {roomId: string, order: string}[] {
const ordered: {roomId: string, order: string}[] = children
.map(c => ({roomId: c.getStateKey(), order: c.getContent()['order']}));
private getOrderedChildren(children: MatrixEvent[]): { roomId: string, order: string }[] {
const ordered: { roomId: string, order: string }[] = children
.map(c => ({ roomId: c.getStateKey(), order: c.getContent()['order'] }));
ordered.sort((a, b) => {
if (a.order && !b.order) {
return -1;
@ -357,7 +357,7 @@ export class MSC3089TreeSpace {
// XXX: We should be creating gaps to avoid conflicts
lastOrder = lastOrder ? nextString(lastOrder) : DEFAULT_ALPHABET[0];
const currentChild = parentRoom.currentState.getStateEvents(EventType.SpaceChild, target.roomId);
const content = currentChild?.getContent() ?? {via: [this.client.getDomain()]};
const content = currentChild?.getContent() ?? { via: [this.client.getDomain()] };
await this.client.sendStateEvent(parentRoom.roomId, EventType.SpaceChild, {
...content,
order: lastOrder,
@ -373,7 +373,7 @@ export class MSC3089TreeSpace {
// Now we can finally update our own order state
const currentChild = parentRoom.currentState.getStateEvents(EventType.SpaceChild, this.roomId);
const content = currentChild?.getContent() ?? {via: [this.client.getDomain()]};
const content = currentChild?.getContent() ?? { via: [this.client.getDomain()] };
await this.client.sendStateEvent(parentRoom.roomId, EventType.SpaceChild, {
...content,
order: newOrder,