Skip to content

Commit

Permalink
fix: refine next 22 of 38 lint warnings (#2660)
Browse files Browse the repository at this point in the history
* fix: delete unused components

* fix: resolve 17 of 33 lint warnings

* fix: remove unused parameter from component props

* fix: remove excessive optional chaining (?.) operator
  • Loading branch information
unrenamed authored Nov 15, 2024
1 parent ecc835e commit b21b1c4
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const formSchema = z.object({
.optional(),
});

export const CreateNewRole: React.FC<Props> = ({ trigger, permissions }) => {
export const CreateNewRole: React.FC<Props> = ({ trigger }) => {
const router = useRouter();
const [open, setOpen] = useState(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const UpdateWorkspaceImage: React.FC = () => {
toast.error("Error uploading image");
});
},
[setImage, organization],
[organization],
);

if (!organization) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const UpdateUserImage: React.FC = () => {
toast.error("Error uploading image");
});
},
[setImage, user],
[user],
);

return (
Expand Down
35 changes: 19 additions & 16 deletions apps/dashboard/components/multi-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,28 @@ export const MultiSelect: React.FC<Props> = ({ options, placeholder, selected, s
setSelected((prev) => prev.filter((s) => s.value !== o.value));
};

const handleKeyDown = React.useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
const input = inputRef.current;
if (input) {
if (e.key === "Delete" || e.key === "Backspace") {
if (input.value === "") {
setSelected((prev) => {
const newSelected = [...prev];
newSelected.pop();
return newSelected;
});
const handleKeyDown = React.useCallback(
(e: React.KeyboardEvent<HTMLDivElement>) => {
const input = inputRef.current;
if (input) {
if (e.key === "Delete" || e.key === "Backspace") {
if (input.value === "") {
setSelected((prev) => {
const newSelected = [...prev];
newSelected.pop();
return newSelected;
});
}
}
}

// This is not a default behaviour of the <input /> field
if (e.key === "Escape") {
input.blur();
// This is not a default behaviour of the <input /> field
if (e.key === "Escape") {
input.blur();
}
}
}
}, []);
},
[setSelected],
);

const selectables = options.filter((o) => !selected.includes(o));

Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/lib/charts/sparkline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function SparkLineInner<T extends Datum>({
range: [0, width],
}),
};
}, [startDate, endDate, minY, maxY, height, width]);
}, [startDate, endDate, minY, maxY, height, width, padding.bottom, padding.top]);

const chartContext: ChartContextType<T> = {
width,
Expand Down
6 changes: 3 additions & 3 deletions apps/dashboard/lib/charts/time-series-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function TimeSeriesChartInner<T extends Datum>({
startDate: dates[times.indexOf(Math.min(...times))],
endDate: dates[times.indexOf(Math.max(...times))],
};
}, data);
}, [data]);

const { minY, maxY } = useMemo(() => {
const values = series
Expand All @@ -74,7 +74,7 @@ function TimeSeriesChartInner<T extends Datum>({
minY: Math.min(...values),
maxY: Math.max(...values),
};
}, [data, series, padding?.bottom, padding?.top]);
}, [data, series]);

const { yScale, xScale } = useMemo(() => {
const rangeY = maxY - minY;
Expand All @@ -90,7 +90,7 @@ function TimeSeriesChartInner<T extends Datum>({
range: [0, width],
}),
};
}, [startDate, endDate, minY, maxY, height, width, margin]);
}, [startDate, endDate, minY, maxY, height, width, padding?.bottom, padding?.top]);

const chartContext: ChartContextType<T> = {
width,
Expand Down
12 changes: 11 additions & 1 deletion apps/dashboard/lib/charts/useTooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ export function useTooltip<T extends Datum>({
tooltipTop: snapToY ? yScale(series.find((s) => s.id === seriesId)!.valueAccessor(d)) : 0,
});
},
[seriesId, data, xScale, yScale, series, visxTooltip.showTooltip],
[
seriesId,
data,
xScale,
yScale,
series,
margin.left,
snapToX,
snapToY,
visxTooltip.showTooltip,
],
);

const TooltipWrapper = renderInPortal ? visxTooltipInPortal.TooltipInPortal : TooltipWithBounds;
Expand Down
89 changes: 0 additions & 89 deletions apps/dashboard/lib/charts/x-axis.tsx

This file was deleted.

118 changes: 0 additions & 118 deletions apps/dashboard/lib/charts/y-axis.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions apps/play/app/page-bk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default function Home() {
const scrollRef = useRef<null | HTMLDivElement>(null);

useEffect(() => {
scrollRef?.current?.scrollIntoView({ behavior: "smooth" });
}, [scrollRef]);
scrollRef.current?.scrollIntoView({ behavior: "smooth" });
}, []);

const parseCurlCommand = useCallback(
(stepString: string) => {
Expand All @@ -34,7 +34,7 @@ export default function Home() {
tempString = keyName.current ? tempString.replace("<key>", keyName.current) : tempString;
return tempString;
},
[apiId, keyId, keyName, timeStamp],
[apiId],
);
function handleSubmit(cmd: string) {
postNewLine(cmd, "text-violet-500");
Expand Down
2 changes: 1 addition & 1 deletion apps/www/app/accelerate/components/rive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const RiveAccelerateAsset = ({ day, stateMachines }: { day: number; stateMachine
r.rive.on(EventType.RiveEvent, onRiveEventReceived);

setDone(true);
}, [done, r.rive, smVarHighlight, smVarUnlockedUntil]);
}, [done, day, r.rive, smVarHighlight, smVarUnlockedUntil]);

return <r.RiveComponent />;
};
Loading

0 comments on commit b21b1c4

Please sign in to comment.