Skip to content

Commit 08ce7f7

Browse files
committed
chore: fix all lint errors and warnings across tests and src
Resolve 88 ESLint problems (82 errors, 6 warnings): - Replace `i++` with `i += 1` (no-plusplus) - Add `type="button"` to test buttons (react/button-has-type) - Remove unused imports and variables (@typescript-eslint/no-unused-vars) - Suppress class-methods-use-this on ResizeObserver mocks - Convert inline require() to top-level imports (global-require) - Fix duplicate re-exports in __tests__/utils/index.ts (import/export) - Remove irregular whitespace in JSDoc (no-irregular-whitespace) - Suppress react/no-array-index-key and no-nested-ternary in stories - Add eslint-disable for react/require-default-props in test examples - Fix react-hooks/exhaustive-deps: move disable comments to dep arrays, capture ref values in effect variables, remove unnecessary deps - Convert unnamed function expressions to arrow functions (func-names) Made-with: Cursor
1 parent f3b5afd commit 08ce7f7

48 files changed

Lines changed: 303 additions & 217 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

__tests__/examples/extreme-examples.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable react/require-default-props */
12
import React from "react";
23

34
import {

__tests__/features/base/interactions.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe("Base [Interactions]", () => {
1111
render(
1212
<TransformWrapper>
1313
<TransformComponent>
14-
<button data-testid="nested-btn" onClick={onClick}>
14+
<button type="button" data-testid="nested-btn" onClick={onClick}>
1515
Click me
1616
</button>
1717
</TransformComponent>
@@ -27,7 +27,7 @@ describe("Base [Interactions]", () => {
2727
render(
2828
<TransformWrapper>
2929
<TransformComponent>
30-
<button data-testid="nested-btn" onClick={onClick}>
30+
<button type="button" data-testid="nested-btn" onClick={onClick}>
3131
Click me
3232
</button>
3333
</TransformComponent>
@@ -68,7 +68,7 @@ describe("Base [Interactions]", () => {
6868
});
6969
it("should trigger onZoom callback on zoom out button click", async () => {
7070
const onZoom = jest.fn();
71-
const { zoomOutBtn, ref } = renderApp({ onZoom, initialScale: 2 });
71+
const { zoomOutBtn } = renderApp({ onZoom, initialScale: 2 });
7272

7373
fireEvent(zoomOutBtn, new MouseEvent("click", { bubbles: true }));
7474
expect(onZoom).toHaveBeenCalled();

__tests__/features/controls/controls.limits.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("Controls [Limits]", () => {
77
it("should not exceed maxScale", async () => {
88
const { ref, zoomInBtn } = renderApp({ maxScale: 2 });
99

10-
for (let i = 0; i < 10; i++) {
10+
for (let i = 0; i < 10; i += 1) {
1111
fireEvent(zoomInBtn, new MouseEvent("click", { bubbles: true }));
1212
}
1313

@@ -25,7 +25,7 @@ describe("Controls [Limits]", () => {
2525
minScale: 0.5,
2626
});
2727

28-
for (let i = 0; i < 10; i++) {
28+
for (let i = 0; i < 10; i += 1) {
2929
fireEvent(zoomOutBtn, new MouseEvent("click", { bubbles: true }));
3030
}
3131

@@ -38,7 +38,7 @@ describe("Controls [Limits]", () => {
3838
it("should not go below default minScale of 1", async () => {
3939
const { ref, zoomOutBtn } = renderApp({ initialScale: 2 });
4040

41-
for (let i = 0; i < 10; i++) {
41+
for (let i = 0; i < 10; i += 1) {
4242
fireEvent(zoomOutBtn, new MouseEvent("click", { bubbles: true }));
4343
}
4444

__tests__/features/controls/controls.ref.spec.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ describe("Controls [Ref]", () => {
1212
});
1313

1414
await waitFor(() => {
15-
expect(content.style.transform).toBe(
16-
"translate(100px, 50px) scale(2)",
17-
);
15+
expect(content.style.transform).toBe("translate(100px, 50px) scale(2)");
1816
});
1917
});
2018

__tests__/features/minimap/minimap.panning.spec.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ describe("MiniMap [Panning]", () => {
6767
});
6868
});
6969

70-
expect(content.style.transform).not.toBe(
71-
"translate(0px, 0px) scale(1)",
72-
);
70+
expect(content.style.transform).not.toBe("translate(0px, 0px) scale(1)");
7371
});
7472

7573
it("should stop updating position after mouseup", () => {

__tests__/features/minimap/minimap.sync.spec.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ describe("MiniMap [Sync]", () => {
9898
fireEvent.mouseMove(content, { clientX: -100, clientY: -50, buttons: 1 });
9999
fireEvent.mouseUp(content);
100100

101-
expect(content.style.transform).toBe(
102-
"translate(-100px, -50px) scale(1)",
103-
);
101+
expect(content.style.transform).toBe("translate(-100px, -50px) scale(1)");
104102

105103
// previewScale = 0.2, x = -(-100) * 0.2 = 20, y = -(-50) * 0.2 = 10
106104
expect(minimapPreview.style.transform).toBe(
@@ -116,7 +114,11 @@ describe("MiniMap [Sync]", () => {
116114

117115
userEvent.hover(content);
118116
fireEvent.mouseDown(content, { clientX: 0, clientY: 0, buttons: 1 });
119-
fireEvent.mouseMove(content, { clientX: -100, clientY: -100, buttons: 1 });
117+
fireEvent.mouseMove(content, {
118+
clientX: -100,
119+
clientY: -100,
120+
buttons: 1,
121+
});
120122
fireEvent.mouseUp(content);
121123

122124
expect(minimapPreview.style.width).toBe(initialWidth);
@@ -133,7 +135,7 @@ describe("MiniMap [Sync]", () => {
133135

134136
userEvent.hover(content);
135137

136-
for (let i = 0; i < 10; i++) {
138+
for (let i = 0; i < 10; i += 1) {
137139
fireEvent(
138140
content,
139141
new WheelEvent("wheel", { bubbles: true, deltaY: -1 }),
@@ -150,7 +152,7 @@ describe("MiniMap [Sync]", () => {
150152
userEvent.hover(content);
151153

152154
// Zoom in first
153-
for (let i = 0; i < 10; i++) {
155+
for (let i = 0; i < 10; i += 1) {
154156
fireEvent(
155157
content,
156158
new WheelEvent("wheel", { bubbles: true, deltaY: -1 }),
@@ -160,7 +162,7 @@ describe("MiniMap [Sync]", () => {
160162
const zoomedInWidth = parseFloat(minimapPreview.style.width);
161163

162164
// Zoom back out
163-
for (let i = 0; i < 10; i++) {
165+
for (let i = 0; i < 10; i += 1) {
164166
fireEvent(
165167
content,
166168
new WheelEvent("wheel", { bubbles: true, deltaY: 1 }),

__tests__/features/props/auto-alignment-props.spec.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ describe("ReactZoomPanPinchProps.autoAlignment", () => {
2525
"translate(-100px, -100px) scale(1)",
2626
);
2727
await waitFor(() => {
28-
expect(content.style.transform).toBe(
29-
"translate(0px, 0px) scale(1)",
30-
);
28+
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
3129
});
3230
});
3331
});

__tests__/features/props/bounds-positions.spec.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { renderApp } from "../../utils";
55
const NativeResizeObserver = global.ResizeObserver;
66

77
beforeAll(() => {
8+
/* eslint-disable class-methods-use-this */
89
global.ResizeObserver = class {
910
observe() {}
1011
disconnect() {}
1112
unobserve() {}
1213
} as unknown as typeof ResizeObserver;
14+
/* eslint-enable class-methods-use-this */
1315
});
1416

1517
afterAll(() => {
@@ -86,9 +88,7 @@ describe("ReactZoomPanPinchProps.limitToBounds", () => {
8688
limitToBounds: false,
8789
});
8890
pan({ x: -200, y: -200 });
89-
expect(content.style.transform).toBe(
90-
"translate(-200px, -200px) scale(1)",
91-
);
91+
expect(content.style.transform).toBe("translate(-200px, -200px) scale(1)");
9292
});
9393
});
9494

@@ -135,8 +135,6 @@ describe("ReactZoomPanPinchProps.disablePadding", () => {
135135
disablePadding: false,
136136
});
137137
pan({ x: -100, y: -100 });
138-
expect(content.style.transform).toBe(
139-
"translate(-100px, -100px) scale(1)",
140-
);
138+
expect(content.style.transform).toBe("translate(-100px, -100px) scale(1)");
141139
});
142140
});

__tests__/features/props/callbacks.spec.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { act, fireEvent, waitFor } from "@testing-library/react";
1+
import { fireEvent, waitFor } from "@testing-library/react";
22
import userEvent from "@testing-library/user-event";
33

4-
import { renderApp, flushAnimationFrames } from "../../utils";
4+
import { renderApp } from "../../utils";
55

66
describe("ReactZoomPanPinchProps callbacks", () => {
77
describe("onInit", () => {
@@ -155,7 +155,8 @@ describe("ReactZoomPanPinchProps callbacks", () => {
155155
const { pan } = renderApp({ onTransform });
156156
pan({ x: -50, y: -50 });
157157
expect(onTransform).toHaveBeenCalled();
158-
const lastCall = onTransform.mock.calls[onTransform.mock.calls.length - 1];
158+
const lastCall =
159+
onTransform.mock.calls[onTransform.mock.calls.length - 1];
159160
expect(lastCall[1]).toHaveProperty("scale");
160161
expect(lastCall[1]).toHaveProperty("positionX");
161162
expect(lastCall[1]).toHaveProperty("positionY");

__tests__/features/props/disabled.spec.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ describe("ReactZoomPanPinchProps.disabled", () => {
1414
it("blocks wheel zoom when disabled is true", () => {
1515
const { content, ref } = renderApp({ disabled: true });
1616
userEvent.hover(content);
17-
fireEvent(
18-
content,
19-
new WheelEvent("wheel", { bubbles: true, deltaY: -10 }),
20-
);
17+
fireEvent(content, new WheelEvent("wheel", { bubbles: true, deltaY: -10 }));
2118
expect(ref.current!.instance.state.scale).toBe(1);
2219
});
2320

@@ -30,8 +27,6 @@ describe("ReactZoomPanPinchProps.disabled", () => {
3027
it("allows interactions when disabled is false", () => {
3128
const { content, pan } = renderApp({ disabled: false });
3229
pan({ x: -100, y: -100 });
33-
expect(content.style.transform).toBe(
34-
"translate(-100px, -100px) scale(1)",
35-
);
30+
expect(content.style.transform).toBe("translate(-100px, -100px) scale(1)");
3631
});
3732
});

0 commit comments

Comments
 (0)