chore: disable rules in oxlint (#9154)

This commit is contained in:
Brooooooklyn
2024-12-13 10:49:35 +00:00
parent 2452ccd1e5
commit ea746e3d77
53 changed files with 621 additions and 269 deletions
@@ -2,8 +2,8 @@ import {
type SubscriptionQuery,
SubscriptionRecurring,
SubscriptionVariant,
SubscriptionPlan,
} from '@affine/graphql';
import { SubscriptionPlan } from '@affine/graphql';
import {
backoffRetry,
catchErrorInto,
@@ -32,4 +32,5 @@ export const EditorSettingSchema = BSEditorSettingSchema.merge(
AffineEditorSettingSchema
);
// eslint-disable-next-line no-redeclare
export type EditorSettingSchema = z.infer<typeof EditorSettingSchema>;
@@ -9,7 +9,7 @@ import { LiveData, Service } from '@toeverything/infra';
import type { DesktopApiService } from '../../desktop-api';
import type { I18n } from '../../i18n';
const SPELL_CHECK_SETTING_KEY: SpellCheckStateKey = 'spellCheckState';
const SPELL_CHECK_SETTING_KEY: typeof SpellCheckStateKey = 'spellCheckState';
export class SpellCheckSettingService extends Service {
constructor(
@@ -8,7 +8,7 @@ import {
DropEffect,
ExplorerTreeRoot,
} from '@affine/core/modules/explorer/views/tree';
import type { FavoriteSupportType } from '@affine/core/modules/favorite';
import type { FavoriteSupportTypeUnion } from '@affine/core/modules/favorite';
import {
FavoriteService,
isFavoriteSupportType,
@@ -97,7 +97,7 @@ export const ExplorerFavorites = () => {
const handleOnChildrenDrop = useCallback(
(
favorite: { id: string; type: FavoriteSupportType },
favorite: { id: string; type: FavoriteSupportTypeUnion },
data: DropTargetDropEvent<AffineDNDData>
) => {
if (
@@ -220,12 +220,12 @@ const ExplorerFavoriteNode = ({
}: {
favorite: {
id: string;
type: FavoriteSupportType;
type: FavoriteSupportTypeUnion;
};
onDrop: (
favorite: {
id: string;
type: FavoriteSupportType;
type: FavoriteSupportTypeUnion;
},
data: DropTargetDropEvent<AffineDNDData>
) => void;
@@ -4,8 +4,8 @@ export const FavoriteSupportType = [
'tag',
'folder',
] as const;
export type FavoriteSupportType = 'collection' | 'doc' | 'tag' | 'folder';
export type FavoriteSupportTypeUnion = 'collection' | 'doc' | 'tag' | 'folder';
export const isFavoriteSupportType = (
type: string
): type is FavoriteSupportType =>
FavoriteSupportType.includes(type as FavoriteSupportType);
): type is FavoriteSupportTypeUnion =>
FavoriteSupportType.includes(type as FavoriteSupportTypeUnion);
@@ -3,7 +3,7 @@ import {
generateFractionalIndexingKeyBetween,
} from '@toeverything/infra';
import type { FavoriteSupportType } from '../constant';
import type { FavoriteSupportTypeUnion } from '../constant';
import type { FavoriteRecord, FavoriteStore } from '../stores/favorite';
export class FavoriteList extends Entity {
@@ -20,16 +20,16 @@ export class FavoriteList extends Entity {
/**
* get favorite record by type and id
*/
favorite$(type: FavoriteSupportType, id: string) {
favorite$(type: FavoriteSupportTypeUnion, id: string) {
return this.store.watchFavorite(type, id);
}
isFavorite$(type: FavoriteSupportType, id: string) {
isFavorite$(type: FavoriteSupportTypeUnion, id: string) {
return this.favorite$(type, id).map(v => !!v);
}
add(
type: FavoriteSupportType,
type: FavoriteSupportTypeUnion,
id: string,
index: string = this.indexAt('before')
) {
@@ -37,7 +37,7 @@ export class FavoriteList extends Entity {
}
toggle(
type: FavoriteSupportType,
type: FavoriteSupportTypeUnion,
id: string,
index: string = this.indexAt('before')
) {
@@ -48,18 +48,18 @@ export class FavoriteList extends Entity {
}
}
remove(type: FavoriteSupportType, id: string) {
remove(type: FavoriteSupportTypeUnion, id: string) {
return this.store.removeFavorite(type, id);
}
reorder(type: FavoriteSupportType, id: string, index: string) {
reorder(type: FavoriteSupportTypeUnion, id: string, index: string) {
return this.store.reorderFavorite(type, id, index);
}
indexAt(
at: 'before' | 'after',
targetRecord?: {
type: FavoriteSupportType;
type: FavoriteSupportTypeUnion;
id: string;
}
) {
@@ -14,7 +14,11 @@ import {
} from './services/old/adapter';
import { FavoriteStore } from './stores/favorite';
export { FavoriteSupportType, isFavoriteSupportType } from './constant';
export {
FavoriteSupportType,
type FavoriteSupportTypeUnion,
isFavoriteSupportType,
} from './constant';
export type { FavoriteList } from './entities/favorite-list';
export { FavoriteService } from './services/favorite';
export {
@@ -6,7 +6,7 @@ import { LiveData, Service } from '@toeverything/infra';
import { defaultsDeep } from 'lodash-es';
import { Observable } from 'rxjs';
import type { FavoriteSupportType } from '../../constant';
import type { FavoriteSupportTypeUnion } from '../../constant';
import type { FavoriteService } from '../favorite';
import {
PagePropertyType,
@@ -192,7 +192,7 @@ export class MigrationFavoriteItemsAdapter extends Service {
}
}
type CompatibleFavoriteSupportType = FavoriteSupportType;
type CompatibleFavoriteSupportType = FavoriteSupportTypeUnion;
/**
* A service written for compatibility,with the same API as old FavoriteItemsAdapter.
@@ -3,11 +3,11 @@ import { LiveData, Store } from '@toeverything/infra';
import { map } from 'rxjs';
import { AuthService, type WorkspaceServerService } from '../../cloud';
import type { FavoriteSupportType } from '../constant';
import type { FavoriteSupportTypeUnion } from '../constant';
import { isFavoriteSupportType } from '../constant';
export interface FavoriteRecord {
type: FavoriteSupportType;
type: FavoriteSupportTypeUnion;
id: string;
index: string;
}
@@ -58,7 +58,7 @@ export class FavoriteStore extends Store {
}
addFavorite(
type: FavoriteSupportType,
type: FavoriteSupportTypeUnion,
id: string,
index: string
): FavoriteRecord {
@@ -70,17 +70,17 @@ export class FavoriteStore extends Store {
return this.toRecord(raw) as FavoriteRecord;
}
reorderFavorite(type: FavoriteSupportType, id: string, index: string) {
reorderFavorite(type: FavoriteSupportTypeUnion, id: string, index: string) {
const db = this.userdataDB$.value;
db.favorite.update(this.encodeKey(type, id), { index });
}
removeFavorite(type: FavoriteSupportType, id: string) {
removeFavorite(type: FavoriteSupportTypeUnion, id: string) {
const db = this.userdataDB$.value;
db.favorite.delete(this.encodeKey(type, id));
}
watchFavorite(type: FavoriteSupportType, id: string) {
watchFavorite(type: FavoriteSupportTypeUnion, id: string) {
const db = this.userdataDB$.value;
return LiveData.from<FavoriteRecord | undefined>(
db.favorite
@@ -112,7 +112,7 @@ export class FavoriteStore extends Store {
* @returns null if key is invalid
*/
private parseKey(key: string): {
type: FavoriteSupportType;
type: FavoriteSupportTypeUnion;
id: string;
} | null {
const [type, id] = key.split(':');
@@ -122,10 +122,10 @@ export class FavoriteStore extends Store {
if (!isFavoriteSupportType(type)) {
return null;
}
return { type: type as FavoriteSupportType, id };
return { type: type as FavoriteSupportTypeUnion, id };
}
private encodeKey(type: FavoriteSupportType, id: string) {
private encodeKey(type: FavoriteSupportTypeUnion, id: string) {
return `${type}:${id}`;
}
}
@@ -4,9 +4,9 @@ export const OrganizeSupportType = [
'collection',
'tag',
] as const;
export type OrganizeSupportType = 'folder' | 'doc' | 'collection' | 'tag';
export type OrganizeSupportTypeUnion = 'folder' | 'doc' | 'collection' | 'tag';
export const isOrganizeSupportType = (
type: string
): type is OrganizeSupportType =>
OrganizeSupportType.includes(type as OrganizeSupportType);
): type is OrganizeSupportTypeUnion =>
OrganizeSupportType.includes(type as OrganizeSupportTypeUnion);
@@ -1,7 +1,7 @@
import { createORMClient, Entity, YjsDBAdapter } from '@toeverything/infra';
import { Doc as YDoc } from 'yjs';
import { USER_DB_SCHEMA } from '../schema';
import { USER_DB_SCHEMA, type UserDbSchema } from '../schema';
import { UserDBEngine } from './user-db-engine';
import { UserDBTable } from './user-db-table';
@@ -42,5 +42,5 @@ export class UserDB extends Entity<{
}
export type UserDBWithTables = UserDB & {
[K in keyof USER_DB_SCHEMA]: UserDBTable<USER_DB_SCHEMA[K]>;
[K in keyof UserDbSchema]: UserDBTable<UserDbSchema[K]>;
};
@@ -6,4 +6,4 @@ export const USER_DB_SCHEMA = {
value: f.string(),
},
} as const satisfies DBSchemaBuilder;
export type USER_DB_SCHEMA = typeof USER_DB_SCHEMA;
export type UserDbSchema = typeof USER_DB_SCHEMA;
@@ -24,8 +24,9 @@ import {
type WorkspaceFlavoursProvider,
type WorkspaceMetadata,
type WorkspaceProfileInfo,
effect,
getAFFiNEWorkspaceSchema,
} from '@toeverything/infra';
import { effect, getAFFiNEWorkspaceSchema } from '@toeverything/infra';
import { isEqual } from 'lodash-es';
import { nanoid } from 'nanoid';
import { EMPTY, map, mergeMap, Observable, switchMap } from 'rxjs';
@@ -21,7 +21,7 @@ export function uint8ArrayToBase64(array: Uint8Array): Promise<string> {
export function base64ToUint8Array(base64: string) {
const binaryString = atob(base64);
const binaryArray = binaryString.split('').map(function (char) {
const binaryArray = [...binaryString].map(function (char) {
return char.charCodeAt(0);
});
return new Uint8Array(binaryArray);