chore: fix eslint in blocksuite (#9232)

This commit is contained in:
Saul-Mirone
2024-12-20 16:48:10 +00:00
parent bfcc53dc1f
commit 3a82da0e5b
269 changed files with 935 additions and 842 deletions

View File

@@ -91,7 +91,7 @@ export class MobileKanbanCard extends SignalWatcher(
) {
static override styles = styles;
private clickCenterPeek = (e: MouseEvent) => {
private readonly clickCenterPeek = (e: MouseEvent) => {
e.stopPropagation();
this.dataViewEle.openDetailPanel({
view: this.view,
@@ -99,7 +99,7 @@ export class MobileKanbanCard extends SignalWatcher(
});
};
private clickMore = (e: MouseEvent) => {
private readonly clickMore = (e: MouseEvent) => {
e.stopPropagation();
popCardMenu(
popupTargetFromElement(e.currentTarget as HTMLElement),

View File

@@ -51,7 +51,7 @@ export class MobileKanbanCell extends SignalWatcher(
) {
static override styles = styles;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
isEditing$ = computed(() => {
const selection = this.kanban?.props.selection$.value;

View File

@@ -60,15 +60,15 @@ export class MobileKanbanGroup extends SignalWatcher(
) {
static override styles = styles;
private clickAddCard = () => {
private readonly clickAddCard = () => {
this.view.addCard('end', this.group.key);
};
private clickAddCardInStart = () => {
private readonly clickAddCardInStart = () => {
this.view.addCard('start', this.group.key);
};
private clickGroupOptions = (e: MouseEvent) => {
private readonly clickGroupOptions = (e: MouseEvent) => {
const ele = e.currentTarget as HTMLElement;
popFilterableSimpleMenu(popupTargetFromElement(ele), [
menu.group({

View File

@@ -125,7 +125,7 @@ export class KanbanCard extends SignalWatcher(
) {
static override styles = styles;
private clickEdit = (e: MouseEvent) => {
private readonly clickEdit = (e: MouseEvent) => {
e.stopPropagation();
const selection = this.getSelection();
if (selection) {
@@ -133,7 +133,7 @@ export class KanbanCard extends SignalWatcher(
}
};
private clickMore = (e: MouseEvent) => {
private readonly clickMore = (e: MouseEvent) => {
e.stopPropagation();
const selection = this.getSelection();
const ele = e.currentTarget as HTMLElement;
@@ -156,7 +156,7 @@ export class KanbanCard extends SignalWatcher(
}
};
private contextMenu = (e: MouseEvent) => {
private readonly contextMenu = (e: MouseEvent) => {
e.stopPropagation();
e.preventDefault();
const selection = this.getSelection();

View File

@@ -59,7 +59,7 @@ export class KanbanCell extends SignalWatcher(
) {
static override styles = styles;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
selectCurrentCell = (editing: boolean) => {
const selectionView = this.closest(

View File

@@ -5,7 +5,7 @@ import type { KanbanViewSelectionWithType } from '../../types.js';
import type { DataViewKanban } from '../kanban-view.js';
export class KanbanClipboardController implements ReactiveController {
private _onCopy = (
private readonly _onCopy = (
_context: UIEventStateContext,
_kanbanSelection: KanbanViewSelectionWithType
) => {
@@ -13,7 +13,7 @@ export class KanbanClipboardController implements ReactiveController {
return true;
};
private _onPaste = (_context: UIEventStateContext) => {
private readonly _onPaste = (_context: UIEventStateContext) => {
// todo
return true;
};

View File

@@ -140,7 +140,7 @@ export class KanbanDragController implements ReactiveController {
return scrollContainer;
}
constructor(private host: DataViewKanban) {
constructor(private readonly host: DataViewKanban) {
this.host.addController(this);
}

View File

@@ -7,7 +7,7 @@ export class KanbanHotkeysController implements ReactiveController {
return !!this.host.selectionController.selection;
}
constructor(private host: DataViewKanban) {
constructor(private readonly host: DataViewKanban) {
this.host.addController(this);
}

View File

@@ -79,7 +79,7 @@ export class KanbanSelectionController implements ReactiveController {
return this.host.props.view;
}
constructor(private host: DataViewKanban) {
constructor(private readonly host: DataViewKanban) {
this.host.addController(this);
}

View File

@@ -96,7 +96,7 @@ export class KanbanGroup extends SignalWatcher(
) {
static override styles = styles;
private clickAddCard = () => {
private readonly clickAddCard = () => {
const id = this.view.addCard('end', this.group.key);
requestAnimationFrame(() => {
const kanban = this.closest('affine-data-view-kanban');
@@ -114,7 +114,7 @@ export class KanbanGroup extends SignalWatcher(
});
};
private clickAddCardInStart = () => {
private readonly clickAddCardInStart = () => {
const id = this.view.addCard('start', this.group.key);
requestAnimationFrame(() => {
const kanban = this.closest('affine-data-view-kanban');
@@ -132,7 +132,7 @@ export class KanbanGroup extends SignalWatcher(
});
};
private clickGroupOptions = (e: MouseEvent) => {
private readonly clickGroupOptions = (e: MouseEvent) => {
const ele = e.currentTarget as HTMLElement;
popFilterableSimpleMenu(popupTargetFromElement(ele), [
menu.action({

View File

@@ -35,7 +35,7 @@ export class KanbanHeader extends SignalWatcher(
) {
static override styles = styles;
private clickGroup = (e: MouseEvent) => {
private readonly clickGroup = (e: MouseEvent) => {
const groupTrait = this.view.traitGet(groupTraitKey);
if (!groupTrait) {
return;

View File

@@ -100,7 +100,7 @@ export class DataViewKanban extends DataViewBase<
> {
static override styles = styles;
private dragController = new KanbanDragController(this);
private readonly dragController = new KanbanDragController(this);
clipboardController = new KanbanClipboardController(this);

View File

@@ -36,7 +36,7 @@ export class MobileTableCell extends SignalWatcher(
}
`;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
@property({ attribute: false })
accessor column!: TableColumn;

View File

@@ -53,7 +53,7 @@ export class MobileTableColumnHeader extends SignalWatcher(
}
`;
private _clickColumn = () => {
private readonly _clickColumn = () => {
if (this.tableViewManager.readonly$.value) {
return;
}

View File

@@ -50,7 +50,7 @@ export class MobileTableGroup extends SignalWatcher(
) {
static override styles = styles;
private clickAddRow = () => {
private readonly clickAddRow = () => {
this.view.rowAdd('end', this.group?.key);
requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController;
@@ -68,7 +68,7 @@ export class MobileTableGroup extends SignalWatcher(
});
};
private clickAddRowInStart = () => {
private readonly clickAddRowInStart = () => {
this.view.rowAdd('start', this.group?.key);
requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController;
@@ -86,7 +86,7 @@ export class MobileTableGroup extends SignalWatcher(
});
};
private clickGroupOptions = (e: MouseEvent) => {
private readonly clickGroupOptions = (e: MouseEvent) => {
const group = this.group;
if (!group) {
return;
@@ -111,7 +111,7 @@ export class MobileTableGroup extends SignalWatcher(
]);
};
private renderGroupHeader = () => {
private readonly renderGroupHeader = () => {
if (!this.group) {
return null;
}

View File

@@ -23,7 +23,7 @@ export class MobileTableHeader extends SignalWatcher(
}
`;
private _onAddColumn = () => {
private readonly _onAddColumn = () => {
if (this.readonly) return;
this.tableViewManager.propertyAdd('end');
this.editLastColumnTitle();

View File

@@ -45,7 +45,7 @@ export class MobileDataViewTable extends DataViewBase<
}
`;
private _addRow = (
private readonly _addRow = (
tableViewManager: TableSingleView,
position: InsertToPosition | number
) => {

View File

@@ -43,7 +43,7 @@ export class DatabaseCellContainer extends SignalWatcher(
}
`;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
@property({ attribute: false })
accessor column!: TableColumn;

View File

@@ -16,7 +16,7 @@ type JsonAreaData = string[][];
const TEXT = 'text/plain';
export class TableClipboardController implements ReactiveController {
private _onCopy = (
private readonly _onCopy = (
tableSelection: TableViewSelectionWithType,
isCut = false
) => {
@@ -72,11 +72,11 @@ export class TableClipboardController implements ReactiveController {
return true;
};
private _onCut = (tableSelection: TableViewSelectionWithType) => {
private readonly _onCut = (tableSelection: TableViewSelectionWithType) => {
this._onCopy(tableSelection, true);
};
private _onPaste = async (_context: UIEventStateContext) => {
private readonly _onPaste = async (_context: UIEventStateContext) => {
const event = _context.get('clipboardState').raw;
event.stopPropagation();
const view = this.host;

View File

@@ -128,7 +128,7 @@ export class TableDragController implements ReactiveController {
return position;
};
constructor(private host: DataViewTable) {
constructor(private readonly host: DataViewTable) {
this.host.addController(this);
}

View File

@@ -10,7 +10,7 @@ export class TableHotkeysController implements ReactiveController {
return this.host.selectionController;
}
constructor(private host: DataViewTable) {
constructor(private readonly host: DataViewTable) {
this.host.addController(this);
}

View File

@@ -29,7 +29,7 @@ import {
export class TableSelectionController implements ReactiveController {
private _tableViewSelection?: TableViewSelectionWithType;
private getFocusCellContainer = () => {
private readonly getFocusCellContainer = () => {
if (
!this._tableViewSelection ||
this._tableViewSelection.selectionType !== 'area'

View File

@@ -67,7 +67,7 @@ export class TableGroup extends SignalWatcher(
) {
static override styles = styles;
private clickAddRow = () => {
private readonly clickAddRow = () => {
this.view.rowAdd('end', this.group?.key);
requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController;
@@ -85,7 +85,7 @@ export class TableGroup extends SignalWatcher(
});
};
private clickAddRowInStart = () => {
private readonly clickAddRowInStart = () => {
this.view.rowAdd('start', this.group?.key);
requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController;
@@ -103,7 +103,7 @@ export class TableGroup extends SignalWatcher(
});
};
private clickGroupOptions = (e: MouseEvent) => {
private readonly clickGroupOptions = (e: MouseEvent) => {
const group = this.group;
if (!group) {
return;
@@ -128,7 +128,7 @@ export class TableGroup extends SignalWatcher(
]);
};
private renderGroupHeader = () => {
private readonly renderGroupHeader = () => {
if (!this.group) {
return null;
}

View File

@@ -19,7 +19,7 @@ export class DatabaseColumnHeader extends SignalWatcher(
) {
static override styles = styles;
private _onAddColumn = (e: MouseEvent) => {
private readonly _onAddColumn = (e: MouseEvent) => {
if (this.readonly) return;
this.tableViewManager.propertyAdd('end');
const ele = e.currentTarget as HTMLElement;

View File

@@ -63,14 +63,14 @@ export class DatabaseHeaderColumn extends SignalWatcher(
}
`;
private _clickColumn = () => {
private readonly _clickColumn = () => {
if (this.tableViewManager.readonly$.value) {
return;
}
this.popMenu();
};
private _clickTypeIcon = (event: MouseEvent) => {
private readonly _clickTypeIcon = (event: MouseEvent) => {
if (this.tableViewManager.readonly$.value) {
return;
}
@@ -96,7 +96,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
});
};
private _contextMenu = (e: MouseEvent) => {
private readonly _contextMenu = (e: MouseEvent) => {
if (this.tableViewManager.readonly$.value) {
return;
}
@@ -104,7 +104,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
this.popMenu(e.currentTarget as HTMLElement);
};
private _enterWidthDragBar = () => {
private readonly _enterWidthDragBar = () => {
if (this.tableViewManager.readonly$.value) {
return;
}
@@ -115,13 +115,13 @@ export class DatabaseHeaderColumn extends SignalWatcher(
this.drawWidthDragBar();
};
private _leaveWidthDragBar = () => {
private readonly _leaveWidthDragBar = () => {
cancelAnimationFrame(this.drawWidthDragBarTask);
this.drawWidthDragBarTask = 0;
getVerticalIndicator().remove();
};
private drawWidthDragBar = () => {
private readonly drawWidthDragBar = () => {
const rect = getTableGroupRect(this);
if (!rect) {
return;
@@ -136,7 +136,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
private drawWidthDragBarTask = 0;
private widthDragBar = createRef();
private readonly widthDragBar = createRef();
editTitle = () => {
this._clickColumn();

View File

@@ -87,14 +87,14 @@ export class DatabaseNumberFormatBar extends WithDisposable(LitElement) {
}
`;
private _decrementDecimalPlaces = () => {
private readonly _decrementDecimalPlaces = () => {
this.column.dataUpdate(data => ({
decimal: Math.max(((data.decimal as number) ?? 0) - 1, 0),
}));
this.requestUpdate();
};
private _incrementDecimalPlaces = () => {
private readonly _incrementDecimalPlaces = () => {
this.column.dataUpdate(data => ({
decimal: Math.min(((data.decimal as number) ?? 0) + 1, 8),
}));

View File

@@ -114,7 +114,7 @@ export class TableRow extends SignalWatcher(WithDisposable(ShadowlessElement)) {
}
`;
private _clickDragHandler = () => {
private readonly _clickDragHandler = () => {
if (this.view.readonly$.value) {
return;
}

View File

@@ -39,7 +39,7 @@ export class TableSingleView extends SingleViewBase<TableViewData> {
return result;
});
private computedColumns$ = computed(() => {
private readonly computedColumns$ = computed(() => {
return this.propertiesWithoutFilter$.value.map(id => {
const column = this.propertyGet(id);
return {
@@ -51,19 +51,19 @@ export class TableSingleView extends SingleViewBase<TableViewData> {
});
});
private filter$ = computed(() => {
private readonly filter$ = computed(() => {
return this.data$.value?.filter ?? emptyFilterGroup;
});
private groupBy$ = computed(() => {
private readonly groupBy$ = computed(() => {
return this.data$.value?.groupBy;
});
private sortList$ = computed(() => {
private readonly sortList$ = computed(() => {
return this.data$.value?.sort;
});
private sortManager = this.traitSet(
private readonly sortManager = this.traitSet(
sortTraitKey,
new SortManager(this.sortList$, this, {
setSortList: sortList => {
@@ -385,7 +385,7 @@ export class TableColumn extends PropertyBase {
}
constructor(
private tableView: TableSingleView,
private readonly tableView: TableSingleView,
columnId: string
) {
super(tableView as SingleView, columnId);