mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
chore: fix eslint in blocksuite (#9232)
This commit is contained in:
@@ -218,7 +218,7 @@ export class ASTWalker<ONode extends object, TNode extends object | never> {
|
||||
|
||||
private _leave: WalkerFn<ONode, TNode> | undefined;
|
||||
|
||||
private _visit = async (o: NodeProps<ONode>) => {
|
||||
private readonly _visit = async (o: NodeProps<ONode>) => {
|
||||
if (!o.node) return;
|
||||
this.context._skipChildrenNum = 0;
|
||||
this.context._skip = false;
|
||||
@@ -277,7 +277,7 @@ export class ASTWalker<ONode extends object, TNode extends object | never> {
|
||||
}
|
||||
};
|
||||
|
||||
private context: ASTWalkerContext<TNode>;
|
||||
private readonly context: ASTWalkerContext<TNode>;
|
||||
|
||||
setEnter = (fn: WalkerFn<ONode, TNode>) => {
|
||||
this._enter = fn;
|
||||
|
||||
@@ -5,7 +5,7 @@ export class ASTWalkerContext<TNode extends object> {
|
||||
|
||||
private _globalContext: Record<string, unknown> = Object.create(null);
|
||||
|
||||
private _stack: {
|
||||
private readonly _stack: {
|
||||
node: TNode;
|
||||
prop: Keyof<TNode>;
|
||||
context: Record<string, unknown>;
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ReactiveYArray extends BaseReactiveYData<
|
||||
unknown[],
|
||||
YArray<unknown>
|
||||
> {
|
||||
private _observer = (event: YArrayEvent<unknown>) => {
|
||||
private readonly _observer = (event: YArrayEvent<unknown>) => {
|
||||
this._onObserve(event, () => {
|
||||
let retain = 0;
|
||||
event.changes.delta.forEach(change => {
|
||||
@@ -159,7 +159,7 @@ export class ReactiveYArray extends BaseReactiveYData<
|
||||
}
|
||||
|
||||
export class ReactiveYMap extends BaseReactiveYData<UnRecord, YMap<unknown>> {
|
||||
private _observer = (event: YMapEvent<unknown>) => {
|
||||
private readonly _observer = (event: YMapEvent<unknown>) => {
|
||||
this._onObserve(event, () => {
|
||||
event.keysChanged.forEach(key => {
|
||||
const type = event.changes.keys.get(key);
|
||||
|
||||
@@ -16,9 +16,9 @@ export type DeltaOperation = {
|
||||
export type OnTextChange = (data: Y.Text) => void;
|
||||
|
||||
export class Text {
|
||||
private _deltas$: Signal<DeltaOperation[]>;
|
||||
private readonly _deltas$: Signal<DeltaOperation[]>;
|
||||
|
||||
private _length$: Signal<number>;
|
||||
private readonly _length$: Signal<number>;
|
||||
|
||||
private _onChange?: OnTextChange;
|
||||
|
||||
|
||||
@@ -155,14 +155,14 @@ export class BlockModel<
|
||||
Props extends object = object,
|
||||
PropsSignal extends object = SignaledProps<Props>,
|
||||
> extends MagicProps()<PropsSignal> {
|
||||
private _children = signal<string[]>([]);
|
||||
private readonly _children = signal<string[]>([]);
|
||||
|
||||
/**
|
||||
* @deprecated use doc instead
|
||||
*/
|
||||
page!: Doc;
|
||||
|
||||
private _childModels = computed(() => {
|
||||
private readonly _childModels = computed(() => {
|
||||
const value: BlockModel[] = [];
|
||||
this._children.value.forEach(id => {
|
||||
const block = this.page.getBlock$(id);
|
||||
@@ -173,9 +173,9 @@ export class BlockModel<
|
||||
return value;
|
||||
});
|
||||
|
||||
private _onCreated: Disposable;
|
||||
private readonly _onCreated: Disposable;
|
||||
|
||||
private _onDeleted: Disposable;
|
||||
private readonly _onDeleted: Disposable;
|
||||
|
||||
childMap = computed(() =>
|
||||
this._children.value.reduce((map, id, index) => {
|
||||
|
||||
@@ -47,27 +47,27 @@ export class BlockCollection {
|
||||
|
||||
private readonly _docCRUD: DocCRUD;
|
||||
|
||||
private _docMap = {
|
||||
private readonly _docMap = {
|
||||
undefined: new Map<string, Doc>(),
|
||||
true: new Map<string, Doc>(),
|
||||
false: new Map<string, Doc>(),
|
||||
};
|
||||
|
||||
// doc/space container.
|
||||
private _handleYEvents = (events: Y.YEvent<YBlock | Y.Text>[]) => {
|
||||
private readonly _handleYEvents = (events: Y.YEvent<YBlock | Y.Text>[]) => {
|
||||
events.forEach(event => this._handleYEvent(event));
|
||||
};
|
||||
|
||||
private _history!: Y.UndoManager;
|
||||
|
||||
private _historyObserver = () => {
|
||||
private readonly _historyObserver = () => {
|
||||
this._updateCanUndoRedoSignals();
|
||||
this.slots.historyUpdated.emit();
|
||||
};
|
||||
|
||||
private readonly _idGenerator: IdGenerator;
|
||||
|
||||
private _initSubDoc = () => {
|
||||
private readonly _initSubDoc = () => {
|
||||
let subDoc = this.rootDoc.spaces.get(this.id);
|
||||
if (!subDoc) {
|
||||
subDoc = new Y.Doc({
|
||||
@@ -86,9 +86,13 @@ export class BlockCollection {
|
||||
|
||||
private _loaded!: boolean;
|
||||
|
||||
private _onLoadSlot = new Slot();
|
||||
private readonly _onLoadSlot = new Slot();
|
||||
|
||||
private _onSubdocEvent = ({ loaded }: { loaded: Set<Y.Doc> }): void => {
|
||||
private readonly _onSubdocEvent = ({
|
||||
loaded,
|
||||
}: {
|
||||
loaded: Set<Y.Doc>;
|
||||
}): void => {
|
||||
const result = Array.from(loaded).find(
|
||||
doc => doc.guid === this._ySpaceDoc.guid
|
||||
);
|
||||
@@ -105,7 +109,7 @@ export class BlockCollection {
|
||||
|
||||
private _shouldTransact = true;
|
||||
|
||||
private _updateCanUndoRedoSignals = () => {
|
||||
private readonly _updateCanUndoRedoSignals = () => {
|
||||
const canRedo = this.readonly ? false : this._history.canRedo();
|
||||
const canUndo = this.readonly ? false : this._history.canUndo();
|
||||
if (this._canRedo$.peek() !== canRedo) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { BlockOptions, YBlock } from './types.js';
|
||||
export * from './types.js';
|
||||
|
||||
export class Block {
|
||||
private _syncController: SyncController;
|
||||
private readonly _syncController: SyncController;
|
||||
|
||||
blockViewType: BlockViewType = BlockViewType.Display;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ type DocOptions = {
|
||||
};
|
||||
|
||||
export class Doc {
|
||||
private _runQuery = (block: Block) => {
|
||||
private readonly _runQuery = (block: Block) => {
|
||||
runQuery(this._query, block);
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export type DocCollectionMetaState = {
|
||||
};
|
||||
|
||||
export class DocCollectionMeta {
|
||||
private _handleDocCollectionMetaEvents = (
|
||||
private readonly _handleDocCollectionMetaEvents = (
|
||||
events: Y.YEvent<Y.Array<unknown> | Y.Text | Y.Map<unknown>>[]
|
||||
) => {
|
||||
events.forEach(e => {
|
||||
|
||||
@@ -32,9 +32,9 @@ export interface AwarenessEvent<
|
||||
}
|
||||
|
||||
export class AwarenessStore<Flags extends BlockSuiteFlags = BlockSuiteFlags> {
|
||||
private _flags: Signal<Flags>;
|
||||
private readonly _flags: Signal<Flags>;
|
||||
|
||||
private _onAwarenessChange = (diff: {
|
||||
private readonly _onAwarenessChange = (diff: {
|
||||
added: number[];
|
||||
removed: number[];
|
||||
updated: number[];
|
||||
|
||||
@@ -10,7 +10,7 @@ export type BlockSuiteDocAllowedValue =
|
||||
export type BlockSuiteDocData = Record<string, BlockSuiteDocAllowedValue>;
|
||||
|
||||
export class BlockSuiteDoc extends Y.Doc {
|
||||
private _spaces: Y.Map<Y.Doc> = this.getMap('spaces');
|
||||
private readonly _spaces: Y.Map<Y.Doc> = this.getMap('spaces');
|
||||
|
||||
get spaces() {
|
||||
return this._spaces;
|
||||
|
||||
Reference in New Issue
Block a user