refactor: migrate to common eslint+prettier configs (#4168)

* refactor: migrate to common eslint+prettier configs

* fix: prettier frontend

* feat: config changes

* fix: lint issues

* fix: lint

* fix: type imports

* fix: cyclical import issue

* fix: lockfile

* fix: missing dep

* fix: switch to tabs

* fix: continue switch to tabs

* fix: rustfmt parity

* fix: moderation lint issue

* fix: lint issues

* fix: ui intl

* fix: lint issues

* Revert "fix: rustfmt parity"

This reverts commit cb99d2376c321d813d4b7fc7e2a213bb30a54711.

* feat: revert last rs
This commit is contained in:
Cal H.
2025-08-14 21:48:38 +01:00
committed by GitHub
parent 82697278dc
commit 2aabcf36ee
702 changed files with 101360 additions and 102020 deletions

View File

@@ -1,46 +1,46 @@
type ImageUploadContext = {
projectID?: string;
context: "project" | "version" | "thread_message" | "report";
};
projectID?: string
context: 'project' | 'version' | 'thread_message' | 'report'
}
interface ImageUploadResponse {
id: string;
url: string;
id: string
url: string
}
export const useImageUpload = async (file: File, ctx: ImageUploadContext) => {
// Make sure file is of type image/png, image/jpeg, image/gif, or image/webp
if (
!file.type.startsWith("image/") ||
!["png", "jpeg", "gif", "webp"].includes(file.type.split("/")[1])
) {
throw new Error("File is not an accepted image type");
}
// Make sure file is of type image/png, image/jpeg, image/gif, or image/webp
if (
!file.type.startsWith('image/') ||
!['png', 'jpeg', 'gif', 'webp'].includes(file.type.split('/')[1])
) {
throw new Error('File is not an accepted image type')
}
// Make sure file is less than 1MB
if (file.size > 1024 * 1024) {
throw new Error("File exceeds the 1MiB size limit");
}
// Make sure file is less than 1MB
if (file.size > 1024 * 1024) {
throw new Error('File exceeds the 1MiB size limit')
}
const qs = new URLSearchParams();
if (ctx.projectID) qs.set("project_id", ctx.projectID);
qs.set("context", ctx.context);
qs.set("ext", file.type.split("/")[1]);
const url = `image?${qs.toString()}`;
const qs = new URLSearchParams()
if (ctx.projectID) qs.set('project_id', ctx.projectID)
qs.set('context', ctx.context)
qs.set('ext', file.type.split('/')[1])
const url = `image?${qs.toString()}`
const response = (await useBaseFetch(url, {
method: "POST",
body: file,
apiVersion: 3,
})) as ImageUploadResponse;
const response = (await useBaseFetch(url, {
method: 'POST',
body: file,
apiVersion: 3,
})) as ImageUploadResponse
// Type check to see if response has a url property and an id property
if (!response?.id || typeof response.id !== "string") {
throw new Error("Unexpected response from server");
}
if (!response?.url || typeof response.url !== "string") {
throw new Error("Unexpected response from server");
}
// Type check to see if response has a url property and an id property
if (!response?.id || typeof response.id !== 'string') {
throw new Error('Unexpected response from server')
}
if (!response?.url || typeof response.url !== 'string') {
throw new Error('Unexpected response from server')
}
return response;
};
return response
}