From d5fc4725cd78e29d224beb8d5704ff2330dbed59 Mon Sep 17 00:00:00 2001 From: nd0ut Date: Fri, 16 Feb 2024 18:00:19 +0300 Subject: [PATCH] chore: fix eslint for tests --- .eslintrc.json | 26 +++++++++++++++++++ .../image-shrink/src/utils/render/fallback.ts | 23 +++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index a06e1bd21..71f930e0a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -33,6 +33,32 @@ } } }, + { + "files": [ + "**/*.test.ts" + ], + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint", + "import" + ], + "extends": [ + "plugin:import/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:import/typescript" + ], + "parserOptions": { + "sourceType": "module", + "project": "./tsconfig.test.json" + }, + "settings": { + "import/internal-regex": "^@uploadcare/", + "import/extensions": [".ts", ".js"], + "import/parsers": { + "@typescript-eslint/parser": [".ts", ".js"] + } + } + }, { "files": [ "**/*.js", diff --git a/packages/image-shrink/src/utils/render/fallback.ts b/packages/image-shrink/src/utils/render/fallback.ts index e9cda6757..f553e49ea 100644 --- a/packages/image-shrink/src/utils/render/fallback.ts +++ b/packages/image-shrink/src/utils/render/fallback.ts @@ -56,14 +56,17 @@ export const fallback = ({ }): Promise => { const steps = calcShrinkSteps(sourceW, targetW, targetH, step) - return steps.reduce((chain, [w, h]) => { - return chain.then((canvas) => { - return ( - testCanvasSize(w, h) - .then(() => canvasResize(canvas, w, h)) - // Here we assume that at least one step will be supported and HTMLImageElement will be converted to HTMLCanvasElement - .catch(() => canvas as unknown as HTMLCanvasElement) - ) - }) - }, Promise.resolve(img as HTMLCanvasElement | HTMLImageElement)) as Promise + return steps.reduce( + (chain, [w, h]) => { + return chain.then((canvas) => { + return ( + testCanvasSize(w, h) + .then(() => canvasResize(canvas, w, h)) + // Here we assume that at least one step will be supported and HTMLImageElement will be converted to HTMLCanvasElement + .catch(() => canvas as unknown as HTMLCanvasElement) + ) + }) + }, + Promise.resolve(img as HTMLCanvasElement | HTMLImageElement) + ) as Promise }