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
@@ -30,7 +30,7 @@ export class AffineLink extends ShadowlessElement {
private _identified: boolean = false;
// see https://github.com/toeverything/AFFiNE/issues/1540
private _onMouseUp = () => {
private readonly _onMouseUp = () => {
const anchorElement = this.querySelector('a');
if (!anchorElement || !anchorElement.isContentEditable) return;
anchorElement.contentEditable = 'false';
@@ -58,7 +58,7 @@ export class AffineLink extends ShadowlessElement {
refNodeSlotsProvider.docLinkClicked.emit(referenceInfo);
};
private _whenHover = new HoverController(
private readonly _whenHover = new HoverController(
this,
({ abortController }) => {
if (this.block?.doc.readonly) {
@@ -49,7 +49,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
private _bodyOverflowStyle = '';
private _createTemplate = () => {
private readonly _createTemplate = () => {
this.updateComplete
.then(() => {
this.linkInput?.focus();
@@ -74,14 +74,14 @@ export class LinkPopup extends WithDisposable(LitElement) {
`;
};
private _delete = () => {
private readonly _delete = () => {
if (this.inlineEditor.isValidInlineRange(this.targetInlineRange)) {
this.inlineEditor.deleteText(this.targetInlineRange);
}
this.abortController.abort();
};
private _edit = () => {
private readonly _edit = () => {
if (!this.host) return;
this.type = 'edit';
@@ -89,7 +89,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
track(this.host.std, 'OpenedAliasPopup', { control: 'edit' });
};
private _editTemplate = () => {
private readonly _editTemplate = () => {
this.updateComplete
.then(() => {
if (
@@ -139,7 +139,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
private _embedOptions: EmbedOptions | null = null;
private _openLink = () => {
private readonly _openLink = () => {
if (this.openLink) {
this.openLink();
return;
@@ -154,7 +154,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
this.abortController.abort();
};
private _removeLink = () => {
private readonly _removeLink = () => {
if (this.inlineEditor.isValidInlineRange(this.targetInlineRange)) {
this.inlineEditor.formatText(this.targetInlineRange, {
link: null,
@@ -163,7 +163,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
this.abortController.abort();
};
private _toggleViewSelector = (e: Event) => {
private readonly _toggleViewSelector = (e: Event) => {
if (!this.host) return;
const opened = (e as CustomEvent<boolean>).detail;
@@ -172,7 +172,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
track(this.host.std, 'OpenedViewSelector', { control: 'switch view' });
};
private _trackViewSelected = (type: string) => {
private readonly _trackViewSelected = (type: string) => {
if (!this.host) return;
track(this.host.std, 'SelectedView', {
@@ -181,7 +181,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
});
};
private _viewTemplate = () => {
private readonly _viewTemplate = () => {
if (!this.currentLink) return;
this._embedOptions =
@@ -89,7 +89,7 @@ export class ReferenceAliasPopup extends SignalWatcher(
}
`;
private _onSave = () => {
private readonly _onSave = () => {
const title = this.title$.value.trim();
if (!title) {
this.remove();
@@ -103,7 +103,7 @@ export class ReferenceAliasPopup extends SignalWatcher(
this.remove();
};
private _updateTitle = (e: InputEvent) => {
private readonly _updateTitle = (e: InputEvent) => {
const target = e.target as HTMLInputElement;
const value = target.value;
this.title$.value = value;
@@ -68,7 +68,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
}
`;
private _updateRefMeta = (doc: Doc) => {
private readonly _updateRefMeta = (doc: Doc) => {
const refAttribute = this.delta.attributes?.reference;
if (!refAttribute) {
return;
@@ -88,7 +88,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
@state()
accessor refMeta: DocMeta | undefined = undefined;
private _whenHover: HoverController = new HoverController(
private readonly _whenHover: HoverController = new HoverController(
this,
({ abortController }) => {
if (
@@ -50,7 +50,7 @@ import { styles } from './styles.js';
export class ReferencePopup extends WithDisposable(LitElement) {
static override styles = styles;
private _copyLink = () => {
private readonly _copyLink = () => {
const url = this.std
.getOptional(GenerateDocUrlProvider)
?.generateDocUrl(this.referenceInfo.pageId, this.referenceInfo.params);
@@ -65,13 +65,13 @@ export class ReferencePopup extends WithDisposable(LitElement) {
track(this.std, 'CopiedLink', { control: 'copy link' });
};
private _openDoc = () => {
private readonly _openDoc = () => {
this.std
.getOptional(RefNodeSlotsProvider)
?.docLinkClicked.emit(this.referenceInfo);
};
private _openEditPopup = (e: MouseEvent) => {
private readonly _openEditPopup = (e: MouseEvent) => {
e.stopPropagation();
if (document.body.querySelector('reference-alias-popup')) {
@@ -102,14 +102,14 @@ export class ReferencePopup extends WithDisposable(LitElement) {
track(std, 'OpenedAliasPopup', { control: 'edit' });
};
private _toggleViewSelector = (e: Event) => {
private readonly _toggleViewSelector = (e: Event) => {
const opened = (e as CustomEvent<boolean>).detail;
if (!opened) return;
track(this.std, 'OpenedViewSelector', { control: 'switch view' });
};
private _trackViewSelected = (type: string) => {
private readonly _trackViewSelected = (type: string) => {
track(this.std, 'SelectedView', {
control: 'select view',
type: `${type} view`,
@@ -60,7 +60,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
private _inlineEditor: AffineInlineEditor | null = null;
private _onCopy = (e: ClipboardEvent) => {
private readonly _onCopy = (e: ClipboardEvent) => {
const inlineEditor = this.inlineEditor;
if (!inlineEditor) return;
@@ -77,7 +77,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
e.stopPropagation();
};
private _onCut = (e: ClipboardEvent) => {
private readonly _onCut = (e: ClipboardEvent) => {
const inlineEditor = this.inlineEditor;
if (!inlineEditor) return;
@@ -99,7 +99,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
e.stopPropagation();
};
private _onPaste = (e: ClipboardEvent) => {
private readonly _onPaste = (e: ClipboardEvent) => {
const inlineEditor = this.inlineEditor;
if (!inlineEditor) return;
@@ -121,14 +121,18 @@ export class RichText extends WithDisposable(ShadowlessElement) {
e.stopPropagation();
};
private _onStackItemAdded = (event: { stackItem: RichTextStackItem }) => {
private readonly _onStackItemAdded = (event: {
stackItem: RichTextStackItem;
}) => {
const inlineRange = this.inlineEditor?.getInlineRange();
if (inlineRange) {
event.stackItem.meta.set('richtext-v-range', inlineRange);
}
};
private _onStackItemPopped = (event: { stackItem: RichTextStackItem }) => {
private readonly _onStackItemPopped = (event: {
stackItem: RichTextStackItem;
}) => {
const inlineRange = event.stackItem.meta.get('richtext-v-range');
if (inlineRange && this.inlineEditor?.isValidInlineRange(inlineRange)) {
this.inlineEditor?.setInlineRange(inlineRange);