Addressing eslint errors

This commit is contained in:
Rakshit Tiwari 2025-06-16 16:42:11 +05:30
parent a77ad276f1
commit b6de2a8557
4 changed files with 47 additions and 46 deletions

View file

@ -19,6 +19,7 @@ export const useClientSideResize = () => {
}); });
// Safe access to clientSideImageResize config with fallbacks // Safe access to clientSideImageResize config with fallbacks
// eslint-disable-next-line react-hooks/exhaustive-deps
const config = (fileConfig as any)?.clientSideImageResize ?? { const config = (fileConfig as any)?.clientSideImageResize ?? {
enabled: false, enabled: false,
maxWidth: 1900, maxWidth: 1900,
@ -66,7 +67,6 @@ export const useClientSideResize = () => {
return { file: result.file, resized: true, result }; return { file: result.file, resized: true, result };
} catch (error) { } catch (error) {
console.warn('Client-side image resizing failed:', error); console.warn('Client-side image resizing failed:', error);
// Return original file on error
return { file, resized: false }; return { file, resized: false };
} }
}, },

View file

@ -60,7 +60,7 @@ function calculateDimensions(
maxWidth: number, maxWidth: number,
maxHeight: number, maxHeight: number,
): { width: number; height: number } { ): { width: number; height: number } {
let { width, height } = { width: originalWidth, height: originalHeight }; const { width, height } = { width: originalWidth, height: originalHeight };
// If image is smaller than max dimensions, don't upscale // If image is smaller than max dimensions, don't upscale
if (width <= maxWidth && height <= maxHeight) { if (width <= maxWidth && height <= maxHeight) {
@ -196,7 +196,8 @@ export function shouldResizeImage(
fileSizeLimit: number = 512 * 1024 * 1024, // 512MB default fileSizeLimit: number = 512 * 1024 * 1024, // 512MB default
): boolean { ): boolean {
// Don't resize if file is already small // Don't resize if file is already small
if (file.size < fileSizeLimit * 0.1) { // Less than 10% of limit if (file.size < fileSizeLimit * 0.1) {
// Less than 10% of limit
return false; return false;
} }