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
@@ -70,29 +70,29 @@ export class DatabaseTitle extends WithDisposable(ShadowlessElement) {
}
`;
private compositionEnd = () => {
private readonly compositionEnd = () => {
this.titleText.replace(0, this.titleText.length, this.input.value);
};
private onBlur = () => {
private readonly onBlur = () => {
this.isFocus = false;
};
private onFocus = () => {
private readonly onFocus = () => {
this.isFocus = true;
if (this.database?.viewSelection$?.value) {
this.database?.setSelection(undefined);
}
};
private onInput = (e: InputEvent) => {
private readonly onInput = (e: InputEvent) => {
this.text = this.input.value;
if (!e.isComposing) {
this.titleText.replace(0, this.titleText.length, this.input.value);
}
};
private onKeyDown = (event: KeyboardEvent) => {
private readonly onKeyDown = (event: KeyboardEvent) => {
event.stopPropagation();
if (event.key === 'Enter' && !event.isComposing) {
event.preventDefault();
@@ -106,7 +106,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<
}
`;
private _clickDatabaseOps = (e: MouseEvent) => {
private readonly _clickDatabaseOps = (e: MouseEvent) => {
const options = this.optionsConfig.configure(this.model, {
items: [
menu.input({
@@ -156,9 +156,9 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<
private _dataSource?: DatabaseBlockDataSource;
private dataView = new DataView();
private readonly dataView = new DataView();
private renderTitle = (dataViewMethod: DataViewInstance) => {
private readonly renderTitle = (dataViewMethod: DataViewInstance) => {
const addRow = () => dataViewMethod.addRow?.('start');
return html` <affine-database-title
style="overflow: hidden"
@@ -82,7 +82,7 @@ export class LinkCell extends BaseCellRenderer<string> {
}
`;
private _onClick = (event: Event) => {
private readonly _onClick = (event: Event) => {
event.stopPropagation();
const value = this.value ?? '';
@@ -102,7 +102,7 @@ export class LinkCell extends BaseCellRenderer<string> {
}
};
private _onEdit = (e: Event) => {
private readonly _onEdit = (e: Event) => {
e.stopPropagation();
this.selectCurrentCell(true);
};
@@ -199,13 +199,13 @@ export class LinkCellEditing extends BaseCellRenderer<string> {
}
`;
private _focusEnd = () => {
private readonly _focusEnd = () => {
const end = this._container.value.length;
this._container.focus();
this._container.setSelectionRange(end, end);
};
private _onKeydown = (e: KeyboardEvent) => {
private readonly _onKeydown = (e: KeyboardEvent) => {
if (e.key === 'Enter' && !e.isComposing) {
this._setValue();
setTimeout(() => {
@@ -214,7 +214,7 @@ export class LinkCellEditing extends BaseCellRenderer<string> {
}
};
private _setValue = (value: string = this._container.value) => {
private readonly _setValue = (value: string = this._container.value) => {
let url = value;
if (isValidUrl(value)) {
url = normalizeUrl(value);
@@ -205,7 +205,7 @@ export class RichTextCellEditing extends BaseCellRenderer<Text> {
}
`;
private _handleKeyDown = (event: KeyboardEvent) => {
private readonly _handleKeyDown = (event: KeyboardEvent) => {
if (event.key !== 'Escape') {
if (event.key === 'Tab') {
event.preventDefault();
@@ -274,12 +274,12 @@ export class RichTextCellEditing extends BaseCellRenderer<Text> {
}
};
private _initYText = (text?: string) => {
private readonly _initYText = (text?: string) => {
const yText = new Text(text);
this.onChange(yText);
};
private _onSoftEnter = () => {
private readonly _onSoftEnter = () => {
if (this.value && this.inlineEditor) {
const inlineRange = this.inlineEditor.getInlineRange();
assertExists(inlineRange);
@@ -205,7 +205,7 @@ export class HeaderAreaTextCell extends BaseTextCell {
}
export class HeaderAreaTextCellEditing extends BaseTextCell {
private _onCopy = (e: ClipboardEvent) => {
private readonly _onCopy = (e: ClipboardEvent) => {
const inlineEditor = this.inlineEditor;
assertExists(inlineEditor);
@@ -222,7 +222,7 @@ export class HeaderAreaTextCellEditing extends BaseTextCell {
e.stopPropagation();
};
private _onCut = (e: ClipboardEvent) => {
private readonly _onCut = (e: ClipboardEvent) => {
const inlineEditor = this.inlineEditor;
assertExists(inlineEditor);
@@ -244,7 +244,7 @@ export class HeaderAreaTextCellEditing extends BaseTextCell {
e.stopPropagation();
};
private _onPaste = (e: ClipboardEvent) => {
private readonly _onPaste = (e: ClipboardEvent) => {
const inlineEditor = this.inlineEditor;
const inlineRange = inlineEditor?.getInlineRange();
if (!inlineRange) return;