Skip to content

Commit 8263edf

Browse files
committed
enforce lint rule hooks - poc
1 parent 624fc13 commit 8263edf

File tree

49 files changed

+303
-188
lines changed

Some content is hidden

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

49 files changed

+303
-188
lines changed

eslint.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pluginJs from "@eslint/js";
22
import pluginReact from "eslint-plugin-react";
3+
import reactHooks from "eslint-plugin-react-hooks";
34
import simpleImportSort from "eslint-plugin-simple-import-sort";
45
import globals from "globals";
56
import tseslint from "typescript-eslint";
@@ -11,8 +12,20 @@ export default [
1112
pluginJs.configs.recommended,
1213
...tseslint.configs.recommended,
1314
pluginReact.configs.flat.recommended,
15+
reactHooks.configs.flat.recommended,
1416
{
1517
rules: {
18+
"react-hooks/exhaustive-deps": [
19+
"warn",
20+
// I left this commented out because it causes infinite loops in the codebase,
21+
// but may useful for mass-refactoring.
22+
// {
23+
// enableDangerousAutofixThisMayCauseInfiniteLoops: true,
24+
// },
25+
],
26+
"react-hooks/set-state-in-effect": "warn",
27+
"react-hooks/refs": "warn",
28+
"react-hooks/immutability": "warn",
1629
"@typescript-eslint/no-explicit-any": "off",
1730
"react/react-in-jsx-scope": "off",
1831
"@typescript-eslint/no-empty-object-type": "off",

package-lock.json

Lines changed: 40 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"test:e2e": "playwright test",
3636
"test:e2e:ui": "playwright test --ui",
3737
"test:e2e:headed": "playwright test --headed",
38-
"lint": "eslint src --config eslint.config.js",
38+
"lint": "eslint --quiet src --config eslint.config.js",
39+
"lint:all": "eslint src --config eslint.config.js",
3940
"format": "prettier --write .",
4041
"typecheck": "tsc --noEmit",
4142
"gh-pages": "npm run build:ghpages && gh-pages -d dist",
@@ -115,6 +116,7 @@
115116
"@vitest/coverage-v8": "^3.2.4",
116117
"eslint": "^9.39.1",
117118
"eslint-plugin-react": "^7.37.5",
119+
"eslint-plugin-react-hooks": "^7.0.1",
118120
"globals": "^16.5.0",
119121
"jsdom": "^27.2.0",
120122
"knip": "^5.63.1",

src/components/Editor/IOEditor/InputValueEditor/InputValueEditor.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export const InputValueEditor = ({
141141

142142
setValidationError(null);
143143
},
144-
[input.name, currentSubgraphSpec],
144+
[input.name, componentSpec],
145145
);
146146

147147
const hasChanges = useCallback(() => {
@@ -203,7 +203,7 @@ export const InputValueEditor = ({
203203
void navigator.clipboard.writeText(inputValue.trim());
204204
notify("Input value copied to clipboard", "success");
205205
}
206-
}, [inputValue]);
206+
}, [inputValue, notify]);
207207

208208
const deleteNode = useCallback(async () => {
209209
if (!currentSubgraphSpec.inputs) return;
@@ -258,17 +258,21 @@ export const InputValueEditor = ({
258258
}, []);
259259

260260
useEffect(() => {
261-
setInputValue(initialInputValue);
262-
setInputName(input.name);
263-
setInputType(input.type?.toString() ?? "any");
264-
setInputOptional(initialIsOptional);
265-
setValidationError(null);
261+
queueMicrotask(() => {
262+
setInputValue(initialInputValue);
263+
setInputName(input.name);
264+
setInputType(input.type?.toString() ?? "any");
265+
setInputOptional(initialIsOptional);
266+
setValidationError(null);
267+
});
266268
}, [input, initialInputValue, initialIsOptional]);
267269

268270
useEffect(() => {
269271
if (triggerSave) {
270-
saveChanges();
271-
setTriggerSave(false);
272+
queueMicrotask(() => {
273+
saveChanges();
274+
setTriggerSave(false);
275+
});
272276
}
273277
}, [triggerSave, saveChanges]);
274278

src/components/Editor/IOEditor/OutputNameEditor/OutputNameEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export const OutputNameEditor = ({
122122

123123
setValidationError(null);
124124
},
125-
[currentSubgraphSpec, output.name],
125+
[componentSpec, output.name],
126126
);
127127

128128
const deleteNode = useCallback(async () => {

src/components/Home/PipelineSection/BulkActionsBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const BulkActionsBar = ({
3737
const errorMessage = getErrorMessage(error);
3838
notify("Failed to delete some pipelines: " + errorMessage, "error");
3939
}
40-
}, [selectedPipelines, onDeleteSuccess]);
40+
}, [selectedPipelines, onDeleteSuccess, notify]);
4141

4242
return (
4343
<div className="fixed bottom-4 left-1/2 transform -translate-x-1/2 bg-background border border-border rounded-lg shadow-lg p-4 z-50">

src/components/Home/PipelineSection/PipelineRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const PipelineRow = ({
7474
};
7575

7676
await deletePipeline(name, deleteCallback);
77-
}, [name]);
77+
}, [name, onDelete]);
7878

7979
const handleClick = useCallback((e: MouseEvent) => {
8080
// Prevent row click when clicking on the checkbox

src/components/Home/RunSection/RunRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const RunRow = ({ run }: { run: PipelineRunResponse }) => {
4141
navigator.clipboard.writeText(createdBy);
4242
notify(`"${createdBy}" copied to clipboard`, "success");
4343
},
44-
[createdBy],
44+
[createdBy, notify],
4545
);
4646

4747
const statusCounts = convertExecutionStatsToStatusCounts(

src/components/PipelineRun/components/CancelPipelineRunButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const CancelPipelineRunButton = ({
5353
} catch (error) {
5454
notify(`Error cancelling run: ${error}`, "error");
5555
}
56-
}, [runId, available]);
56+
}, [runId, available, notify, cancelPipeline]);
5757

5858
const onClick = useCallback(() => {
5959
setIsOpen(true);

src/components/PipelineRun/components/RerunPipelineButton.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ export const RerunPipelineButton = ({
2828
const { awaitAuthorization, isAuthorized } = useAwaitAuthorization();
2929
const { getToken } = useAuthLocalStorage();
3030

31-
const onSuccess = useCallback((response: PipelineRun) => {
32-
navigate({ to: `${APP_ROUTES.RUNS}/${response.id}` });
33-
}, []);
31+
const onSuccess = useCallback(
32+
(response: PipelineRun) => {
33+
navigate({ to: `${APP_ROUTES.RUNS}/${response.id}` });
34+
},
35+
[navigate],
36+
);
3437

3538
const onError = useCallback(
3639
(error: Error | string) => {

0 commit comments

Comments
 (0)