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
@@ -36,7 +36,7 @@ export class MobileTableCell extends SignalWatcher(
}
`;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
@property({ attribute: false })
accessor column!: TableColumn;
@@ -53,7 +53,7 @@ export class MobileTableColumnHeader extends SignalWatcher(
}
`;
private _clickColumn = () => {
private readonly _clickColumn = () => {
if (this.tableViewManager.readonly$.value) {
return;
}
@@ -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;
}
@@ -23,7 +23,7 @@ export class MobileTableHeader extends SignalWatcher(
}
`;
private _onAddColumn = () => {
private readonly _onAddColumn = () => {
if (this.readonly) return;
this.tableViewManager.propertyAdd('end');
this.editLastColumnTitle();
@@ -45,7 +45,7 @@ export class MobileDataViewTable extends DataViewBase<
}
`;
private _addRow = (
private readonly _addRow = (
tableViewManager: TableSingleView,
position: InsertToPosition | number
) => {
@@ -43,7 +43,7 @@ export class DatabaseCellContainer extends SignalWatcher(
}
`;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
@property({ attribute: false })
accessor column!: TableColumn;
@@ -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;
@@ -128,7 +128,7 @@ export class TableDragController implements ReactiveController {
return position;
};
constructor(private host: DataViewTable) {
constructor(private readonly host: DataViewTable) {
this.host.addController(this);
}
@@ -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);
}
@@ -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'
@@ -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;
}
@@ -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;
@@ -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();
@@ -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),
}));
@@ -114,7 +114,7 @@ export class TableRow extends SignalWatcher(WithDisposable(ShadowlessElement)) {
}
`;
private _clickDragHandler = () => {
private readonly _clickDragHandler = () => {
if (this.view.readonly$.value) {
return;
}
@@ -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);