mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 09:59:55 +08:00
fix: add prefer-readonly rule (#5122)
This commit is contained in:
@@ -4,9 +4,11 @@ import { typesystem } from './typesystem';
|
||||
type MatcherData<Data, Type extends TType = TType> = { type: Type; data: Data };
|
||||
|
||||
export class Matcher<Data, Type extends TType = TType> {
|
||||
private list: MatcherData<Data, Type>[] = [];
|
||||
private readonly list: MatcherData<Data, Type>[] = [];
|
||||
|
||||
constructor(private _match?: (type: Type, target: TType) => boolean) {}
|
||||
constructor(
|
||||
private readonly _match?: (type: Type, target: TType) => boolean
|
||||
) {}
|
||||
|
||||
register(type: Type, data: Data) {
|
||||
this.list.push({ type, data });
|
||||
|
||||
@@ -92,8 +92,8 @@ export type ValueOfData<T extends DataDefine> = T extends DataDefine<infer R>
|
||||
|
||||
export class DataDefine<Data extends DataTypeShape = Record<string, unknown>> {
|
||||
constructor(
|
||||
private config: DataDefineConfig<Data>,
|
||||
private dataMap: Map<string, DataDefine>
|
||||
private readonly config: DataDefineConfig<Data>,
|
||||
private readonly dataMap: Map<string, DataDefine>
|
||||
) {}
|
||||
|
||||
create(data?: Data): TDataType<Data> {
|
||||
|
||||
@@ -5,8 +5,8 @@ import type { Map as YMap } from 'yjs';
|
||||
import { Doc as YDoc } from 'yjs';
|
||||
export class UserSetting {
|
||||
constructor(
|
||||
private workspace: Workspace,
|
||||
private userId: string
|
||||
private readonly workspace: Workspace,
|
||||
private readonly userId: string
|
||||
) {}
|
||||
|
||||
get setting(): YDoc {
|
||||
|
||||
@@ -13,7 +13,7 @@ const COLLECTIONS_TRASH_KEY = 'collections_trash';
|
||||
const SETTING_KEY = 'setting';
|
||||
|
||||
export class WorkspaceSetting {
|
||||
constructor(private workspace: Workspace) {}
|
||||
constructor(private readonly workspace: Workspace) {}
|
||||
|
||||
get doc() {
|
||||
return this.workspace.doc;
|
||||
|
||||
@@ -33,7 +33,7 @@ function pickAndBind<T extends object, U extends keyof T>(
|
||||
|
||||
class HelperProcessManager {
|
||||
ready: Promise<void>;
|
||||
#process: UtilityProcess;
|
||||
readonly #process: UtilityProcess;
|
||||
|
||||
// a rpc server for the main process -> helper process
|
||||
rpc?: _AsyncVersionOf<HelperToMain>;
|
||||
|
||||
@@ -29,7 +29,7 @@ const hrefRegExp = /\/tag\/([^/]+)$/;
|
||||
export class CustomGitHubProvider extends BaseGitHubProvider<GithubUpdateInfo> {
|
||||
constructor(
|
||||
options: CustomPublishOptions,
|
||||
private updater: AppUpdater,
|
||||
private readonly updater: AppUpdater,
|
||||
runtimeOptions: ProviderRuntimeOptions
|
||||
) {
|
||||
super(options as unknown as GithubOptions, 'github.com', runtimeOptions);
|
||||
|
||||
@@ -22,7 +22,7 @@ interface MessagePortLike {
|
||||
}
|
||||
|
||||
export class MessageEventChannel implements EventBasedChannel {
|
||||
constructor(private worker: MessagePortLike) {}
|
||||
constructor(private readonly worker: MessagePortLike) {}
|
||||
|
||||
on(listener: (data: unknown) => void) {
|
||||
const f = (data: unknown) => {
|
||||
|
||||
@@ -54,7 +54,7 @@ export class TraceReporter {
|
||||
|
||||
private spansCache = new Array<TraceSpan>();
|
||||
private reportIntervalId: number | undefined | NodeJS.Timeout;
|
||||
private reportInterval = 60_000;
|
||||
private readonly reportInterval = 60_000;
|
||||
|
||||
private static instance: TraceReporter;
|
||||
|
||||
@@ -175,7 +175,7 @@ export class TraceReporter {
|
||||
};
|
||||
}
|
||||
|
||||
private initTraceReport = () => {
|
||||
private readonly initTraceReport = () => {
|
||||
if (!this.reportIntervalId && TraceReporter.shouldReportTrace) {
|
||||
if (typeof window !== 'undefined') {
|
||||
this.reportIntervalId = window.setInterval(
|
||||
@@ -191,7 +191,7 @@ export class TraceReporter {
|
||||
}
|
||||
};
|
||||
|
||||
private reportHandler = () => {
|
||||
private readonly reportHandler = () => {
|
||||
if (this.spansCache.length <= 0) {
|
||||
clearInterval(this.reportIntervalId);
|
||||
this.reportIntervalId = undefined;
|
||||
|
||||
@@ -5,8 +5,8 @@ const logger = new DebugLogger('affine:blob-engine');
|
||||
|
||||
export class BlobEngine {
|
||||
constructor(
|
||||
private local: BlobStorage,
|
||||
private remotes: BlobStorage[]
|
||||
private readonly local: BlobStorage,
|
||||
private readonly remotes: BlobStorage[]
|
||||
) {}
|
||||
|
||||
get storages() {
|
||||
|
||||
@@ -15,12 +15,12 @@ interface SyncUpdateSender {
|
||||
* - retryable, allow retry when previous sync request failed but with retry flag been set to true
|
||||
*/
|
||||
export class BatchSyncSender {
|
||||
private buffered: Uint8Array[] = [];
|
||||
private readonly buffered: Uint8Array[] = [];
|
||||
private job: Promise<void> | null = null;
|
||||
private started = true;
|
||||
|
||||
constructor(
|
||||
private guid: string,
|
||||
private readonly guid: string,
|
||||
private readonly rawSender: SyncUpdateSender
|
||||
) {}
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ export class SyncEngine {
|
||||
private abort = new AbortController();
|
||||
|
||||
constructor(
|
||||
private rootDoc: Doc,
|
||||
private local: Storage,
|
||||
private remotes: Storage[]
|
||||
private readonly rootDoc: Doc,
|
||||
private readonly local: Storage,
|
||||
private readonly remotes: Storage[]
|
||||
) {
|
||||
this._status = {
|
||||
step: SyncEngineStep.Stopped,
|
||||
|
||||
@@ -69,8 +69,8 @@ export class SyncPeer {
|
||||
logger = new DebugLogger('affine:sync-peer:' + this.name);
|
||||
|
||||
constructor(
|
||||
private rootDoc: Doc,
|
||||
private storage: Storage
|
||||
private readonly rootDoc: Doc,
|
||||
private readonly storage: Storage
|
||||
) {
|
||||
this.logger.debug('peer start');
|
||||
|
||||
@@ -150,7 +150,7 @@ export class SyncPeer {
|
||||
}
|
||||
}
|
||||
|
||||
private state: {
|
||||
private readonly state: {
|
||||
connectedDocs: Map<string, Doc>;
|
||||
pushUpdatesQueue: AsyncQueue<{
|
||||
docId: string;
|
||||
|
||||
Reference in New Issue
Block a user