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

View File

@@ -4,8 +4,9 @@ import { type EditorHost } from '@blocksuite/affine/block-std';
import {
type AIItemGroupConfig,
EdgelessRootService,
createLitPortal,
HoverController,
} from '@blocksuite/affine/blocks';
import { createLitPortal, HoverController } from '@blocksuite/affine/blocks';
import { WithDisposable } from '@blocksuite/affine/global/utils';
import { flip, offset } from '@floating-ui/dom';
import { css, html, LitElement, nothing } from 'lit';

View File

@@ -6,8 +6,6 @@ import {
type AffineSlashSubMenu,
type AIItemConfig,
DocModeProvider,
} from '@blocksuite/affine/blocks';
import {
AFFINE_AI_PANEL_WIDGET,
AffineSlashMenuWidget,
AIStarIcon,

View File

@@ -6,8 +6,8 @@ import {
DocModeProvider,
type EdgelessRootService,
TelemetryProvider,
NotificationProvider,
} from '@blocksuite/affine/blocks';
import { NotificationProvider } from '@blocksuite/affine/blocks';
import {
type AIChatBlockModel,
type ChatMessage,

View File

@@ -4,8 +4,9 @@ import {
type FrameBlockModel,
ImageBlockModel,
type SurfaceBlockComponent,
BlocksUtils,
EdgelessRootService,
} from '@blocksuite/affine/blocks';
import { BlocksUtils, EdgelessRootService } from '@blocksuite/affine/blocks';
import { assertExists } from '@blocksuite/affine/global/utils';
import {
type BlockModel,

View File

@@ -236,6 +236,7 @@ export function revertUpdate(
} else if (type === 'Array') {
return snapshotDoc.getArray(key);
}
// eslint-disable-next-line array-callback-return
throw new Error('Unknown type');
})
);

View File

@@ -27,12 +27,12 @@ import { DebugLogger } from '@affine/debug';
import { track } from '@affine/track';
import {
type BlockService,
BlockServiceWatcher,
BlockViewIdentifier,
ConfigIdentifier,
type ExtensionType,
type WidgetComponent,
} from '@blocksuite/affine/block-std';
import { BlockServiceWatcher } from '@blocksuite/affine/block-std';
import type {
AffineReference,
DocMode,

View File

@@ -11,8 +11,6 @@ import { GlobalDialogService } from '@affine/core/modules/dialogs';
import {
type CreateCheckoutSessionInput,
SubscriptionRecurring,
} from '@affine/graphql';
import {
SubscriptionPlan,
SubscriptionStatus,
SubscriptionVariant,

View File

@@ -3,7 +3,7 @@ import {
ExplorerService,
ExplorerTreeRoot,
} from '@affine/core/modules/explorer';
import type { FavoriteSupportType } from '@affine/core/modules/favorite';
import type { FavoriteSupportTypeUnion } from '@affine/core/modules/favorite';
import { FavoriteService } from '@affine/core/modules/favorite';
import { useI18n } from '@affine/i18n';
import {
@@ -73,7 +73,7 @@ export const FavoriteNode = ({
}: {
favorite: {
id: string;
type: FavoriteSupportType;
type: FavoriteSupportTypeUnion;
};
}) => {
return favorite.type === 'doc' ? (

View File

@@ -2,8 +2,8 @@ import {
type SubscriptionQuery,
SubscriptionRecurring,
SubscriptionVariant,
SubscriptionPlan,
} from '@affine/graphql';
import { SubscriptionPlan } from '@affine/graphql';
import {
backoffRetry,
catchErrorInto,

View File

@@ -32,4 +32,5 @@ export const EditorSettingSchema = BSEditorSettingSchema.merge(
AffineEditorSettingSchema
);
// eslint-disable-next-line no-redeclare
export type EditorSettingSchema = z.infer<typeof EditorSettingSchema>;

View File

@@ -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(

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;
}
) {

View File

@@ -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 {

View File

@@ -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.

View File

@@ -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}`;
}
}

View File

@@ -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);

View File

@@ -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]>;
};

View File

@@ -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;

View File

@@ -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';

View File

@@ -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);

View File

@@ -16,16 +16,12 @@ export function fuzzyMatch(
query: string,
matchInitial?: boolean
) {
const pureName = name
.trim()
.toLowerCase()
.split('')
const pureName = [...name.trim().toLowerCase()]
.filter(char => char !== ' ')
.join('');
const regex = new RegExp(
query
.split('')
[...query]
.filter(char => char !== ' ')
.map(item => `${escapeRegExp(item)}.*`)
.join(''),