Skip to content

Commit

Permalink
chore: fix eslint for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nd0ut committed Feb 16, 2024
1 parent c7a15fd commit d5fc472
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 13 additions & 10 deletions packages/image-shrink/src/utils/render/fallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ export const fallback = ({
}): Promise<HTMLCanvasElement> => {
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<HTMLCanvasElement>
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<HTMLCanvasElement>
}

0 comments on commit d5fc472

Please sign in to comment.