Enable @typescript-eslint/explicit-member-accessibility on /src (#9785)

* Enable `@typescript-eslint/explicit-member-accessibility` on /src

* Prettier
This commit is contained in:
Michael Telatynski 2022-12-16 12:29:59 +00:00 committed by GitHub
parent 51554399fb
commit f1e8e7f140
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
396 changed files with 1110 additions and 1098 deletions

View file

@ -22,7 +22,7 @@ import PermalinkConstructor, { PermalinkParts } from "./PermalinkConstructor";
export default class ElementPermalinkConstructor extends PermalinkConstructor {
private elementUrl: string;
constructor(elementUrl: string) {
public constructor(elementUrl: string) {
super();
this.elementUrl = elementUrl;
@ -31,19 +31,19 @@ export default class ElementPermalinkConstructor extends PermalinkConstructor {
}
}
forEvent(roomId: string, eventId: string, serverCandidates: string[]): string {
public forEvent(roomId: string, eventId: string, serverCandidates: string[]): string {
return `${this.elementUrl}/#/room/${roomId}/${eventId}${this.encodeServerCandidates(serverCandidates)}`;
}
forRoom(roomIdOrAlias: string, serverCandidates?: string[]): string {
public forRoom(roomIdOrAlias: string, serverCandidates?: string[]): string {
return `${this.elementUrl}/#/room/${roomIdOrAlias}${this.encodeServerCandidates(serverCandidates)}`;
}
forUser(userId: string): string {
public forUser(userId: string): string {
return `${this.elementUrl}/#/user/${userId}`;
}
forEntity(entityId: string): string {
public forEntity(entityId: string): string {
if (entityId[0] === "!" || entityId[0] === "#") {
return this.forRoom(entityId);
} else if (entityId[0] === "@") {
@ -51,12 +51,12 @@ export default class ElementPermalinkConstructor extends PermalinkConstructor {
} else throw new Error("Unrecognized entity");
}
isPermalinkHost(testHost: string): boolean {
public isPermalinkHost(testHost: string): boolean {
const parsedUrl = new URL(this.elementUrl);
return testHost === (parsedUrl.host || parsedUrl.hostname); // one of the hosts should match
}
encodeServerCandidates(candidates?: string[]) {
public encodeServerCandidates(candidates?: string[]) {
if (!candidates || candidates.length === 0) return "";
return `?via=${candidates.map((c) => encodeURIComponent(c)).join("&via=")}`;
}
@ -64,7 +64,7 @@ export default class ElementPermalinkConstructor extends PermalinkConstructor {
// Heavily inspired by/borrowed from the matrix-bot-sdk (with permission):
// https://github.com/turt2live/matrix-js-bot-sdk/blob/7c4665c9a25c2c8e0fe4e509f2616505b5b66a1c/src/Permalinks.ts#L33-L61
// Adapted for Element's URL format
parsePermalink(fullUrl: string): PermalinkParts {
public parsePermalink(fullUrl: string): PermalinkParts {
if (!fullUrl || !fullUrl.startsWith(this.elementUrl)) {
throw new Error("Does not appear to be a permalink");
}
@ -79,7 +79,7 @@ export default class ElementPermalinkConstructor extends PermalinkConstructor {
* @param {string} route The app route
* @returns {PermalinkParts}
*/
static parseAppRoute(route: string): PermalinkParts {
public static parseAppRoute(route: string): PermalinkParts {
const parts = route.split("/");
if (parts.length < 2) {

View file

@ -20,7 +20,7 @@ import PermalinkConstructor, { PermalinkParts } from "./PermalinkConstructor";
* Generates matrix: scheme permalinks
*/
export default class MatrixSchemePermalinkConstructor extends PermalinkConstructor {
constructor() {
public constructor() {
super();
}
@ -38,36 +38,36 @@ export default class MatrixSchemePermalinkConstructor extends PermalinkConstruct
throw new Error("Cannot encode entity: " + entity);
}
forEvent(roomId: string, eventId: string, serverCandidates: string[]): string {
public forEvent(roomId: string, eventId: string, serverCandidates: string[]): string {
return (
`matrix:${this.encodeEntity(roomId)}` +
`/${this.encodeEntity(eventId)}${this.encodeServerCandidates(serverCandidates)}`
);
}
forRoom(roomIdOrAlias: string, serverCandidates: string[]): string {
public forRoom(roomIdOrAlias: string, serverCandidates: string[]): string {
return `matrix:${this.encodeEntity(roomIdOrAlias)}${this.encodeServerCandidates(serverCandidates)}`;
}
forUser(userId: string): string {
public forUser(userId: string): string {
return `matrix:${this.encodeEntity(userId)}`;
}
forEntity(entityId: string): string {
public forEntity(entityId: string): string {
return `matrix:${this.encodeEntity(entityId)}`;
}
isPermalinkHost(testHost: string): boolean {
public isPermalinkHost(testHost: string): boolean {
// TODO: Change API signature to accept the URL for checking
return testHost === "";
}
encodeServerCandidates(candidates: string[]) {
public encodeServerCandidates(candidates: string[]) {
if (!candidates || candidates.length === 0) return "";
return `?via=${candidates.map((c) => encodeURIComponent(c)).join("&via=")}`;
}
parsePermalink(fullUrl: string): PermalinkParts {
public parsePermalink(fullUrl: string): PermalinkParts {
if (!fullUrl || !fullUrl.startsWith("matrix:")) {
throw new Error("Does not appear to be a permalink");
}

View file

@ -23,38 +23,38 @@ export const baseUrl = `https://${host}`;
* Generates matrix.to permalinks
*/
export default class MatrixToPermalinkConstructor extends PermalinkConstructor {
constructor() {
public constructor() {
super();
}
forEvent(roomId: string, eventId: string, serverCandidates: string[]): string {
public forEvent(roomId: string, eventId: string, serverCandidates: string[]): string {
return `${baseUrl}/#/${roomId}/${eventId}${this.encodeServerCandidates(serverCandidates)}`;
}
forRoom(roomIdOrAlias: string, serverCandidates: string[]): string {
public forRoom(roomIdOrAlias: string, serverCandidates: string[]): string {
return `${baseUrl}/#/${roomIdOrAlias}${this.encodeServerCandidates(serverCandidates)}`;
}
forUser(userId: string): string {
public forUser(userId: string): string {
return `${baseUrl}/#/${userId}`;
}
forEntity(entityId: string): string {
public forEntity(entityId: string): string {
return `${baseUrl}/#/${entityId}`;
}
isPermalinkHost(testHost: string): boolean {
public isPermalinkHost(testHost: string): boolean {
return testHost === host;
}
encodeServerCandidates(candidates: string[]) {
public encodeServerCandidates(candidates: string[]) {
if (!candidates || candidates.length === 0) return "";
return `?via=${candidates.map((c) => encodeURIComponent(c)).join("&via=")}`;
}
// Heavily inspired by/borrowed from the matrix-bot-sdk (with permission):
// https://github.com/turt2live/matrix-js-bot-sdk/blob/7c4665c9a25c2c8e0fe4e509f2616505b5b66a1c/src/Permalinks.ts#L33-L61
parsePermalink(fullUrl: string): PermalinkParts {
public parsePermalink(fullUrl: string): PermalinkParts {
if (!fullUrl || !fullUrl.startsWith(baseUrl)) {
throw new Error("Does not appear to be a permalink");
}

View file

@ -19,27 +19,27 @@ limitations under the License.
* TODO: Convert this to a real TypeScript interface
*/
export default class PermalinkConstructor {
forEvent(roomId: string, eventId: string, serverCandidates: string[] = []): string {
public forEvent(roomId: string, eventId: string, serverCandidates: string[] = []): string {
throw new Error("Not implemented");
}
forRoom(roomIdOrAlias: string, serverCandidates: string[] = []): string {
public forRoom(roomIdOrAlias: string, serverCandidates: string[] = []): string {
throw new Error("Not implemented");
}
forUser(userId: string): string {
public forUser(userId: string): string {
throw new Error("Not implemented");
}
forEntity(entityId: string): string {
public forEntity(entityId: string): string {
throw new Error("Not implemented");
}
isPermalinkHost(host: string): boolean {
public isPermalinkHost(host: string): boolean {
throw new Error("Not implemented");
}
parsePermalink(fullUrl: string): PermalinkParts {
public parsePermalink(fullUrl: string): PermalinkParts {
throw new Error("Not implemented");
}
}
@ -47,35 +47,30 @@ export default class PermalinkConstructor {
// Inspired by/Borrowed with permission from the matrix-bot-sdk:
// https://github.com/turt2live/matrix-js-bot-sdk/blob/7c4665c9a25c2c8e0fe4e509f2616505b5b66a1c/src/Permalinks.ts#L1-L6
export class PermalinkParts {
roomIdOrAlias: string;
eventId: string;
userId: string;
viaServers: string[];
public constructor(
public readonly roomIdOrAlias: string,
public readonly eventId: string,
public readonly userId: string,
public readonly viaServers: string[],
) {}
constructor(roomIdOrAlias: string, eventId: string, userId: string, viaServers: string[]) {
this.roomIdOrAlias = roomIdOrAlias;
this.eventId = eventId;
this.userId = userId;
this.viaServers = viaServers;
}
static forUser(userId: string): PermalinkParts {
public static forUser(userId: string): PermalinkParts {
return new PermalinkParts(null, null, userId, null);
}
static forRoom(roomIdOrAlias: string, viaServers: string[] = []): PermalinkParts {
public static forRoom(roomIdOrAlias: string, viaServers: string[] = []): PermalinkParts {
return new PermalinkParts(roomIdOrAlias, null, null, viaServers);
}
static forEvent(roomId: string, eventId: string, viaServers: string[] = []): PermalinkParts {
public static forEvent(roomId: string, eventId: string, viaServers: string[] = []): PermalinkParts {
return new PermalinkParts(roomId, eventId, null, viaServers);
}
get primaryEntityId(): string {
public get primaryEntityId(): string {
return this.roomIdOrAlias || this.userId;
}
get sigil(): string {
public get sigil(): string {
return this.primaryEntityId[0];
}
}

View file

@ -94,7 +94,7 @@ export class RoomPermalinkCreator {
// Some of the tests done by this class are relatively expensive, so normally
// throttled to not happen on every update. Pass false as the shouldThrottle
// param to disable this behaviour, eg. for tests.
constructor(room: Room, roomId: string | null = null, shouldThrottle = true) {
public constructor(room: Room, roomId: string | null = null, shouldThrottle = true) {
this.room = room;
this.roomId = room ? room.roomId : roomId;
this.highestPlUserId = null;