Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

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

Merged
merged 3 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ module.exports = {
rules: {
// temporary disabled
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",

// Things we do that break the ideal style
"prefer-promise-reject-errors": "off",
Expand Down Expand Up @@ -157,6 +156,14 @@ module.exports = {
"@typescript-eslint/no-var-requires": "off",
},
},
{
files: ["test/**/*.{ts,tsx}", "cypress/**/*.ts"],
rules: {
// We don't need super strict typing in test utilities
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
},
},
],
settings: {
react: {
Expand Down
2 changes: 1 addition & 1 deletion src/@types/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function polyfillTouchEvent() {
public get scale(): number {
return 0.0;
}
constructor(eventType: string, params?: any) {
public constructor(eventType: string, params?: any) {
super(eventType, params);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/@types/worker-loader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

declare module "*.worker.ts" {
class WebpackWorker extends Worker {
constructor();
public constructor();
}

export default WebpackWorker;
Expand Down
2 changes: 1 addition & 1 deletion src/AddThreepid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class AddThreepid {
private clientSecret: string;
private bind: boolean;

constructor() {
public constructor() {
this.clientSecret = MatrixClientPeg.get().generateClientSecret();
}

Expand Down
6 changes: 3 additions & 3 deletions src/AsyncWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class AsyncWrapper extends React.Component<IProps, IState> {
error: null,
};

componentDidMount() {
public componentDidMount() {
// XXX: temporary logging to try to diagnose
// https://github.com/vector-im/element-web/issues/3148
logger.log("Starting load of AsyncWrapper for modal");
Expand All @@ -69,15 +69,15 @@ export default class AsyncWrapper extends React.Component<IProps, IState> {
});
}

componentWillUnmount() {
public componentWillUnmount() {
this.unmounted = true;
}

private onWrapperCancelClick = () => {
this.props.onFinished(false);
};

render() {
public render() {
if (this.state.component) {
const Component = this.state.component;
return <Component {...this.props} />;
Expand Down
2 changes: 1 addition & 1 deletion src/BasePlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default abstract class BasePlatform {
protected notificationCount = 0;
protected errorDidOccur = false;

constructor() {
public constructor() {
dis.register(this.onAction);
this.startUpdateCheck = this.startUpdateCheck.bind(this);
}
Expand Down
2 changes: 1 addition & 1 deletion src/BlurhashEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class BlurhashEncoder {
private seq = 0;
private pendingDeferredMap = new Map<number, IDeferred<string>>();

constructor() {
public constructor() {
this.worker = new BlurhashWorker();
this.worker.onmessage = this.onMessage;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ContentMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ export default class ContentMessages {
});
}

static sharedInstance() {
public static sharedInstance() {
if (window.mxContentMessages === undefined) {
window.mxContentMessages = new ContentMessages();
}
Expand Down
8 changes: 4 additions & 4 deletions src/DecryptionFailureTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { PosthogAnalytics } from "./PosthogAnalytics";
export class DecryptionFailure {
public readonly ts: number;

constructor(public readonly failedEventId: string, public readonly errorCode: string) {
public constructor(public readonly failedEventId: string, public readonly errorCode: string) {
this.ts = Date.now();
}
}
Expand Down Expand Up @@ -87,14 +87,14 @@ export class DecryptionFailureTracker {
public trackInterval: number = null;

// Spread the load on `Analytics` by tracking at a low frequency, `TRACK_INTERVAL_MS`.
static TRACK_INTERVAL_MS = 60000;
public static TRACK_INTERVAL_MS = 60000;

// Call `checkFailures` every `CHECK_INTERVAL_MS`.
static CHECK_INTERVAL_MS = 5000;
public static CHECK_INTERVAL_MS = 5000;

// Give events a chance to be decrypted by waiting `GRACE_PERIOD_MS` before counting
// the failure in `failureCounts`.
static GRACE_PERIOD_MS = 4000;
public static GRACE_PERIOD_MS = 4000;

/**
* Create a new DecryptionFailureTracker.
Expand Down
2 changes: 1 addition & 1 deletion src/HtmlUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ const topicSanitizeHtmlParams: IExtendedSanitizeOptions = {
};

abstract class BaseHighlighter<T extends React.ReactNode> {
constructor(public highlightClass: string, public highlightLink: string) {}
public constructor(public highlightClass: string, public highlightLink: string) {}

/**
* apply the highlights to a section of text
Expand Down
2 changes: 1 addition & 1 deletion src/IdentityAuthClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class IdentityAuthClient {
* When provided, this class will operate solely within memory, refusing to
* persist any information such as tokens. Default null (not provided).
*/
constructor(identityUrl?: string) {
public constructor(identityUrl?: string) {
if (identityUrl) {
// XXX: We shouldn't have to create a whole new MatrixClient just to
// do identity server auth. The functions don't take an identity URL
Expand Down
18 changes: 9 additions & 9 deletions src/KeyBindingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class KeyBindingsManager {
* To overwrite the default key bindings add a new providers before the default provider, e.g. a provider for
* customized key bindings.
*/
bindingsProviders: IKeyBindingsProvider[] = [defaultBindingsProvider];
public bindingsProviders: IKeyBindingsProvider[] = [defaultBindingsProvider];

/**
* Finds a matching KeyAction for a given KeyboardEvent
Expand All @@ -124,56 +124,56 @@ export class KeyBindingsManager {
return undefined;
}

getMessageComposerAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
public getMessageComposerAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
return this.getAction(
this.bindingsProviders.map((it) => it.getMessageComposerBindings),
ev,
);
}

getAutocompleteAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
public getAutocompleteAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
return this.getAction(
this.bindingsProviders.map((it) => it.getAutocompleteBindings),
ev,
);
}

getRoomListAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
public getRoomListAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
return this.getAction(
this.bindingsProviders.map((it) => it.getRoomListBindings),
ev,
);
}

getRoomAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
public getRoomAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
return this.getAction(
this.bindingsProviders.map((it) => it.getRoomBindings),
ev,
);
}

getNavigationAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
public getNavigationAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
return this.getAction(
this.bindingsProviders.map((it) => it.getNavigationBindings),
ev,
);
}

getAccessibilityAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
public getAccessibilityAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
return this.getAction(
this.bindingsProviders.map((it) => it.getAccessibilityBindings),
ev,
);
}

getCallAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
public getCallAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
return this.getAction(
this.bindingsProviders.map((it) => it.getCallBindings),
ev,
);
}

getLabsAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
public getLabsAction(ev: KeyboardEvent | React.KeyboardEvent): KeyBindingAction | undefined {
return this.getAction(
this.bindingsProviders.map((it) => it.getLabsBindings),
ev,
Expand Down
2 changes: 1 addition & 1 deletion src/Login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class Login {
private defaultDeviceDisplayName: string;
private tempClient: MatrixClient;

constructor(hsUrl: string, isUrl: string, fallbackHsUrl?: string, opts?: ILoginOptions) {
public constructor(hsUrl: string, isUrl: string, fallbackHsUrl?: string, opts?: ILoginOptions) {
this.hsUrl = hsUrl;
this.isUrl = isUrl;
this.fallbackHsUrl = fallbackHsUrl;
Expand Down
8 changes: 4 additions & 4 deletions src/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default class Markdown {
private input: string;
private parsed: commonmark.Node;

constructor(input: string) {
public constructor(input: string) {
this.input = input;

const parser = new commonmark.Parser();
Expand Down Expand Up @@ -234,7 +234,7 @@ export default class Markdown {
return parsed;
}

isPlainText(): boolean {
public isPlainText(): boolean {
const walker = this.parsed.walker();

let ev: commonmark.NodeWalkingStep;
Expand All @@ -257,7 +257,7 @@ export default class Markdown {
return true;
}

toHTML({ externalLinks = false } = {}): string {
public toHTML({ externalLinks = false } = {}): string {
const renderer = new commonmark.HtmlRenderer({
safe: false,

Expand Down Expand Up @@ -344,7 +344,7 @@ export default class Markdown {
* N.B. this does **NOT** render arbitrary MD to plain text - only MD
* which has no formatting. Otherwise it emits HTML(!).
*/
toPlaintext(): string {
public toPlaintext(): string {
const renderer = new commonmark.HtmlRenderer({ safe: false });

renderer.paragraph = function (node: commonmark.Node, entering: boolean) {
Expand Down
2 changes: 1 addition & 1 deletion src/NodeAnimator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class NodeAnimator extends React.Component<IProps> {
startStyles: [],
};

constructor(props: IProps) {
public constructor(props: IProps) {
super(props);

this.updateChildren(this.props.children);
Expand Down
2 changes: 1 addition & 1 deletion src/PasswordReset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class PasswordReset {
* @param {string} homeserverUrl The URL to the HS which has the account to reset.
* @param {string} identityUrl The URL to the IS which has linked the email -> mxid mapping.
*/
constructor(homeserverUrl: string, identityUrl: string) {
public constructor(homeserverUrl: string, identityUrl: string) {
this.client = createClient({
baseUrl: homeserverUrl,
idBaseUrl: identityUrl,
Expand Down
2 changes: 1 addition & 1 deletion src/PosthogAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class PosthogAnalytics {
return this._instance;
}

constructor(private readonly posthog: PostHog) {
public constructor(private readonly posthog: PostHog) {
const posthogConfig = SdkConfig.getObject("posthog");
if (posthogConfig) {
this.posthog.init(posthogConfig.get("project_api_key"), {
Expand Down
8 changes: 4 additions & 4 deletions src/PosthogTrackers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,20 @@ export default class PosthogTrackers {
}

export class PosthogScreenTracker extends PureComponent<{ screenName: ScreenName }> {
componentDidMount() {
public componentDidMount() {
PosthogTrackers.instance.trackOverride(this.props.screenName);
}

componentDidUpdate() {
public componentDidUpdate() {
// We do not clear the old override here so that we do not send the non-override screen as a transition
PosthogTrackers.instance.trackOverride(this.props.screenName);
}

componentWillUnmount() {
public componentWillUnmount() {
PosthogTrackers.instance.clearOverride(this.props.screenName);
}

render() {
public render() {
return null; // no need to render anything, we just need to hook into the React lifecycle
}
}
16 changes: 8 additions & 8 deletions src/ScalarAuthClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class ScalarAuthClient {
private termsInteractionCallback: TermsInteractionCallback;
private isDefaultManager: boolean;

constructor(private apiUrl: string, private uiUrl: string) {
public constructor(private apiUrl: string, private uiUrl: string) {
this.scalarToken = null;
// `undefined` to allow `startTermsFlow` to fallback to a default
// callback if this is unset.
Expand Down Expand Up @@ -72,22 +72,22 @@ export default class ScalarAuthClient {
return this.readTokenFromStore();
}

setTermsInteractionCallback(callback) {
public setTermsInteractionCallback(callback) {
this.termsInteractionCallback = callback;
}

connect(): Promise<void> {
public connect(): Promise<void> {
return this.getScalarToken().then((tok) => {
this.scalarToken = tok;
});
}

hasCredentials(): boolean {
public hasCredentials(): boolean {
return this.scalarToken != null; // undef or null
}

// Returns a promise that resolves to a scalar_token string
getScalarToken(): Promise<string> {
public getScalarToken(): Promise<string> {
const token = this.readToken();

if (!token) {
Expand Down Expand Up @@ -169,7 +169,7 @@ export default class ScalarAuthClient {
});
}

registerForToken(): Promise<string> {
public registerForToken(): Promise<string> {
// Get openid bearer token from the HS as the first part of our dance
return MatrixClientPeg.get()
.getOpenIdToken()
Expand Down Expand Up @@ -256,7 +256,7 @@ export default class ScalarAuthClient {
}
}

getScalarInterfaceUrlForRoom(room: Room, screen: string, id: string): string {
public getScalarInterfaceUrlForRoom(room: Room, screen: string, id: string): string {
const roomId = room.roomId;
const roomName = room.name;
let url = this.uiUrl;
Expand All @@ -273,7 +273,7 @@ export default class ScalarAuthClient {
return url;
}

getStarterLink(starterLinkUrl: string): string {
public getStarterLink(starterLinkUrl: string): string {
return starterLinkUrl + "?scalar_token=" + encodeURIComponent(this.scalarToken);
}
}
2 changes: 1 addition & 1 deletion src/SecurityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function isSecretStorageBeingAccessed(): boolean {
}

export class AccessCancelledError extends Error {
constructor() {
public constructor() {
super("Secret storage access canceled");
}
}
Expand Down
Loading