Enable @typescript-eslint/explicit-member-accessibility
on /src (#9785)
* Enable `@typescript-eslint/explicit-member-accessibility` on /src * Prettier
This commit is contained in:
parent
51554399fb
commit
f1e8e7f140
396 changed files with 1110 additions and 1098 deletions
|
@ -43,31 +43,31 @@ export function ruleTypeToStable(rule: string): string {
|
|||
}
|
||||
|
||||
export class BanList {
|
||||
_rules: ListRule[] = [];
|
||||
_roomId: string;
|
||||
private _rules: ListRule[] = [];
|
||||
private _roomId: string;
|
||||
|
||||
constructor(roomId: string) {
|
||||
public constructor(roomId: string) {
|
||||
this._roomId = roomId;
|
||||
this.updateList();
|
||||
}
|
||||
|
||||
get roomId(): string {
|
||||
public get roomId(): string {
|
||||
return this._roomId;
|
||||
}
|
||||
|
||||
get serverRules(): ListRule[] {
|
||||
public get serverRules(): ListRule[] {
|
||||
return this._rules.filter((r) => r.kind === RULE_SERVER);
|
||||
}
|
||||
|
||||
get userRules(): ListRule[] {
|
||||
public get userRules(): ListRule[] {
|
||||
return this._rules.filter((r) => r.kind === RULE_USER);
|
||||
}
|
||||
|
||||
get roomRules(): ListRule[] {
|
||||
public get roomRules(): ListRule[] {
|
||||
return this._rules.filter((r) => r.kind === RULE_ROOM);
|
||||
}
|
||||
|
||||
async banEntity(kind: string, entity: string, reason: string): Promise<any> {
|
||||
public async banEntity(kind: string, entity: string, reason: string): Promise<any> {
|
||||
await MatrixClientPeg.get().sendStateEvent(
|
||||
this._roomId,
|
||||
ruleTypeToStable(kind),
|
||||
|
@ -81,7 +81,7 @@ export class BanList {
|
|||
this._rules.push(new ListRule(entity, RECOMMENDATION_BAN, reason, ruleTypeToStable(kind)));
|
||||
}
|
||||
|
||||
async unbanEntity(kind: string, entity: string): Promise<any> {
|
||||
public async unbanEntity(kind: string, entity: string): Promise<any> {
|
||||
// Empty state event is effectively deleting it.
|
||||
await MatrixClientPeg.get().sendStateEvent(this._roomId, ruleTypeToStable(kind), {}, "rule:" + entity);
|
||||
this._rules = this._rules.filter((r) => {
|
||||
|
@ -91,7 +91,7 @@ export class BanList {
|
|||
});
|
||||
}
|
||||
|
||||
updateList() {
|
||||
public updateList() {
|
||||
this._rules = [];
|
||||
|
||||
const room = MatrixClientPeg.get().getRoom(this._roomId);
|
||||
|
|
|
@ -29,13 +29,13 @@ export function recommendationToStable(recommendation: string, unstable = true):
|
|||
}
|
||||
|
||||
export class ListRule {
|
||||
_glob: MatrixGlob;
|
||||
_entity: string;
|
||||
_action: string;
|
||||
_reason: string;
|
||||
_kind: string;
|
||||
private _glob: MatrixGlob;
|
||||
private readonly _entity: string;
|
||||
private readonly _action: string;
|
||||
private readonly _reason: string;
|
||||
private readonly _kind: string;
|
||||
|
||||
constructor(entity: string, action: string, reason: string, kind: string) {
|
||||
public constructor(entity: string, action: string, reason: string, kind: string) {
|
||||
this._glob = new MatrixGlob(entity);
|
||||
this._entity = entity;
|
||||
this._action = recommendationToStable(action, false);
|
||||
|
@ -43,23 +43,23 @@ export class ListRule {
|
|||
this._kind = kind;
|
||||
}
|
||||
|
||||
get entity(): string {
|
||||
public get entity(): string {
|
||||
return this._entity;
|
||||
}
|
||||
|
||||
get reason(): string {
|
||||
public get reason(): string {
|
||||
return this._reason;
|
||||
}
|
||||
|
||||
get kind(): string {
|
||||
public get kind(): string {
|
||||
return this._kind;
|
||||
}
|
||||
|
||||
get recommendation(): string {
|
||||
public get recommendation(): string {
|
||||
return this._action;
|
||||
}
|
||||
|
||||
isMatch(entity: string): boolean {
|
||||
public isMatch(entity: string): boolean {
|
||||
return this._glob.test(entity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,15 +39,15 @@ export class Mjolnir {
|
|||
private mjolnirWatchRef: string = null;
|
||||
private dispatcherRef: string = null;
|
||||
|
||||
get roomIds(): string[] {
|
||||
public get roomIds(): string[] {
|
||||
return this._roomIds;
|
||||
}
|
||||
|
||||
get lists(): BanList[] {
|
||||
public get lists(): BanList[] {
|
||||
return this._lists;
|
||||
}
|
||||
|
||||
start() {
|
||||
public start() {
|
||||
this.mjolnirWatchRef = SettingsStore.watchSetting("mjolnirRooms", null, this.onListsChanged.bind(this));
|
||||
|
||||
this.dispatcherRef = dis.register(this.onAction);
|
||||
|
@ -64,13 +64,13 @@ export class Mjolnir {
|
|||
}
|
||||
};
|
||||
|
||||
setup() {
|
||||
public setup() {
|
||||
if (!MatrixClientPeg.get()) return;
|
||||
this.updateLists(SettingsStore.getValue("mjolnirRooms"));
|
||||
MatrixClientPeg.get().on(RoomStateEvent.Events, this.onEvent);
|
||||
}
|
||||
|
||||
stop() {
|
||||
public stop() {
|
||||
if (this.mjolnirWatchRef) {
|
||||
SettingsStore.unwatchSetting(this.mjolnirWatchRef);
|
||||
this.mjolnirWatchRef = null;
|
||||
|
@ -85,7 +85,7 @@ export class Mjolnir {
|
|||
MatrixClientPeg.get().removeListener(RoomStateEvent.Events, this.onEvent);
|
||||
}
|
||||
|
||||
async getOrCreatePersonalList(): Promise<BanList> {
|
||||
public async getOrCreatePersonalList(): Promise<BanList> {
|
||||
let personalRoomId = SettingsStore.getValue("mjolnirPersonalRoom");
|
||||
if (!personalRoomId) {
|
||||
const resp = await MatrixClientPeg.get().createRoom({
|
||||
|
@ -113,7 +113,7 @@ export class Mjolnir {
|
|||
}
|
||||
|
||||
// get without creating the list
|
||||
getPersonalList(): BanList {
|
||||
public getPersonalList(): BanList {
|
||||
const personalRoomId = SettingsStore.getValue("mjolnirPersonalRoom");
|
||||
if (!personalRoomId) return null;
|
||||
|
||||
|
@ -125,13 +125,13 @@ export class Mjolnir {
|
|||
return list;
|
||||
}
|
||||
|
||||
async subscribeToList(roomId: string) {
|
||||
public async subscribeToList(roomId: string) {
|
||||
const roomIds = [...this._roomIds, roomId];
|
||||
await SettingsStore.setValue("mjolnirRooms", null, SettingLevel.ACCOUNT, roomIds);
|
||||
this._lists.push(new BanList(roomId));
|
||||
}
|
||||
|
||||
async unsubscribeFromList(roomId: string) {
|
||||
public async unsubscribeFromList(roomId: string) {
|
||||
const roomIds = this._roomIds.filter((r) => r !== roomId);
|
||||
await SettingsStore.setValue("mjolnirRooms", null, SettingLevel.ACCOUNT, roomIds);
|
||||
this._lists = this._lists.filter((b) => b.roomId !== roomId);
|
||||
|
@ -164,7 +164,7 @@ export class Mjolnir {
|
|||
}
|
||||
}
|
||||
|
||||
isServerBanned(serverName: string): boolean {
|
||||
public isServerBanned(serverName: string): boolean {
|
||||
for (const list of this._lists) {
|
||||
for (const rule of list.serverRules) {
|
||||
if (rule.isMatch(serverName)) {
|
||||
|
@ -175,7 +175,7 @@ export class Mjolnir {
|
|||
return false;
|
||||
}
|
||||
|
||||
isUserBanned(userId: string): boolean {
|
||||
public isUserBanned(userId: string): boolean {
|
||||
for (const list of this._lists) {
|
||||
for (const rule of list.userRules) {
|
||||
if (rule.isMatch(userId)) {
|
||||
|
@ -186,7 +186,7 @@ export class Mjolnir {
|
|||
return false;
|
||||
}
|
||||
|
||||
static sharedInstance(): Mjolnir {
|
||||
public static sharedInstance(): Mjolnir {
|
||||
if (!Mjolnir.instance) {
|
||||
Mjolnir.instance = new Mjolnir();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue