Skip to content

Commit

Permalink
Fix issues found by Biome
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jun 5, 2024
1 parent 6223d08 commit f936596
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 26 deletions.
8 changes: 4 additions & 4 deletions packages/react-pdf/src/Page.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ describe('Page', () => {
const viewport = page.getViewport({ scale: 1 });

// Expect the canvas layer not to be rotated
expect(parseInt(width, 10)).toBe(Math.floor(viewport.width));
expect(parseInt(height, 10)).toBe(Math.floor(viewport.height));
expect(Number.parseInt(width, 10)).toBe(Math.floor(viewport.width));
expect(Number.parseInt(height, 10)).toBe(Math.floor(viewport.height));
});

it('requests page to be rendered with given rotation when given rotate prop', async () => {
Expand All @@ -471,8 +471,8 @@ describe('Page', () => {
const viewport = page.getViewport({ scale: 1, rotation: rotate });

// Expect the canvas layer to be rotated
expect(parseInt(width, 10)).toBe(Math.floor(viewport.width));
expect(parseInt(height, 10)).toBe(Math.floor(viewport.height));
expect(Number.parseInt(width, 10)).toBe(Math.floor(viewport.width));
expect(Number.parseInt(height, 10)).toBe(Math.floor(viewport.height));
});

it('requests page to be rendered in canvas mode by default', async () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/react-pdf/src/Page/AnnotationLayer.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ describe('AnnotationLayer', () => {
.map((item) => item.firstChild as HTMLElement)
.filter((item) => item.tagName === 'A');

annotationLinkItems.forEach((link) => expect(link.getAttribute('target')).toBe(target));
for (const link of annotationLinkItems) {
expect(link.getAttribute('target')).toBe(target);
}
},
);

Expand Down Expand Up @@ -280,7 +282,9 @@ describe('AnnotationLayer', () => {
.map((item) => item.firstChild as HTMLElement)
.filter((item) => item.tagName === 'A');

annotationLinkItems.forEach((link) => expect(link.getAttribute('rel')).toBe(rel));
for (const link of annotationLinkItems) {
expect(link.getAttribute('rel')).toBe(rel);
}
},
);

Expand Down
2 changes: 1 addition & 1 deletion packages/react-pdf/src/Page/AnnotationLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function AnnotationLayer() {
const layerElement = useRef<HTMLDivElement>(null);

warning(
parseInt(
Number.parseInt(
window.getComputedStyle(document.body).getPropertyValue('--react-pdf-annotation-layer'),
10,
) === 1,
Expand Down
10 changes: 1 addition & 9 deletions packages/react-pdf/src/Page/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,7 @@ export default function Canvas(props: CanvasProps) {
drawPageOnCanvas,
// Ommitted callbacks so they are not called every time they change
// eslint-disable-next-line react-hooks/exhaustive-deps
[
canvasBackground,
canvasElement,
devicePixelRatio,
page,
renderForms,
renderViewport,
viewport,
],
[canvasBackground, page, renderForms, renderViewport, viewport],
);

const cleanup = useCallback(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-pdf/src/Page/TextLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function TextLayer() {
const endElement = useRef<HTMLElement | undefined>(undefined);

warning(
parseInt(
Number.parseInt(
window.getComputedStyle(document.body).getPropertyValue('--react-pdf-text-layer'),
10,
) === 1,
Expand Down
8 changes: 4 additions & 4 deletions packages/react-pdf/src/Thumbnail.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ describe('Thumbnail', () => {
const viewport = page.getViewport({ scale: 1 });

// Expect the canvas layer not to be rotated
expect(parseInt(width, 10)).toBe(Math.floor(viewport.width));
expect(parseInt(height, 10)).toBe(Math.floor(viewport.height));
expect(Number.parseInt(width, 10)).toBe(Math.floor(viewport.width));
expect(Number.parseInt(height, 10)).toBe(Math.floor(viewport.height));
});

it('requests page to be rendered with given rotation when given rotate prop', async () => {
Expand All @@ -383,8 +383,8 @@ describe('Thumbnail', () => {
const viewport = page.getViewport({ scale: 1, rotation: rotate });

// Expect the canvas layer to be rotated
expect(parseInt(width, 10)).toBe(Math.floor(viewport.width));
expect(parseInt(height, 10)).toBe(Math.floor(viewport.height));
expect(Number.parseInt(width, 10)).toBe(Math.floor(viewport.width));
expect(Number.parseInt(height, 10)).toBe(Math.floor(viewport.height));
});

it('requests page to be rendered in canvas mode by default', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-pdf/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function displayWorkerWarning() {
}

export function cancelRunningTask(runningTask?: { cancel?: () => void } | null) {
if (runningTask && runningTask.cancel) runningTask.cancel();
if (runningTask?.cancel) runningTask.cancel();
}

export function makePageCallback(page: PDFPageProxy, scale: number): PageCallback {
Expand Down
2 changes: 1 addition & 1 deletion test/CustomRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function CustomRenderer() {
};
}

useEffect(drawPageOnCanvas, [canvasElement, page, viewport]);
useEffect(drawPageOnCanvas, [page, viewport]);

return (
<canvas
Expand Down
4 changes: 1 addition & 3 deletions test/Test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export function readAsDataURL(file: Blob): Promise<string> {
});
}

/* eslint-disable no-console */

export default function Test() {
const [canvasBackground, setCanvasBackground] = useState<string>();
const [devicePixelRatio, setDevicePixelRatio] = useState<number>();
Expand Down Expand Up @@ -301,7 +299,7 @@ export default function Test() {
inputRef={
pageNumber === index + 1
? (ref) => {
ref && ref.scrollIntoView();
ref?.scrollIntoView();
}
: null
}
Expand Down

0 comments on commit f936596

Please sign in to comment.