mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-15 15:55:56 +02:00
refactor: clear a few ESLint warnings (#5808)
* refactor: clear a few ESLint warnings Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Fix
This commit is contained in:
parent
68c970175a
commit
4b2152a964
9 changed files with 35 additions and 26 deletions
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
declare module '@generated/client-modules' {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const clientModules: readonly any[];
|
||||
export default clientModules;
|
||||
}
|
||||
|
@ -26,6 +27,7 @@ declare module '@generated/site-metadata' {
|
|||
|
||||
declare module '@generated/registry' {
|
||||
const registry: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
readonly [key: string]: [() => Promise<any>, string, string];
|
||||
};
|
||||
export default registry;
|
||||
|
@ -50,7 +52,8 @@ declare module '@generated/routesChunkNames' {
|
|||
}
|
||||
|
||||
declare module '@generated/globalData' {
|
||||
const globalData: Record<string, unknown>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const globalData: Record<string, any>;
|
||||
export default globalData;
|
||||
}
|
||||
|
||||
|
@ -89,7 +92,7 @@ declare module '@theme/Loading' {
|
|||
}
|
||||
|
||||
declare module '@theme/NotFound' {
|
||||
export default function NotFound(props: any): JSX.Element;
|
||||
export default function NotFound(): JSX.Element;
|
||||
}
|
||||
|
||||
declare module '@theme/Root' {
|
||||
|
@ -292,6 +295,7 @@ declare module '@docusaurus/useGlobalData' {
|
|||
pluginId?: string,
|
||||
): T;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function useGlobalData(): Record<string, any>;
|
||||
export default useGlobalData;
|
||||
}
|
||||
|
|
|
@ -59,13 +59,13 @@ function validateCollectedRedirects(
|
|||
redirects: RedirectMetadata[],
|
||||
pluginContext: PluginContext,
|
||||
) {
|
||||
const redirectValidationErrors: string[] = redirects
|
||||
const redirectValidationErrors = redirects
|
||||
.map((redirect) => {
|
||||
try {
|
||||
validateRedirect(redirect);
|
||||
return undefined;
|
||||
} catch (e: any) {
|
||||
return e.message;
|
||||
} catch (e) {
|
||||
return (e as Error).message;
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
|
|
@ -148,7 +148,7 @@ function DocPage(props: Props): JSX.Element {
|
|||
matchPath(location.pathname, docRoute),
|
||||
);
|
||||
if (!currentDocRoute) {
|
||||
return <NotFound {...props} />;
|
||||
return <NotFound />;
|
||||
}
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -26,8 +26,8 @@ function getBrowserStorage(
|
|||
} else {
|
||||
try {
|
||||
return window[storageType];
|
||||
} catch (e: any) {
|
||||
logOnceBrowserStorageNotAvailableWarning(e);
|
||||
} catch (e) {
|
||||
logOnceBrowserStorageNotAvailableWarning(e as Error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,9 +181,9 @@ export async function parseMarkdownFile(
|
|||
const markdownString = await fs.readFile(source, 'utf-8');
|
||||
try {
|
||||
return parseMarkdownString(markdownString, options);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Error while parsing Markdown file ${source}: "${e.message}".`,
|
||||
`Error while parsing Markdown file ${source}: "${(e as Error).message}".`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,9 +55,10 @@ export async function readTranslationFileContent(
|
|||
const content = JSON.parse(await fs.readFile(filePath, 'utf8'));
|
||||
ensureTranslationFileContent(content);
|
||||
return content;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
throw new Error(`Invalid translation file at ${filePath}.\n${e.message}`);
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Invalid translation file at ${filePath}.\n${(e as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
|
|
|
@ -157,10 +157,15 @@ export async function extractSourceCodeFileTranslations(
|
|||
filename: sourceCodeFilePath,
|
||||
}) as Node;
|
||||
|
||||
return await extractSourceCodeAstTranslations(ast, sourceCodeFilePath);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
e.message = `Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}\n${e.message}`;
|
||||
const translations = await extractSourceCodeAstTranslations(
|
||||
ast,
|
||||
sourceCodeFilePath,
|
||||
);
|
||||
return translations;
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
e.message = `Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}\n${e.message}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,11 +234,10 @@ class CleanWebpackPlugin {
|
|||
console.warn(`clean-webpack-plugin: removed ${filename}`);
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
const needsForce =
|
||||
/Cannot delete files\/folders outside the current working directory\./.test(
|
||||
error.message,
|
||||
(error as Error).message,
|
||||
);
|
||||
|
||||
if (needsForce) {
|
||||
|
|
|
@ -457,21 +457,21 @@ function validateKeyAndCerts({
|
|||
try {
|
||||
// publicEncrypt will throw an error with an invalid cert
|
||||
encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`,
|
||||
`The certificate "${chalk.yellow(crtFile)}" is invalid.\n${
|
||||
(err as Error).message
|
||||
}`,
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
// privateDecrypt will throw an error with an invalid key
|
||||
crypto.privateDecrypt(key, encrypted);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
|
||||
err.message
|
||||
(err as Error).message
|
||||
}`,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue