Skip to content

Commit

Permalink
Add lint for unused locals (#8007)
Browse files Browse the repository at this point in the history
  • Loading branch information
jryans committed Mar 9, 2022
1 parent c7dfaa8 commit 6569120
Show file tree
Hide file tree
Showing 25 changed files with 46 additions and 115 deletions.
6 changes: 2 additions & 4 deletions src/ActiveRoomObserver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 New Vector Ltd
Copyright 2017 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { EventSubscription } from 'fbemitter';
import { logger } from "matrix-js-sdk/src/logger";

import RoomViewStore from './stores/RoomViewStore';
Expand All @@ -33,11 +32,10 @@ type Listener = (isActive: boolean) => void;
export class ActiveRoomObserver {
private listeners: {[key: string]: Listener[]} = {};
private _activeRoomId = RoomViewStore.getRoomId();
private readonly roomStoreToken: EventSubscription;

constructor() {
// TODO: We could self-destruct when the last listener goes away, or at least stop listening.
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
RoomViewStore.addListener(this.onRoomViewStoreUpdate);
}

public get activeRoomId(): string {
Expand Down
3 changes: 1 addition & 2 deletions src/Analytics.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright 2017 Michael Telatynski <7t3chguy@gmail.com>
Copyright 2020 The Matrix.org Foundation C.I.C.
Copyright 2020 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -166,7 +166,6 @@ const HEARTBEAT_INTERVAL = 30 * 1000; // seconds

export class Analytics {
private baseUrl: URL = null;
private siteId: string = null;
private visitVariables: Record<number, [string, string]> = {}; // {[id: number]: [name: string, value: string]}
private firstPage = true;
private heartbeatIntervalID: number = null;
Expand Down
8 changes: 2 additions & 6 deletions src/CallHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017, 2018 New Vector Ltd
Copyright 2019 - 2021 The Matrix.org Foundation C.I.C.
Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -125,10 +125,6 @@ export default class CallHandler extends EventEmitter {
private supportsPstnProtocol = null;
private pstnSupportPrefixed = null; // True if the server only support the prefixed pstn protocol
private supportsSipNativeVirtual = null; // im.vector.protocol.sip_virtual and im.vector.protocol.sip_native
private pstnSupportCheckTimer: number;
// For rooms we've been invited to, true if they're from virtual user, false if we've checked and they aren't.
private invitedRoomsAreVirtual = new Map<string, boolean>();
private invitedRoomCheckInProgress = false;

// Map of the asserted identity users after we've looked them up using the API.
// We need to be be able to determine the mapped room synchronously, so we
Expand Down Expand Up @@ -255,7 +251,7 @@ export default class CallHandler extends EventEmitter {
logger.log("Failed to check for protocol support and no retries remain: assuming no support", e);
} else {
logger.log("Failed to check for protocol support: will retry", e);
this.pstnSupportCheckTimer = setTimeout(() => {
setTimeout(() => {
this.checkProtocols(maxTries - 1);
}, 10000);
}
Expand Down
4 changes: 1 addition & 3 deletions src/PasswordReset.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,6 @@ import { _t } from './languageHandler';
export default class PasswordReset {
private client: MatrixClient;
private clientSecret: string;
private identityServerDomain: string;
private password: string;
private sessionId: string;

Expand All @@ -44,7 +43,6 @@ export default class PasswordReset {
idBaseUrl: identityUrl,
});
this.clientSecret = this.client.generateClientSecret();
this.identityServerDomain = identityUrl ? identityUrl.split("://")[1] : null;
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/audio/PlaybackQueue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 The Matrix.org Foundation C.I.C.
Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixClient } from "matrix-js-sdk/src/client";
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { Room } from "matrix-js-sdk/src/models/room";
import { EventType } from "matrix-js-sdk/src/@types/event";
Expand Down Expand Up @@ -49,7 +48,7 @@ export class PlaybackQueue {
private currentPlaybackId: string; // event ID, broken out from above for ease of use
private recentFullPlays = new Set<string>(); // event IDs

constructor(private client: MatrixClient, private room: Room) {
constructor(private room: Room) {
this.loadClocks();

RoomViewStore.addListener(() => {
Expand All @@ -71,7 +70,7 @@ export class PlaybackQueue {
if (PlaybackQueue.queues.has(room.roomId)) {
return PlaybackQueue.queues.get(room.roomId);
}
const queue = new PlaybackQueue(cli, room);
const queue = new PlaybackQueue(room);
PlaybackQueue.queues.set(room.roomId, queue);
return queue;
}
Expand Down
4 changes: 0 additions & 4 deletions src/components/structures/InteractiveAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ export default class InteractiveAuthComponent extends React.Component<IProps, IS
}
};

private tryContinue = (): void => {
this.stageComponent.current?.tryContinue?.();
};

private authStateUpdated = (stageType: AuthType, stageState: IStageStatus): void => {
const oldStage = this.state.authStage;
this.setState({
Expand Down
5 changes: 3 additions & 2 deletions src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2015 - 2021 The Matrix.org Foundation C.I.C.
Copyright 2015 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -58,6 +58,7 @@ import AudioFeedArrayForCall from '../views/voip/AudioFeedArrayForCall';
import { OwnProfileStore } from '../../stores/OwnProfileStore';
import { UPDATE_EVENT } from "../../stores/AsyncStore";
import RoomView from './RoomView';
import type { RoomView as RoomViewType } from './RoomView';
import ToastContainer from './ToastContainer';
import MyGroups from "./MyGroups";
import UserView from "./UserView";
Expand Down Expand Up @@ -139,7 +140,7 @@ class LoggedInView extends React.Component<IProps, IState> {
static displayName = 'LoggedInView';

protected readonly _matrixClient: MatrixClient;
protected readonly _roomView: React.RefObject<any>;
protected readonly _roomView: React.RefObject<RoomViewType>;
protected readonly _resizeContainer: React.RefObject<HTMLDivElement>;
protected readonly resizeHandler: React.RefObject<HTMLDivElement>;
protected layoutWatcherRef: string;
Expand Down
3 changes: 0 additions & 3 deletions src/components/structures/MatrixChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
private firstSyncPromise: IDeferred<void>;

private screenAfterLogin?: IScreen;
private pageChanging: boolean;
private tokenLogin?: boolean;
private accountPassword?: string;
private accountPasswordTimer?: number;
Expand Down Expand Up @@ -284,8 +283,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
this.prevWindowWidth = UIStore.instance.windowWidth || 1000;
UIStore.instance.on(UI_EVENTS.Resize, this.handleResize);

this.pageChanging = false;

// For PersistentElement
this.state.resizeNotifier.on("middlePanelResized", this.dispatchTimelineResize);

Expand Down
1 change: 0 additions & 1 deletion src/components/structures/RoomDirectory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ interface IState {

@replaceableComponent("structures.RoomDirectory")
export default class RoomDirectory extends React.Component<IProps, IState> {
private readonly startTime: number;
private unmounted = false;
private nextBatch: string = null;
private filterTimeout: number;
Expand Down
4 changes: 2 additions & 2 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1681,8 +1681,8 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
*
* We pass it down to the scroll panel.
*/
private handleScrollKey = ev => {
let panel;
public handleScrollKey = ev => {
let panel: ScrollPanel | TimelinePanel;
if (this.searchResultsPanel.current) {
panel = this.searchResultsPanel.current;
} else if (this.messagePanel) {
Expand Down
5 changes: 0 additions & 5 deletions src/components/views/auth/InteractiveAuthEntryComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,6 @@ export class TermsAuthEntry extends React.Component<ITermsAuthEntryProps, ITerms
this.props.onPhaseChange(DEFAULT_PHASE);
}

public tryContinue = () => {
this.trySubmit();
};

private togglePolicy(policyId: string) {
const newToggles = {};
for (const policy of this.state.policies) {
Expand Down Expand Up @@ -832,7 +828,6 @@ export interface IStageComponentProps extends IAuthEntryProps {
}

export interface IStageComponent extends React.ComponentClass<React.PropsWithRef<IStageComponentProps>> {
tryContinue?(): void;
attemptFailed?(): void;
focus?(): void;
}
Expand Down
7 changes: 1 addition & 6 deletions src/components/views/dialogs/LogoutDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright 2018, 2019 New Vector Ltd
Copyright 2020 The Matrix.org Foundation C.I.C.
Copyright 2020 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -81,11 +81,6 @@ export default class LogoutDialog extends React.Component<IProps, IState> {
}
}

private onSettingsLinkClick = (): void => {
// close dialog
this.props.onFinished(true);
};

private onExportE2eKeysClicked = (): void => {
Modal.createTrackedDialogAsync('Export E2E Keys', '',
import(
Expand Down
7 changes: 4 additions & 3 deletions src/components/views/settings/Notifications.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2016 - 2021 The Matrix.org Foundation C.I.C.
Copyright 2016 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,6 +28,7 @@ import {
VectorPushRulesDefinitions,
VectorState,
} from "../../../notifications";
import type { VectorPushRuleDefinition } from "../../../notifications";
import { _t, TranslatedString } from "../../../languageHandler";
import LabelledToggleSwitch from "../elements/LabelledToggleSwitch";
import SettingsStore from "../../../settings/SettingsStore";
Expand Down Expand Up @@ -209,7 +210,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
for (const category of vectorCategories) {
preparedNewState.vectorPushRules[category] = [];
for (const rule of defaultRules[category]) {
const definition = VectorPushRulesDefinitions[rule.rule_id];
const definition: VectorPushRuleDefinition = VectorPushRulesDefinitions[rule.rule_id];
const vectorState = definition.ruleToVectorState(rule);
preparedNewState.vectorPushRules[category].push({
ruleId: rule.rule_id,
Expand Down Expand Up @@ -356,7 +357,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
}
}
} else {
const definition = VectorPushRulesDefinitions[rule.ruleId];
const definition: VectorPushRuleDefinition = VectorPushRulesDefinitions[rule.ruleId];
const actions = definition.vectorStateToActions[checkedState];
if (!actions) {
await cli.setPushRuleEnabled('global', rule.rule.kind, rule.rule.rule_id, false);
Expand Down
14 changes: 1 addition & 13 deletions src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2022 The Matrix.org Foundation C.I.C.
Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -100,18 +100,6 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
});
};

private showSpoiler = (event) => {
const target = event.target;
target.innerHTML = target.getAttribute('data-spoiler');

const range = document.createRange();
range.selectNodeContents(target);

const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
};

private renderLegal() {
const tocLinks = SdkConfig.get().terms_and_conditions_links;
if (!tocLinks) return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
Copyright 2019 New Vector Ltd
Copyright 2020 The Matrix.org Foundation C.I.C.
Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -147,14 +146,6 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
});
};

private onGoToUserProfileClick = (): void => {
dis.dispatch({
action: 'view_user_info',
userId: MatrixClientPeg.get().getUserId(),
});
this.props.closeSettingsFn();
};

private onUserUnignored = async (userId: string): Promise<void> => {
const { ignoredUserIds, waitingUnignored } = this.state;
const currentlyIgnoredUserIds = ignoredUserIds.filter(e => !waitingUnignored.includes(e));
Expand Down
4 changes: 2 additions & 2 deletions src/components/views/spaces/SpacePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 The Matrix.org Foundation C.I.C.
Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -205,7 +205,7 @@ const CreateSpaceButton = ({
}: Pick<IInnerSpacePanelProps, "isPanelCollapsed" | "setPanelCollapsed">) => {
// We don't need the handle as we position the menu in a constant location
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu<void>();
const [menuDisplayed, _handle, openMenu, closeMenu] = useContextMenu<void>();

useEffect(() => {
if (!isPanelCollapsed && menuDisplayed) {
Expand Down
4 changes: 1 addition & 3 deletions src/components/views/voip/CallViewForRoom.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Copyright 2020 - 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,8 +42,6 @@ interface IState {
*/
@replaceableComponent("views.voip.CallViewForRoom")
export default class CallViewForRoom extends React.Component<IProps, IState> {
private dispatcherRef: string;

constructor(props: IProps) {
super(props);
this.state = {
Expand Down
Loading

0 comments on commit 6569120

Please sign in to comment.