Skip to content

Commit

Permalink
change typescript-eslint configuration of explicit any usage to 'warn…
Browse files Browse the repository at this point in the history
…' and disable eslint or fix for existing usage (#757)
  • Loading branch information
dpgraham4401 authored Jul 31, 2024
1 parent 1990dc0 commit b958ad9
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React, { ReactElement } from 'react';
import {
Bar,
BarChart,
Expand All @@ -8,7 +9,6 @@ import {
XAxis,
YAxis,
} from 'recharts';
import React, { JSXElementConstructor, ReactElement } from 'react';

const data = [
{
Expand Down Expand Up @@ -73,15 +73,17 @@ const data = [
},
];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const monthTickFormatter = (tick: any) => {
const date = new Date(tick);

return date.getMonth() + 1;
};

const renderQuarterTick = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
tickProps: any
): ReactElement<SVGElement, string | JSXElementConstructor<any>> => {
): ReactElement<SVGElement> => {
const { x, y, payload } = tickProps;
const { value, offset } = payload;
const date = new Date(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const calculateCoordinates = (
};
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const renderCustomLabel = (props: any): ReactElement | null => {
const { cx, cy, midAngle, outerRadius, value, hover, activeIndex, index } = props;
const { sin, cos } = calculateTrig(midAngle);
Expand Down Expand Up @@ -83,6 +84,7 @@ const renderCustomLabel = (props: any): ReactElement | null => {
return activeIndex !== index ? labelElement : null;
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const renderOuterRing = (props: any): ReactElement => {
const { cx, cy, midAngle, outerRadius, startAngle, endAngle, fill, payload, percent } = props;
const { sin, cos } = calculateTrig(midAngle);
Expand Down Expand Up @@ -145,6 +147,7 @@ const renderOuterRing = (props: any): ReactElement => {
};

/** Render the currently focused pie slice*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const renderActiveShape = (props: any): ReactElement => {
const { cx, cy, midAngle, innerRadius, outerRadius, startAngle, endAngle, fill, onClick } = props;
const { sin, cos } = calculateTrig(midAngle);
Expand All @@ -170,6 +173,7 @@ const renderActiveShape = (props: any): ReactElement => {
);
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const renderLegend = (props: any): ReactElement => {
const { payload, handleMouseEnter, handleMouseLeave, handleClick } = props;

Expand All @@ -182,6 +186,7 @@ const renderLegend = (props: any): ReactElement => {
className="recharts-default-legend"
style={{ padding: '0px', margin: '10px', textAlign: 'center' }}
>
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any*/}
{payload.map((entry: any, index: number) => {
const dataEntry = data.find((d) => d.name === entry.value);
const activeAlphaColor = entry.color.slice(
Expand Down Expand Up @@ -234,6 +239,7 @@ export function ManifestStatusPieChart() {
const navigate = useNavigate();

const handleMouseEnter = useCallback(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(_: any, index: number) => {
setAnimationIsActive(false); // stop animation if impatient user
setActiveIndex(index);
Expand All @@ -246,6 +252,7 @@ export function ManifestStatusPieChart() {
setActiveIndex(-1);
}, [setActiveIndex]);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const renderLabel = (props: any) => {
return renderCustomLabel({ ...props, hover: false, activeIndex: activeIndex });
};
Expand All @@ -261,6 +268,7 @@ export function ManifestStatusPieChart() {
<ResponsiveContainer minWidth={100} minHeight={300} height={'10%'}>
<PieChart width={400} height={400}>
<Legend
// eslint-disable-next-line @typescript-eslint/no-explicit-any
content={(props: any) =>
renderLegend({ ...props, handleMouseEnter, handleMouseLeave, handleClick })
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Layout/PrivateRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Navigate } from 'react-router-dom';
import { selectAuthenticated, useAppSelector } from 'store';

interface Props {
children: any;
children: ReactElement;
}

/** Redirect to the login if user is not authenticated*/
Expand Down
20 changes: 11 additions & 9 deletions client/src/components/Layout/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ export function Root() {
return (
<NavContext.Provider value={{ showSidebar, setShowSidebar }}>
<PrivateRoute>
<TopNav />
<Sidebar />
<Container fluid>
<ErrorBoundary>
<Suspense fallback={<HtSpinner center className="my-auto" />}>
<Outlet />
</Suspense>
</ErrorBoundary>
</Container>
<div>
<TopNav />
<Sidebar />
<Container fluid>
<ErrorBoundary>
<Suspense fallback={<HtSpinner center className="my-auto" />}>
<Outlet />
</Suspense>
</ErrorBoundary>
</Container>
</div>
</PrivateRoute>
</NavContext.Provider>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { faCheck, faXmark } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { HtSpinner } from 'components/UI';
import React from 'react';
import { Badge } from 'react-bootstrap';
import { HtSpinner } from 'components/UI';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCheck, faXmark } from '@fortawesome/free-solid-svg-icons';

interface RcrainfoInfoStatusProps {
isFetching: boolean;
error: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any;
isFetching: boolean;
rcraInfoIntegrated: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { describe, expect, test } from 'vitest';

function TestComponent({ siteType }: { siteType?: RcraSiteType }) {
const [mockSiteType, setMockSiteType] = useState();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleChange = (siteType: any) => setMockSiteType(siteType);
const { control } = useForm();
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface TransporterTableProps {
setupSign: () => void;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function CustomToggle({ eventKey }: any) {
const [open, setOpen] = useState(false);
const decoratedOnClick = useAccordionButton(eventKey, () => setOpen(!open));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export function HazardousWasteForm({ epaWaste }: HazardousWasteFormProps) {
* see SO question here
* https://stackoverflow.com/questions/52482985/react-select-show-different-text-label-for-drop-down-and-control
*/

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const MultiValue = (props: any) => (
<components.MultiValue {...props}>{props.data.code}</components.MultiValue>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function StateWasteCodeSelect({ stateId, fieldName }: StateWasteCodeSelec
* see SO question here
* https://stackoverflow.com/questions/52482985/react-select-show-different-text-label-for-drop-down-and-control
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const MultiValue = (props: any) => (
<components.MultiValue {...props}>{props.data.code}</components.MultiValue>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const WasteCodes = ({ wasteLine }: { wasteLine: WasteLine }) => {
);
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const CustomToggle = ({ eventKey }: any) => {
const [open, setOpen] = useState(false);
const decoratedOnClick = useAccordionButton(eventKey, () => setOpen(!open));
Expand Down
1 change: 1 addition & 0 deletions client/src/components/UI/FloatingActionBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button, ButtonProps } from 'react-bootstrap';
interface HtFloatingActionBtnProps extends ButtonProps {
position?: 'bottom-left' | 'bottom-right';
extended?: boolean;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
component?: any;
}

Expand Down
1 change: 1 addition & 0 deletions client/src/components/UI/HtPaginate/HtPaginate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface usePaginationProps {
}

interface HtPaginateProps extends usePaginationProps {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onPageChange: any;
}

Expand Down
3 changes: 3 additions & 0 deletions client/src/features/NewManifest/NewManifest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export function NewManifest() {

const selectBySiteId = useMemo(() => {
return createSelector(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(res: any) => res.data,
(_res, siteId) => siteId,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(data: any, siteId) => {
return data?.sites[siteId]?.handler ?? undefined;
}
Expand Down Expand Up @@ -72,6 +74,7 @@ export function NewManifest() {

if (isLoading && siteId) return <HtSpinner center />;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleSiteChange = (site: any) => {
updateSiteSelection(site);
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/manifest/useSaveManifest/useSaveManifest.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import { Manifest } from 'components/Manifest';
import { useEffect, useState } from 'react';
import {
useCreateManifestMutation,
useSaveEManifestMutation,
Expand All @@ -13,7 +13,7 @@ export function useSaveManifest() {
const [data, setData] = useState<Manifest | undefined>();
const [isLoading, setIsLoading] = useState(false);
const [taskId, setTaskId] = useState<string | undefined>();
const [error, setError] = useState<any | undefined>(null);
const [error, setError] = useState<unknown | undefined>(null);

const [createManifest, { data: createData, error: createError, isLoading: createIsLoading }] =
useCreateManifestMutation();
Expand Down

0 comments on commit b958ad9

Please sign in to comment.