mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-23 20:18:42 +08:00
style: add ban-ts-comment rule (#2738)
(cherry picked from commit 2e975e79dd)
This commit is contained in:
@@ -7,3 +7,4 @@ affine-out
|
|||||||
_next
|
_next
|
||||||
lib
|
lib
|
||||||
.eslintrc.js
|
.eslintrc.js
|
||||||
|
packages/i18n/src/i18n-generated.ts
|
||||||
|
|||||||
+27
-2
@@ -103,7 +103,15 @@ const config = {
|
|||||||
'unused-imports/no-unused-imports': 'error',
|
'unused-imports/no-unused-imports': 'error',
|
||||||
'simple-import-sort/imports': 'error',
|
'simple-import-sort/imports': 'error',
|
||||||
'simple-import-sort/exports': 'error',
|
'simple-import-sort/exports': 'error',
|
||||||
'@typescript-eslint/ban-ts-comment': 0,
|
'@typescript-eslint/ban-ts-comment': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'ts-expect-error': 'allow-with-description',
|
||||||
|
'ts-ignore': true,
|
||||||
|
'ts-nocheck': true,
|
||||||
|
'ts-check': false,
|
||||||
|
},
|
||||||
|
],
|
||||||
'@typescript-eslint/no-restricted-imports': [
|
'@typescript-eslint/no-restricted-imports': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
@@ -143,9 +151,26 @@ const config = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: ['**/__tests__/**/*', '**/*.stories.tsx'],
|
files: [
|
||||||
|
'**/__tests__/**/*',
|
||||||
|
'**/*.stories.tsx',
|
||||||
|
'**/*.spec.ts',
|
||||||
|
'**/tests/**/*',
|
||||||
|
'scripts/**/*',
|
||||||
|
'**/benchmark/**/*',
|
||||||
|
'**/__debug__/**/*',
|
||||||
|
],
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/no-non-null-assertion': 0,
|
'@typescript-eslint/no-non-null-assertion': 0,
|
||||||
|
'@typescript-eslint/ban-ts-comment': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'ts-expect-error': false,
|
||||||
|
'ts-ignore': true,
|
||||||
|
'ts-nocheck': true,
|
||||||
|
'ts-check': false,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...allPackages.map(pkg => ({
|
...allPackages.map(pkg => ({
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ async function dispatch<
|
|||||||
>(
|
>(
|
||||||
namespace: T,
|
namespace: T,
|
||||||
functionName: F,
|
functionName: F,
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
...args: Parameters<WithoutFirstParameter<MainIPCHandlerMap[T][F]>>
|
...args: Parameters<WithoutFirstParameter<MainIPCHandlerMap[T][F]>>
|
||||||
): // @ts-ignore
|
): // @ts-expect-error
|
||||||
ReturnType<MainIPCHandlerMap[T][F]> {
|
ReturnType<MainIPCHandlerMap[T][F]> {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
const handlers = registeredHandlers.get(namespace + ':' + functionName);
|
const handlers = registeredHandlers.get(namespace + ':' + functionName);
|
||||||
assert(handlers);
|
assert(handlers);
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ const electronModule = {
|
|||||||
registeredHandlers.set(name, handlers);
|
registeredHandlers.set(name, handlers);
|
||||||
},
|
},
|
||||||
addListener: (...args: any[]) => {
|
addListener: (...args: any[]) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
electronModule.app.on(...args);
|
electronModule.app.on(...args);
|
||||||
},
|
},
|
||||||
removeListener: () => {},
|
removeListener: () => {},
|
||||||
|
|||||||
@@ -132,9 +132,9 @@ export function createApplicationMenu() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// @ts-ignore The snippet is copied from Electron official docs.
|
// @ts-expect-error: The snippet is copied from Electron official docs.
|
||||||
// It's working as expected. No idea why it contains type errors.
|
// It's working as expected. No idea why it contains type errors.
|
||||||
// Just ignore for now.
|
// Just ignore for now.
|
||||||
const menu = Menu.buildFromTemplate(template);
|
const menu = Menu.buildFromTemplate(template);
|
||||||
Menu.setApplicationMenu(menu);
|
Menu.setApplicationMenu(menu);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const electronModule = {
|
|||||||
registeredHandlers.set(name, handlers);
|
registeredHandlers.set(name, handlers);
|
||||||
},
|
},
|
||||||
addListener: (...args: any[]) => {
|
addListener: (...args: any[]) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
electronModule.app.on(...args);
|
electronModule.app.on(...args);
|
||||||
},
|
},
|
||||||
removeListener: () => {},
|
removeListener: () => {},
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ const page = blockSuiteWorkspace.createPage({ id: 'page0' });
|
|||||||
|
|
||||||
const Editor: React.FC = () => {
|
const Editor: React.FC = () => {
|
||||||
const onLoad = useCallback((page: Page, editor: EditorContainer) => {
|
const onLoad = useCallback((page: Page, editor: EditorContainer) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
globalThis.page = page;
|
globalThis.page = page;
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
globalThis.editor = editor;
|
globalThis.editor = editor;
|
||||||
return () => void 0;
|
return () => void 0;
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ const SetDBLocationContent = ({
|
|||||||
if (result?.filePath) {
|
if (result?.filePath) {
|
||||||
onConfirmLocation(result.filePath);
|
onConfirmLocation(result.filePath);
|
||||||
} else if (result?.error) {
|
} else if (result?.error) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error: result.error is dynamic so the type is unknown
|
||||||
toast(t[result.error]());
|
toast(t[result.error]());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -278,7 +278,7 @@ export const CreateWorkspaceModal = ({
|
|||||||
setStep('set-syncing-mode');
|
setStep('set-syncing-mode');
|
||||||
} else if (result.error || result.canceled) {
|
} else if (result.error || result.canceled) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error: result.error is dynamic so the type is unknown
|
||||||
toast(t[result.error]());
|
toast(t[result.error]());
|
||||||
}
|
}
|
||||||
onClose();
|
onClose();
|
||||||
@@ -294,71 +294,92 @@ export const CreateWorkspaceModal = ({
|
|||||||
};
|
};
|
||||||
}, [mode, onClose, t]);
|
}, [mode, onClose, t]);
|
||||||
|
|
||||||
|
const onConfirmEnableCloudSyncing = useCallback(
|
||||||
|
(enableCloudSyncing: boolean) => {
|
||||||
|
(async function () {
|
||||||
|
if (!config.enableLegacyCloud && enableCloudSyncing) {
|
||||||
|
setOpenDisableCloudAlertModal(true);
|
||||||
|
} else {
|
||||||
|
let id = addedId;
|
||||||
|
// syncing mode is also the last step
|
||||||
|
if (addedId && mode === 'add') {
|
||||||
|
await addLocalWorkspace(addedId);
|
||||||
|
} else if (mode === 'new' && workspaceName) {
|
||||||
|
id = await createLocalWorkspace(workspaceName);
|
||||||
|
// if dbFileLocation is set, move db file to that location
|
||||||
|
if (dbFileLocation) {
|
||||||
|
await window.apis?.dialog.moveDBFile(id, dbFileLocation);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error('invalid state');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (id) {
|
||||||
|
onCreate(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})().catch(e => {
|
||||||
|
logger.error(e);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[
|
||||||
|
addLocalWorkspace,
|
||||||
|
addedId,
|
||||||
|
createLocalWorkspace,
|
||||||
|
dbFileLocation,
|
||||||
|
mode,
|
||||||
|
onCreate,
|
||||||
|
setOpenDisableCloudAlertModal,
|
||||||
|
workspaceName,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
const nameWorkspaceNode =
|
||||||
|
step === 'name-workspace' ? (
|
||||||
|
<NameWorkspaceContent
|
||||||
|
// go to previous step instead?
|
||||||
|
onClose={onClose}
|
||||||
|
onConfirmName={async name => {
|
||||||
|
setWorkspaceName(name);
|
||||||
|
if (environment.isDesktop) {
|
||||||
|
setStep('set-syncing-mode');
|
||||||
|
} else {
|
||||||
|
// this will be the last step for web for now
|
||||||
|
// fix me later
|
||||||
|
const id = await createLocalWorkspace(name);
|
||||||
|
onCreate(id);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null;
|
||||||
|
|
||||||
|
const setDBLocationNode =
|
||||||
|
step === 'set-db-location' ? (
|
||||||
|
<SetDBLocationContent
|
||||||
|
onConfirmLocation={dir => {
|
||||||
|
setDBFileLocation(dir);
|
||||||
|
setStep('name-workspace');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null;
|
||||||
|
|
||||||
|
const setSyncingModeNode =
|
||||||
|
step === 'set-syncing-mode' ? (
|
||||||
|
<SetSyncingModeContent
|
||||||
|
mode={mode}
|
||||||
|
onConfirmMode={onConfirmEnableCloudSyncing}
|
||||||
|
/>
|
||||||
|
) : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={mode !== false && !!step} onClose={onClose}>
|
<Modal open={mode !== false && !!step} onClose={onClose}>
|
||||||
<ModalWrapper width={560} style={{ padding: '10px' }}>
|
<ModalWrapper width={560} style={{ padding: '10px' }}>
|
||||||
<div className={style.header}>
|
<div className={style.header}>
|
||||||
<ModalCloseButton
|
<ModalCloseButton top={6} right={6} onClick={onClose} />
|
||||||
top={6}
|
|
||||||
right={6}
|
|
||||||
onClick={() => {
|
|
||||||
onClose();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{step === 'name-workspace' && (
|
{nameWorkspaceNode}
|
||||||
<NameWorkspaceContent
|
{setDBLocationNode}
|
||||||
// go to previous step instead?
|
{setSyncingModeNode}
|
||||||
onClose={onClose}
|
|
||||||
onConfirmName={async name => {
|
|
||||||
setWorkspaceName(name);
|
|
||||||
if (environment.isDesktop) {
|
|
||||||
setStep('set-syncing-mode');
|
|
||||||
} else {
|
|
||||||
// this will be the last step for web for now
|
|
||||||
// fix me later
|
|
||||||
const id = await createLocalWorkspace(name);
|
|
||||||
onCreate(id);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{step === 'set-db-location' && (
|
|
||||||
<SetDBLocationContent
|
|
||||||
onConfirmLocation={dir => {
|
|
||||||
setDBFileLocation(dir);
|
|
||||||
setStep('name-workspace');
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{step === 'set-syncing-mode' && (
|
|
||||||
<SetSyncingModeContent
|
|
||||||
mode={mode}
|
|
||||||
onConfirmMode={async enableCloudSyncing => {
|
|
||||||
if (!config.enableLegacyCloud && enableCloudSyncing) {
|
|
||||||
setOpenDisableCloudAlertModal(true);
|
|
||||||
} else {
|
|
||||||
let id = addedId;
|
|
||||||
// syncing mode is also the last step
|
|
||||||
if (addedId && mode === 'add') {
|
|
||||||
await addLocalWorkspace(addedId);
|
|
||||||
} else if (mode === 'new' && workspaceName) {
|
|
||||||
id = await createLocalWorkspace(workspaceName);
|
|
||||||
// if dbFileLocation is set, move db file to that location
|
|
||||||
if (dbFileLocation) {
|
|
||||||
await window.apis?.dialog.moveDBFile(id, dbFileLocation);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.error('invalid state');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (id) {
|
|
||||||
onCreate(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</ModalWrapper>
|
</ModalWrapper>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-2
@@ -109,8 +109,7 @@ const AffineRemoteCollaborationPanel: React.FC<
|
|||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
// FIXME: remove ignore
|
// FIXME: remove ignore
|
||||||
|
|
||||||
// @ts-ignore
|
await removeMember(Number(member.id));
|
||||||
await removeMember(member.id);
|
|
||||||
toast(
|
toast(
|
||||||
t['Member has been removed']({
|
t['Member has been removed']({
|
||||||
name: user.name,
|
name: user.name,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const ExportPanel = () => {
|
|||||||
if (id) {
|
if (id) {
|
||||||
const result = await window.apis?.dialog.saveDBFileAs(id);
|
const result = await window.apis?.dialog.saveDBFileAs(id);
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error: result.error is dynamic
|
||||||
toast(t[result.error]());
|
toast(t[result.error]());
|
||||||
} else if (!result?.canceled) {
|
} else if (!result?.canceled) {
|
||||||
toast(t['Export success']());
|
toast(t['Export success']());
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ const useShowOpenDBFile = (workspaceId: string) => {
|
|||||||
window.apis.workspace.getMeta(workspaceId).then(meta => {
|
window.apis.workspace.getMeta(workspaceId).then(meta => {
|
||||||
setShow(!!meta.secondaryDBPath);
|
setShow(!!meta.secondaryDBPath);
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
return window.events.workspace.onMetaChange((newMeta: any) => {
|
||||||
return window.events.workspace.onMetaChange(newMeta => {
|
|
||||||
if (newMeta.workspaceId === workspaceId) {
|
if (newMeta.workspaceId === workspaceId) {
|
||||||
const meta = newMeta.meta;
|
const meta = newMeta.meta;
|
||||||
setShow(!!meta.secondaryDBPath);
|
setShow(!!meta.secondaryDBPath);
|
||||||
@@ -74,7 +73,7 @@ export const GeneralPanel: React.FC<PanelProps> = ({
|
|||||||
if (!result?.error && !result?.canceled) {
|
if (!result?.error && !result?.canceled) {
|
||||||
toast(t['Move folder success']());
|
toast(t['Move folder success']());
|
||||||
} else if (result?.error) {
|
} else if (result?.error) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error: result.error is dynamic
|
||||||
toast(t[result.error]());
|
toast(t[result.error]());
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import { css, displayFlex, keyframes, styled } from '@affine/component';
|
import { css, displayFlex, keyframes, styled } from '@affine/component';
|
||||||
// @ts-ignore
|
// @ts-expect-error: no types for css-spring
|
||||||
import spring, { toString } from 'css-spring';
|
import spring, { toString } from 'css-spring';
|
||||||
|
|
||||||
const ANIMATE_DURATION = 400;
|
const ANIMATE_DURATION = 400;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ export const PurePopper = (props: PurePopperProps) => {
|
|||||||
} = props;
|
} = props;
|
||||||
const [arrowRef, setArrowRef] = useState<HTMLElement | null>();
|
const [arrowRef, setArrowRef] = useState<HTMLElement | null>();
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
return (
|
return (
|
||||||
<BasicStyledPopper
|
<BasicStyledPopper
|
||||||
zIndex={zIndex}
|
zIndex={zIndex}
|
||||||
|
|||||||
@@ -182,12 +182,19 @@ const createSQLiteProvider = (
|
|||||||
const connect = () => {
|
const connect = () => {
|
||||||
logger.info('connecting sqlite provider', blockSuiteWorkspace.id);
|
logger.info('connecting sqlite provider', blockSuiteWorkspace.id);
|
||||||
blockSuiteWorkspace.doc.on('update', handleUpdate);
|
blockSuiteWorkspace.doc.on('update', handleUpdate);
|
||||||
// @ts-expect-error
|
unsubscribe = events.db.onExternalUpdate(
|
||||||
unsubscribe = events.db.onExternalUpdate(({ update, workspaceId }) => {
|
({
|
||||||
if (workspaceId === blockSuiteWorkspace.id) {
|
update,
|
||||||
Y.applyUpdate(blockSuiteWorkspace.doc, update, sqliteOrigin);
|
workspaceId,
|
||||||
|
}: {
|
||||||
|
workspaceId: string;
|
||||||
|
update: Uint8Array;
|
||||||
|
}) => {
|
||||||
|
if (workspaceId === blockSuiteWorkspace.id) {
|
||||||
|
Y.applyUpdate(blockSuiteWorkspace.doc, update, sqliteOrigin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
connected = true;
|
connected = true;
|
||||||
logger.info('connecting sqlite done', blockSuiteWorkspace.id);
|
logger.info('connecting sqlite done', blockSuiteWorkspace.id);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
{ "path": "../y-indexeddb" },
|
{ "path": "../y-indexeddb" },
|
||||||
{ "path": "../env" },
|
{ "path": "../env" },
|
||||||
{ "path": "../debug" },
|
{ "path": "../debug" },
|
||||||
{ "path": "../hooks" },
|
{ "path": "../hooks" }
|
||||||
{ "path": "../../apps/electron" }
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ export async function loginUser(
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
await page.evaluate(async token => {
|
await page.evaluate(async token => {
|
||||||
// @ts-ignore
|
|
||||||
globalThis.setLogin(token);
|
globalThis.setLogin(token);
|
||||||
}, token);
|
}, token);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ test('should have page0', async ({ page }) => {
|
|||||||
await page.goto('http://localhost:8080/_debug/init-page');
|
await page.goto('http://localhost:8080/_debug/init-page');
|
||||||
await page.waitForSelector('v-line');
|
await page.waitForSelector('v-line');
|
||||||
const pageId = await page.evaluate(async () => {
|
const pageId = await page.evaluate(async () => {
|
||||||
// @ts-ignore
|
|
||||||
return globalThis.page.id;
|
return globalThis.page.id;
|
||||||
});
|
});
|
||||||
expect(pageId).toBe('page0');
|
expect(pageId).toBe('page0');
|
||||||
|
|||||||
Reference in New Issue
Block a user