Fix lint issues in new code

This commit is contained in:
Jorik Schellekens 2020-07-20 20:43:49 +01:00
parent c3ffbdbdbc
commit 4ba1f91a2b
19 changed files with 66 additions and 33 deletions

View file

@ -33,14 +33,14 @@ declare global {
init: () => Promise<void>; init: () => Promise<void>;
}; };
mx_ContentMessages: ContentMessages; mxContentMessages: ContentMessages;
mx_ToastStore: ToastStore; mxToastStore: ToastStore;
mx_DeviceListener: DeviceListener; mxDeviceListener: DeviceListener;
mx_RebrandListener: RebrandListener; mxRebrandListener: RebrandListener;
mx_RoomListStore: RoomListStoreClass; mxRoomListStore: RoomListStoreClass;
mx_RoomListLayoutStore: RoomListLayoutStore; mxRoomListLayoutStore: RoomListLayoutStore;
mx_PlatformPeg: PlatformPeg; mxPlatformPeg: PlatformPeg;
mx_IntegrationManagers: typeof IntegrationManagers; mxIntegrationManagers: typeof IntegrationManagers;
} }
// workaround for https://github.com/microsoft/TypeScript/issues/30933 // workaround for https://github.com/microsoft/TypeScript/issues/30933

View file

@ -621,9 +621,9 @@ export default class ContentMessages {
} }
static sharedInstance() { static sharedInstance() {
if (window.mx_ContentMessages === undefined) { if (window.mxContentMessages === undefined) {
window.mx_ContentMessages = new ContentMessages(); window.mxContentMessages = new ContentMessages();
} }
return window.mx_ContentMessages; return window.mxContentMessages;
} }
} }

View file

@ -48,8 +48,8 @@ export default class DeviceListener {
private displayingToastsForDeviceIds = new Set<string>(); private displayingToastsForDeviceIds = new Set<string>();
static sharedInstance() { static sharedInstance() {
if (!window.mx_DeviceListener) window.mx_DeviceListener = new DeviceListener(); if (!window.mxDeviceListener) window.mxDeviceListener = new DeviceListener();
return window.mx_DeviceListener; return window.mxDeviceListener;
} }
start() { start() {

View file

@ -45,7 +45,7 @@ export class PlatformPeg {
} }
} }
if (!window.mx_PlatformPeg) { if (!window.mxPlatformPeg) {
window.mx_PlatformPeg = new PlatformPeg(); window.mxPlatformPeg = new PlatformPeg();
} }
export default window.mx_PlatformPeg; export default window.mxPlatformPeg;

View file

@ -67,8 +67,8 @@ export default class RebrandListener {
private nagAgainAt?: number = null; private nagAgainAt?: number = null;
static sharedInstance() { static sharedInstance() {
if (!window.mx_RebrandListener) window.mx_RebrandListener = new RebrandListener(); if (!window.mxRebrandListener) window.mxRebrandListener = new RebrandListener();
return window.mx_RebrandListener; return window.mxRebrandListener;
} }
constructor() { constructor() {

View file

@ -29,6 +29,9 @@ import {getAddressType} from "./UserAddress";
const E2EE_WK_KEY = "im.vector.riot.e2ee"; const E2EE_WK_KEY = "im.vector.riot.e2ee";
// we define a number of interfaces which in effect take their names from the js-sdk
/* eslint-disable camelcase */
// TODO move these interfaces over to js-sdk once it has been typescripted enough to accept them // TODO move these interfaces over to js-sdk once it has been typescripted enough to accept them
enum Visibility { enum Visibility {
Public = "public", Public = "public",
@ -42,6 +45,7 @@ enum Preset {
} }
interface Invite3PID { interface Invite3PID {
id_server: string; id_server: string;
id_access_token?: string; // this gets injected by the js-sdk id_access_token?: string; // this gets injected by the js-sdk
medium: string; medium: string;

View file

@ -30,7 +30,7 @@ export const useAccountData = <T extends {}>(cli: MatrixClient, eventType: strin
const handler = useCallback((event) => { const handler = useCallback((event) => {
if (event.getType() !== eventType) return; if (event.getType() !== eventType) return;
setValue(event.getContent()); setValue(event.getContent());
}, [cli, eventType]); }, [eventType]);
useEventEmitter(cli, "accountData", handler); useEventEmitter(cli, "accountData", handler);
return value || {} as T; return value || {} as T;
@ -43,7 +43,7 @@ export const useRoomAccountData = <T extends {}>(room: Room, eventType: string)
const handler = useCallback((event) => { const handler = useCallback((event) => {
if (event.getType() !== eventType) return; if (event.getType() !== eventType) return;
setValue(event.getContent()); setValue(event.getContent());
}, [room, eventType]); }, [eventType]);
useEventEmitter(room, "Room.accountData", handler); useEventEmitter(room, "Room.accountData", handler);
return value || {} as T; return value || {} as T;

View file

@ -123,7 +123,12 @@ export class IntegrationManagers {
const apiUrl = data['api_url']; const apiUrl = data['api_url'];
if (!apiUrl || !uiUrl) return; if (!apiUrl || !uiUrl) return;
const manager = new IntegrationManagerInstance(Kind.Account, apiUrl, uiUrl, w['id'] || w['state_key'] || ''); const manager = new IntegrationManagerInstance(
Kind.Account,
apiUrl,
uiUrl,
w['id'] || w['state_key'] || '',
);
this.managers.push(manager); this.managers.push(manager);
}); });
this.primaryManager = null; // reset primary this.primaryManager = null; // reset primary
@ -245,4 +250,4 @@ export class IntegrationManagers {
} }
// For debugging // For debugging
window.mx_IntegrationManagers = IntegrationManagers; window.mxIntegrationManagers = IntegrationManagers;

View file

@ -16,7 +16,7 @@ limitations under the License.
*/ */
import {PushRuleVectorState, State} from "./PushRuleVectorState"; import {PushRuleVectorState, State} from "./PushRuleVectorState";
import {IExtendedPushRule, IPushRuleSet, IRuleSets} from "./types"; import {IExtendedPushRule, IRuleSets} from "./types";
export interface IContentRules { export interface IContentRules {
vectorState: State; vectorState: State;

View file

@ -22,10 +22,12 @@ export enum NotificationSetting {
} }
export interface ISoundTweak { export interface ISoundTweak {
// eslint-disable-next-line camelcase
set_tweak: "sound"; set_tweak: "sound";
value: string; value: string;
} }
export interface IHighlightTweak { export interface IHighlightTweak {
// eslint-disable-next-line camelcase
set_tweak: "highlight"; set_tweak: "highlight";
value?: boolean; value?: boolean;
} }
@ -86,6 +88,7 @@ export enum RuleIds {
export interface IPushRule { export interface IPushRule {
enabled: boolean; enabled: boolean;
// eslint-disable-next-line camelcase
rule_id: RuleIds | string; rule_id: RuleIds | string;
actions: Action[]; actions: Action[];
default: boolean; default: boolean;

View file

@ -19,7 +19,6 @@ import SettingsStore, {SettingLevel} from '../SettingsStore';
import IWatcher from "./Watcher"; import IWatcher from "./Watcher";
import { toPx } from '../../utils/units'; import { toPx } from '../../utils/units';
import { Action } from '../../dispatcher/actions'; import { Action } from '../../dispatcher/actions';
import { UpdateSystemFontPayload } from '../../dispatcher/payloads/UpdateSystemFontPayload';
export class FontWatcher implements IWatcher { export class FontWatcher implements IWatcher {
public static readonly MIN_SIZE = 8; public static readonly MIN_SIZE = 8;

View file

@ -37,8 +37,8 @@ export default class ToastStore extends EventEmitter {
private countSeen = 0; private countSeen = 0;
static sharedInstance() { static sharedInstance() {
if (!window.mx_ToastStore) window.mx_ToastStore = new ToastStore(); if (!window.mxToastStore) window.mxToastStore = new ToastStore();
return window.mx_ToastStore; return window.mxToastStore;
} }
reset() { reset() {

View file

@ -70,4 +70,4 @@ export default class RoomListLayoutStore extends AsyncStoreWithClient<IState> {
} }
} }
window.mx_RoomListLayoutStore = RoomListLayoutStore.instance; window.mxRoomListLayoutStore = RoomListLayoutStore.instance;

View file

@ -606,4 +606,4 @@ export default class RoomListStore {
} }
} }
window.mx_RoomListStore = RoomListStore.instance; window.mxRoomListStore = RoomListStore.instance;

View file

@ -419,7 +419,9 @@ export class Algorithm extends EventEmitter {
if (!updatedTag || updatedTag === sticky.tag) { if (!updatedTag || updatedTag === sticky.tag) {
if (SettingsStore.getValue("advancedRoomListLogging")) { if (SettingsStore.getValue("advancedRoomListLogging")) {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14602 // TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14602
console.log(`Inserting sticky room ${sticky.room.roomId} at position ${sticky.position} in ${sticky.tag}`); console.log(
`Inserting sticky room ${sticky.room.roomId} at position ${sticky.position} in ${sticky.tag}`,
);
} }
this._cachedStickyRooms[sticky.tag].splice(sticky.position, 0, sticky.room); this._cachedStickyRooms[sticky.tag].splice(sticky.position, 0, sticky.room);
} }
@ -823,6 +825,7 @@ export class Algorithm extends EventEmitter {
// Flag that we've done something // Flag that we've done something
this.recalculateFilteredRoomsForTag(tag); // update filter to re-sort the list this.recalculateFilteredRoomsForTag(tag); // update filter to re-sort the list
this.recalculateStickyRoom(tag); // update sticky room to make sure it appears if needed this.recalculateStickyRoom(tag); // update sticky room to make sure it appears if needed
changed = true;
} }
if (SettingsStore.getValue("advancedRoomListLogging")) { if (SettingsStore.getValue("advancedRoomListLogging")) {

View file

@ -218,7 +218,12 @@ export class ImportanceAlgorithm extends OrderingAlgorithm {
} }
// noinspection JSMethodCanBeStatic // noinspection JSMethodCanBeStatic
private moveRoomIndexes(nRooms: number, fromCategory: NotificationColor, toCategory: NotificationColor, indices: ICategoryIndex) { private moveRoomIndexes(
nRooms: number,
fromCategory: NotificationColor,
toCategory: NotificationColor,
indices: ICategoryIndex,
) {
// We have to update the index of the category *after* the from/toCategory variables // We have to update the index of the category *after* the from/toCategory variables
// in order to update the indices correctly. Because the room is moving from/to those // in order to update the indices correctly. Because the room is moving from/to those
// categories, the next category's index will change - not the category we're modifying. // categories, the next category's index will change - not the category we're modifying.

View file

@ -56,7 +56,11 @@ export class NaturalAlgorithm extends OrderingAlgorithm {
// TODO: Optimize this to avoid useless operations: https://github.com/vector-im/riot-web/issues/14457 // TODO: Optimize this to avoid useless operations: https://github.com/vector-im/riot-web/issues/14457
// For example, we can skip updates to alphabetic (sometimes) and manually ordered tags // For example, we can skip updates to alphabetic (sometimes) and manually ordered tags
this.cachedOrderedRooms = await sortRoomsWithAlgorithm(this.cachedOrderedRooms, this.tagId, this.sortingAlgorithm); this.cachedOrderedRooms = await sortRoomsWithAlgorithm(
this.cachedOrderedRooms,
this.tagId,
this.sortingAlgorithm,
);
return true; return true;
} finally { } finally {

View file

@ -26,7 +26,7 @@ import { EffectiveMembership, getEffectiveMembership } from "../../../../utils/m
* useful to the user. * useful to the user.
*/ */
export class RecentAlgorithm implements IAlgorithm { export class RecentAlgorithm implements IAlgorithm {
public async sortRooms(rooms: Room[], _: TagID): Promise<Room[]> { public async sortRooms(rooms: Room[], tagID: TagID): Promise<Room[]> {
// We cache the timestamp lookup to avoid iterating forever on the timeline // We cache the timestamp lookup to avoid iterating forever on the timeline
// of events. This cache only survives a single sort though. // of events. This cache only survives a single sort though.
// We wouldn't need this if `.sort()` didn't constantly try and compare all // We wouldn't need this if `.sort()` didn't constantly try and compare all

View file

@ -1264,11 +1264,21 @@
resolved "https://registry.yarnpkg.com/@types/classnames/-/classnames-2.2.10.tgz#cc658ca319b6355399efc1f5b9e818f1a24bf999" resolved "https://registry.yarnpkg.com/@types/classnames/-/classnames-2.2.10.tgz#cc658ca319b6355399efc1f5b9e818f1a24bf999"
integrity sha512-1UzDldn9GfYYEsWWnn/P4wkTlkZDH7lDb0wBMGbtIQc9zXEQq7FlKBdZUn6OBqD8sKZZ2RQO2mAjGpXiDGoRmQ== integrity sha512-1UzDldn9GfYYEsWWnn/P4wkTlkZDH7lDb0wBMGbtIQc9zXEQq7FlKBdZUn6OBqD8sKZZ2RQO2mAjGpXiDGoRmQ==
"@types/color-name@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
"@types/counterpart@^0.18.1": "@types/counterpart@^0.18.1":
version "0.18.1" version "0.18.1"
resolved "https://registry.yarnpkg.com/@types/counterpart/-/counterpart-0.18.1.tgz#b1b784d9e54d9879f0a8cb12f2caedab65430fe8" resolved "https://registry.yarnpkg.com/@types/counterpart/-/counterpart-0.18.1.tgz#b1b784d9e54d9879f0a8cb12f2caedab65430fe8"
integrity sha512-PRuFlBBkvdDOtxlIASzTmkEFar+S66Ek48NVVTWMUjtJAdn5vyMSN8y6IZIoIymGpR36q2nZbIYazBWyFxL+IQ== integrity sha512-PRuFlBBkvdDOtxlIASzTmkEFar+S66Ek48NVVTWMUjtJAdn5vyMSN8y6IZIoIymGpR36q2nZbIYazBWyFxL+IQ==
"@types/eslint-visitor-keys@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==
"@types/fbemitter@*": "@types/fbemitter@*":
version "2.0.32" version "2.0.32"
resolved "https://registry.yarnpkg.com/@types/fbemitter/-/fbemitter-2.0.32.tgz#8ed204da0f54e9c8eaec31b1eec91e25132d082c" resolved "https://registry.yarnpkg.com/@types/fbemitter/-/fbemitter-2.0.32.tgz#8ed204da0f54e9c8eaec31b1eec91e25132d082c"
@ -5779,7 +5789,7 @@ lodash.sortby@^4.7.0:
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.2.1: lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.2.1:
version "4.17.19" version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==