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

@@ -51,11 +51,11 @@ type HtmlToSliceSnapshotPayload = {
};
export class HtmlAdapter extends BaseAdapter<Html> {
private _astToHtml = (ast: Root) => {
private readonly _astToHtml = (ast: Root) => {
return unified().use(rehypeStringify).stringify(ast);
};
private _traverseHtml = async (
private readonly _traverseHtml = async (
html: HtmlAST,
snapshot: BlockSnapshot,
assets?: AssetsManager
@@ -108,7 +108,7 @@ export class HtmlAdapter extends BaseAdapter<Html> {
return walker.walk(html, snapshot);
};
private _traverseSnapshot = async (
private readonly _traverseSnapshot = async (
snapshot: BlockSnapshot,
html: HtmlAST,
assets?: AssetsManager

View File

@@ -50,7 +50,7 @@ type MarkdownToSliceSnapshotPayload = {
};
export class MarkdownAdapter extends BaseAdapter<Markdown> {
private _traverseMarkdown = (
private readonly _traverseMarkdown = (
markdown: MarkdownAST,
snapshot: BlockSnapshot,
assets?: AssetsManager
@@ -105,7 +105,7 @@ export class MarkdownAdapter extends BaseAdapter<Markdown> {
return walker.walk(markdown, snapshot);
};
private _traverseSnapshot = async (
private readonly _traverseSnapshot = async (
snapshot: BlockSnapshot,
markdown: MarkdownAST,
assets?: AssetsManager

View File

@@ -38,7 +38,7 @@ type MixTextToSliceSnapshotPayload = {
};
export class MixTextAdapter extends BaseAdapter<MixText> {
private _markdownAdapter: MarkdownAdapter;
private readonly _markdownAdapter: MarkdownAdapter;
constructor(job: Job) {
super(job);

View File

@@ -54,7 +54,7 @@ type NotionHtmlToDocSnapshotPayload = {
type NotionHtmlToBlockSnapshotPayload = NotionHtmlToDocSnapshotPayload;
export class NotionHtmlAdapter extends BaseAdapter<NotionHtml> {
private _traverseNotionHtml = async (
private readonly _traverseNotionHtml = async (
html: HtmlAST,
snapshot: BlockSnapshot,
assets?: AssetsManager,

View File

@@ -48,7 +48,7 @@ export class AIItemList extends WithDisposable(LitElement) {
private _activeSubMenuItem: AIItemConfig | null = null;
private _closeSubMenu = () => {
private readonly _closeSubMenu = () => {
if (this._abortController) {
this._abortController.abort();
this._abortController = null;
@@ -56,11 +56,11 @@ export class AIItemList extends WithDisposable(LitElement) {
this._activeSubMenuItem = null;
};
private _itemClassName = (item: AIItemConfig) => {
private readonly _itemClassName = (item: AIItemConfig) => {
return 'ai-item-' + item.name.split(' ').join('-').toLocaleLowerCase();
};
private _openSubMenu = (item: AIItemConfig) => {
private readonly _openSubMenu = (item: AIItemConfig) => {
if (!item.subItem || item.subItem.length === 0) {
this._closeSubMenu();
return;

View File

@@ -45,7 +45,7 @@ export class AISubItemList extends WithDisposable(LitElement) {
${menuItemStyles}
`;
private _handleClick = (subItem: AISubItemConfig) => {
private readonly _handleClick = (subItem: AISubItemConfig) => {
this.onClick?.();
if (subItem.handler) {
// TODO: add parameters to ai handler

View File

@@ -22,11 +22,11 @@ import { embedCardModalStyles } from './styles.js';
export class EmbedCardCreateModal extends WithDisposable(ShadowlessElement) {
static override styles = embedCardModalStyles;
private _onCancel = () => {
private readonly _onCancel = () => {
this.remove();
};
private _onConfirm = () => {
private readonly _onConfirm = () => {
const url = this.input.value;
if (!isValidUrl(url)) {
@@ -91,7 +91,7 @@ export class EmbedCardCreateModal extends WithDisposable(ShadowlessElement) {
this.remove();
};
private _onDocumentKeydown = (e: KeyboardEvent) => {
private readonly _onDocumentKeydown = (e: KeyboardEvent) => {
e.stopPropagation();
if (e.key === 'Enter' && !e.isComposing) {
this._onConfirm();

View File

@@ -144,11 +144,11 @@ export class EmbedCardEditModal extends SignalWatcher(
private _blockComponent: BlockComponent | null = null;
private _hide = () => {
private readonly _hide = () => {
this.remove();
};
private _onKeydown = (e: KeyboardEvent) => {
private readonly _onKeydown = (e: KeyboardEvent) => {
e.stopPropagation();
if (e.key === 'Enter' && !(e.isComposing || e.shiftKey)) {
this._onSave();
@@ -159,7 +159,7 @@ export class EmbedCardEditModal extends SignalWatcher(
}
};
private _onReset = () => {
private readonly _onReset = () => {
const blockComponent = this._blockComponent;
if (!blockComponent) {
@@ -186,7 +186,7 @@ export class EmbedCardEditModal extends SignalWatcher(
this.remove();
};
private _onSave = () => {
private readonly _onSave = () => {
const blockComponent = this._blockComponent;
if (!blockComponent) {
@@ -224,12 +224,12 @@ export class EmbedCardEditModal extends SignalWatcher(
this.remove();
};
private _updateDescription = (e: InputEvent) => {
private readonly _updateDescription = (e: InputEvent) => {
const target = e.target as HTMLTextAreaElement;
this.description$.value = target.value;
};
private _updateTitle = (e: InputEvent) => {
private readonly _updateTitle = (e: InputEvent) => {
const target = e.target as HTMLInputElement;
this.title$.value = target.value;
};

View File

@@ -31,13 +31,13 @@ export type FileDropOptions = {
export class FileDropManager {
private static _dropResult: DropResult | null = null;
private _blockService: BlockService;
private readonly _blockService: BlockService;
private _fileDropOptions: FileDropOptions;
private readonly _fileDropOptions: FileDropOptions;
private _indicator!: DragIndicator;
private readonly _indicator!: DragIndicator;
private _onDrop = (event: DragEvent) => {
private readonly _onDrop = (event: DragEvent) => {
this._indicator.rect = null;
const { onDrop } = this._fileDropOptions;

View File

@@ -64,7 +64,7 @@ export class SmoothCorner extends LitElement {
}
`;
private _resizeObserver: ResizeObserver | null = null;
private readonly _resizeObserver: ResizeObserver | null = null;
get _path() {
return getFigmaSquircleSvgPath({

View File

@@ -137,16 +137,18 @@ export const quickActionConfig: QuickActionConfig[] = [
const doc = host.doc;
const autofill = getTitleFromSelectedModels(selectedModels);
void promptDocTitle(host, autofill).then(title => {
if (title === null) return;
convertSelectedBlocksToLinkedDoc(
host.std,
doc,
draftedModels,
title
).catch(console.error);
notifyDocCreated(host, doc);
});
promptDocTitle(host, autofill)
.then(title => {
if (title === null) return;
convertSelectedBlocksToLinkedDoc(
host.std,
doc,
draftedModels,
title
).catch(console.error);
notifyDocCreated(host, doc);
})
.catch(console.error);
},
},
];

View File

@@ -44,11 +44,11 @@ export type ExportOptions = {
imageProxyEndpoint: string;
};
export class ExportManager {
private _exportOptions: ExportOptions = {
private readonly _exportOptions: ExportOptions = {
imageProxyEndpoint: DEFAULT_IMAGE_PROXY_ENDPOINT,
};
private _replaceRichTextWithSvgElement = (element: HTMLElement) => {
private readonly _replaceRichTextWithSvgElement = (element: HTMLElement) => {
const richList = Array.from(element.querySelectorAll('.inline-editor'));
richList.forEach(rich => {
const svgEle = this._elementToSvgElement(

View File

@@ -8,7 +8,7 @@ export class Zip {
private finalized = false;
private zip = new fflate.Zip((err, chunk, final) => {
private readonly zip = new fflate.Zip((err, chunk, final) => {
if (!err) {
const temp = new Uint8Array(this.compressed.length + chunk.length);
temp.set(this.compressed);