From 720d04f1f25a53263eb926cef3552d5091d25915 Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Thu, 1 Dec 2022 13:09:45 -0500 Subject: [PATCH] Fix linting and formatting issues --- core/src/backend.ts | 1 + core/src/backends/git-gateway/implementation.tsx | 2 ++ core/src/backends/github/API.ts | 14 ++++++++++---- core/src/formats/FileFormatter.ts | 6 +----- core/src/integrations/index.ts | 9 ++------- core/src/lib/formatters.ts | 2 +- core/src/lib/util/backendUtil.ts | 1 + core/src/locales/bg/index.ts | 6 ++++-- core/src/locales/cs/index.ts | 6 ++++-- core/src/locales/da/index.ts | 3 ++- core/src/locales/fr/index.ts | 3 ++- core/src/locales/he/index.ts | 3 ++- core/src/locales/it/index.ts | 3 ++- core/src/locales/pl/index.ts | 3 ++- core/src/locales/ro/index.ts | 3 ++- core/src/locales/tr/index.ts | 3 ++- core/src/locales/vi/index.ts | 3 ++- core/src/reducers/entryDraft.ts | 2 +- core/src/reducers/integrations.ts | 6 +----- core/src/store/middleware/waitUntilAction.ts | 1 + core/src/widgets/file/FilePreview.tsx | 2 +- core/src/widgets/file/withFileControl.tsx | 8 ++++---- core/src/widgets/image/ImagePreview.tsx | 2 +- core/src/widgets/list/ListControl.tsx | 2 +- 24 files changed, 52 insertions(+), 42 deletions(-) diff --git a/core/src/backend.ts b/core/src/backend.ts index 237ada0e..26a15025 100644 --- a/core/src/backend.ts +++ b/core/src/backend.ts @@ -364,6 +364,7 @@ export class Backend { async logout() { try { await this.implementation.logout(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (e: any) { console.warn('Error during logout', e.message); } finally { diff --git a/core/src/backends/git-gateway/implementation.tsx b/core/src/backends/git-gateway/implementation.tsx index ac9f3309..395b4a96 100644 --- a/core/src/backends/git-gateway/implementation.tsx +++ b/core/src/backends/git-gateway/implementation.tsx @@ -531,6 +531,7 @@ export default class GitGateway implements BackendClass { async persistEntry(entry: BackendEntry, options: PersistOptions) { const client = await this.getLargeMediaClient(); if (client.enabled) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const assets = (await getLargeMediaFilteredMediaFiles(client, entry.assets)) as any; return this.backend!.persistEntry({ ...entry, assets }, options); } else { @@ -549,6 +550,7 @@ export default class GitGateway implements BackendClass { client, fileObj as File, path, + // eslint-disable-next-line @typescript-eslint/no-explicit-any )) as any; return { ...(await this.backend!.persistMedia(persistMediaArgument, options)), diff --git a/core/src/backends/github/API.ts b/core/src/backends/github/API.ts index 842b3489..a65f64b9 100644 --- a/core/src/backends/github/API.ts +++ b/core/src/backends/github/API.ts @@ -227,6 +227,7 @@ export default class API { responseStatus = response.status; const parsedResponse = await parser(response); return parsedResponse; + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { return this.handleRequestError(error, responseStatus); } @@ -349,6 +350,7 @@ export default class API { size: file.size!, })) ); + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { if (err && err.status === 404) { console.info('This 404 was expected and handled appropriately.'); @@ -360,14 +362,18 @@ export default class API { } async persistFiles(dataFiles: DataFile[], mediaFiles: AssetProxy[], options: PersistOptions) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const files: (DataFile | AssetProxy)[] = mediaFiles.concat(dataFiles as any); const uploadPromises = files.map(file => this.uploadBlob(file)); await Promise.all(uploadPromises); - return this.getDefaultBranch() - .then(branchData => this.updateTree(branchData.commit.sha, files as any)) - .then(changeTree => this.commit(options.commitMessage, changeTree)) - .then(response => this.patchBranch(this.branch, response.sha)); + return ( + this.getDefaultBranch() + // eslint-disable-next-line @typescript-eslint/no-explicit-any + .then(branchData => this.updateTree(branchData.commit.sha, files as any)) + .then(changeTree => this.commit(options.commitMessage, changeTree)) + .then(response => this.patchBranch(this.branch, response.sha)) + ); } async getFileSha(path: string, { repoURL = this.repoURL, branch = this.branch } = {}) { diff --git a/core/src/formats/FileFormatter.ts b/core/src/formats/FileFormatter.ts index 5adea6f3..9647b4cd 100644 --- a/core/src/formats/FileFormatter.ts +++ b/core/src/formats/FileFormatter.ts @@ -1,8 +1,4 @@ export abstract class FileFormatter { abstract fromFile(content: string): object; - abstract toFile( - data: object, - sortedKeys?: string[], - comments?: Record, - ): string; + abstract toFile(data: object, sortedKeys?: string[], comments?: Record): string; } diff --git a/core/src/integrations/index.ts b/core/src/integrations/index.ts index 1a75d96e..077420e6 100644 --- a/core/src/integrations/index.ts +++ b/core/src/integrations/index.ts @@ -12,9 +12,7 @@ interface Integrations { algolia?: Algolia; } -export function resolveIntegrations( - config: IntegrationsConfig | undefined, -) { +export function resolveIntegrations(config: IntegrationsConfig | undefined) { const integrationInstances: Integrations = {}; if (config?.providers?.algolia) { @@ -27,10 +25,7 @@ export function resolveIntegrations( export const getSearchIntegrationProvider = (function () { let integrations: Integrations = {}; - return ( - config: IntegrationsConfig | undefined, - provider: SearchIntegrationProvider, - ) => { + return (config: IntegrationsConfig | undefined, provider: SearchIntegrationProvider) => { if (provider in (config?.providers ?? {})) if (integrations) { return integrations[provider]; diff --git a/core/src/lib/formatters.ts b/core/src/lib/formatters.ts index 30b5a88a..9c0e25c7 100644 --- a/core/src/lib/formatters.ts +++ b/core/src/lib/formatters.ts @@ -11,7 +11,7 @@ import { addFileTemplateFields, compileStringTemplate, keyToPathArray, - parseDateFromEntry + parseDateFromEntry, } from './widgets/stringTemplate'; import type { Collection, Config, Entry, EntryData, Slug } from '../interface'; diff --git a/core/src/lib/util/backendUtil.ts b/core/src/lib/util/backendUtil.ts index 2547c251..0d747937 100644 --- a/core/src/lib/util/backendUtil.ts +++ b/core/src/lib/util/backendUtil.ts @@ -70,6 +70,7 @@ export async function parseResponse { return; } - const getImage = async() => { + const getImage = async () => { const asset = (await getAsset(value, field))?.toString() ?? ''; setAssetSource(asset); }; diff --git a/core/src/widgets/file/withFileControl.tsx b/core/src/widgets/file/withFileControl.tsx index d764605d..e3897149 100644 --- a/core/src/widgets/file/withFileControl.tsx +++ b/core/src/widgets/file/withFileControl.tsx @@ -136,11 +136,11 @@ const SortableImage = SortableElement( ({ itemValue, getAsset, field, onRemove, onReplace }: SortableImageProps) => { const [assetSource, setAssetSource] = useState(''); useEffect(() => { - const getImage = async() => { + const getImage = async () => { const asset = (await getAsset(itemValue, field))?.toString() ?? ''; setAssetSource(asset); }; - + getImage(); // eslint-disable-next-line react-hooks/exhaustive-deps }, [itemValue]); @@ -393,13 +393,13 @@ export default function withFileControl({ forImage = false }: WithImageOptions = return; } - const getImage = async() => { + const getImage = async () => { const newValue = (await getAsset(internalValue, field))?.toString() ?? ''; if (newValue !== internalValue) { setAssetSource(newValue); } }; - + getImage(); // eslint-disable-next-line react-hooks/exhaustive-deps }, [internalValue]); diff --git a/core/src/widgets/image/ImagePreview.tsx b/core/src/widgets/image/ImagePreview.tsx index a9a94ee4..d6eea28d 100644 --- a/core/src/widgets/image/ImagePreview.tsx +++ b/core/src/widgets/image/ImagePreview.tsx @@ -26,7 +26,7 @@ interface ImageAssetProps { function ImageAsset({ getAsset, value, field }: ImageAssetProps) { const [assetSource, setAssetSource] = useState(''); useEffect(() => { - const getImage = async() => { + const getImage = async () => { const asset = (await getAsset(value, field))?.toString() ?? ''; setAssetSource(asset); }; diff --git a/core/src/widgets/list/ListControl.tsx b/core/src/widgets/list/ListControl.tsx index 060d1c55..ccaba04b 100644 --- a/core/src/widgets/list/ListControl.tsx +++ b/core/src/widgets/list/ListControl.tsx @@ -18,7 +18,7 @@ import type { ListField, ObjectValue, ValueOrNestedValue, - WidgetControlProps + WidgetControlProps, } from '../../interface'; const StyledListWrapper = styled('div')`