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

@@ -150,7 +150,7 @@ class TagManager {
return this.ops.value;
}
constructor(private ops: TagManagerOptions) {}
constructor(private readonly ops: TagManagerOptions) {}
deleteTag(id: string) {
this.ops.onChange(this.value.value.filter(item => item !== id));
@@ -180,7 +180,7 @@ export class MultiTagSelect extends SignalWatcher(
) {
static override styles = styles;
private _clickItemOption = (e: MouseEvent, id: string) => {
private readonly _clickItemOption = (e: MouseEvent, id: string) => {
e.stopPropagation();
const option = this.options.value.find(v => v.id === id);
if (!option) {
@@ -235,11 +235,11 @@ export class MultiTagSelect extends SignalWatcher(
});
};
private _onInput = (event: KeyboardEvent) => {
private readonly _onInput = (event: KeyboardEvent) => {
this.tagManager.text.value = (event.target as HTMLInputElement).value;
};
private _onInputKeydown = (event: KeyboardEvent) => {
private readonly _onInputKeydown = (event: KeyboardEvent) => {
event.stopPropagation();
const inputValue = this.text.value.trim();
if (event.key === 'Backspace' && inputValue === '') {
@@ -257,9 +257,9 @@ export class MultiTagSelect extends SignalWatcher(
}
};
private tagManager = new TagManager(this);
private readonly tagManager = new TagManager(this);
private selectedTag$ = computed(() => {
private readonly selectedTag$ = computed(() => {
return this.tagManager.filteredOptions$.value[this.selectedIndex];
});

View File

@@ -63,14 +63,14 @@ export class DataViewRenderer extends SignalWatcher(
}
`;
private _view = createRef<{
private readonly _view = createRef<{
expose: DataViewInstance;
}>();
@property({ attribute: false })
accessor config!: DataViewRendererConfig;
private currentViewId$ = computed(() => {
private readonly currentViewId$ = computed(() => {
return this.config.dataSource.viewManager.currentViewId$.value;
});
@@ -218,7 +218,7 @@ declare global {
}
export class DataView {
private _ref = createRef<DataViewRenderer>();
private readonly _ref = createRef<DataViewRenderer>();
get expose() {
return this._ref.value?.view?.expose;

View File

@@ -109,7 +109,7 @@ export class RecordField extends SignalWatcher(
}
`;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
_click = (e: MouseEvent) => {
e.stopPropagation();

View File

@@ -49,7 +49,7 @@ export class DetailSelection {
}
}
constructor(private viewEle: RecordDetail) {}
constructor(private readonly viewEle: RecordDetail) {}
blur(selection: DetailViewSelection) {
const container = this.getFocusCellContainer(selection);

View File

@@ -21,7 +21,7 @@ export class NumberGroupView extends BaseGroup<NonNullable<unknown>, number> {
}
`;
private _click = () => {
private readonly _click = () => {
if (this.readonly) {
return;
}

View File

@@ -42,7 +42,7 @@ export class SelectGroupView extends BaseGroup<
}
`;
private _click = (e: MouseEvent) => {
private readonly _click = (e: MouseEvent) => {
if (this.readonly) {
return;
}

View File

@@ -21,7 +21,7 @@ export class StringGroupView extends BaseGroup<NonNullable<unknown>, string> {
}
`;
private _click = () => {
private readonly _click = () => {
if (this.readonly) {
return;
}

View File

@@ -103,7 +103,7 @@ export class GroupTrait {
return groupMap;
});
private _groupsDataList$ = computed(() => {
private readonly _groupsDataList$ = computed(() => {
const groupMap = this.groupDataMap$.value;
if (!groupMap) {
return;
@@ -143,9 +143,9 @@ export class GroupTrait {
}
constructor(
private groupBy$: ReadonlySignal<GroupBy | undefined>,
private readonly groupBy$: ReadonlySignal<GroupBy | undefined>,
public view: SingleView,
private ops: {
private readonly ops: {
groupBySet: (groupBy: GroupBy | undefined) => void;
sortGroup: (keys: string[]) => string[];
sortRow: (groupKey: string, rowIds: string[]) => string[];

View File

@@ -50,9 +50,9 @@ export class DataType<
> implements TypeDefinition
{
constructor(
private name: Name,
private readonly name: Name,
_dataSchema: DataSchema,
private valueSchema: ValueSchema
private readonly valueSchema: ValueSchema
) {}
instance(literal?: Zod.TypeOf<DataSchema>) {

View File

@@ -14,8 +14,8 @@ export class MatcherCreator<Data, Type extends TypeInstance = TypeInstance> {
export class Matcher<Data, Type extends TypeInstance = TypeInstance> {
constructor(
private list: MatcherData<Data, Type>[],
private _match: (type: Type, target: TypeInstance) => boolean = (
private readonly list: MatcherData<Data, Type>[],
private readonly _match: (type: Type, target: TypeInstance) => boolean = (
type,
target
) => typeSystem.unify(target, type)

View File

@@ -32,7 +32,7 @@ const getMap2 = <T>(
};
export class TypeSystem {
private _unify: Unify = (
private readonly _unify: Unify = (
ctx: TypeVarContext,
left: TypeInstance | undefined,
right: TypeInstance | undefined

View File

@@ -34,7 +34,7 @@ export class SortManager {
constructor(
readonly sort$: ReadonlySignal<Sort | undefined>,
readonly view: SingleView,
private ops: {
private readonly ops: {
setSortList: (sortList: Sort) => void;
}
) {}

View File

@@ -56,20 +56,20 @@ const defaultCoordinates: Coordinates = {
};
export class DndContext {
private dragMove = (coordinates: Coordinates) => {
private readonly dragMove = (coordinates: Coordinates) => {
this.activationCoordinates$.value = coordinates;
this.autoScroll();
};
private droppableNodes$ = signal<DroppableNodes>(new Map());
private readonly droppableNodes$ = signal<DroppableNodes>(new Map());
private initialCoordinates$ = signal<Coordinates>();
private readonly initialCoordinates$ = signal<Coordinates>();
private initScrollOffset$ = signal(defaultCoordinates);
private readonly initScrollOffset$ = signal(defaultCoordinates);
private session$ = signal<DndSession>();
private readonly session$ = signal<DndSession>();
private startSession = (
private readonly startSession = (
id: UniqueIdentifier,
activeNode: HTMLElement,
sessionCreator: DndSessionCreator
@@ -96,7 +96,7 @@ export class DndContext {
activationCoordinates$ = signal<Coordinates>();
private translate$ = computed(() => {
private readonly translate$ = computed(() => {
const init = this.initialCoordinates$.value;
const current = this.activationCoordinates$.value;
if (!init || !current) {

View File

@@ -192,8 +192,8 @@ export class MouseSession implements DndSession {
constructor(
event: Event,
private sessionProps: DndSessionProps,
private props: MouseSensorProps
private readonly sessionProps: DndSessionProps,
private readonly props: MouseSensorProps
) {
this.initialCoordinates = getEventCoordinates(event) ?? defaultCoordinates;
this.attach();

View File

@@ -1,5 +1,5 @@
export class Listeners<T extends EventTarget> {
private listeners: [
private readonly listeners: [
string,
EventListenerOrEventListenerObject | null,
AddEventListenerOptions | boolean | undefined,

View File

@@ -139,9 +139,9 @@ export abstract class SingleViewBase<
ViewData extends DataViewDataType = DataViewDataType,
> implements SingleView
{
private searchString = signal('');
private readonly searchString = signal('');
private traitMap = new Map<symbol, unknown>();
private readonly traitMap = new Map<symbol, unknown>();
data$ = computed(() => {
return this.dataSource.viewDataGet(this.id) as ViewData | undefined;