Skip to content

Commit

Permalink
enable strict and stylistic typescript-eslint configs
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgraham4401 committed Jul 31, 2024
1 parent 772879a commit 8b0fa6e
Show file tree
Hide file tree
Showing 31 changed files with 56 additions and 52 deletions.
5 changes: 4 additions & 1 deletion client/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export default [
// ToDo: eslint-plugin-react-hooks does not yet support eslint > 9 and this config
pluginJs.configs.recommended,
jsxA11y.flatConfigs.recommended,
...tseslint.configs.recommended,
// ...tseslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
eslintPluginPrettierRecommended,
{
name: 'ignore-outputs',
Expand All @@ -36,6 +38,7 @@ export default [
files: ['**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-interface': 'off',
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Color {
active: string;
}

const data: Array<Entry> = [
const data: Entry[] = [
{ name: 'Pending', value: 40, searchParam: 'pending' },
{ name: 'Scheduled', value: 39, searchParam: 'scheduled' },
{ name: 'In Transit', value: 33, searchParam: 'intransit' },
Expand All @@ -23,7 +23,7 @@ const data: Array<Entry> = [
const inactiveAlpha = '1';
const activeAlpha = '.75';

const COLORS: Array<Color> = [
const COLORS: Color[] = [
{ normal: `rgba(0, 136, 254, ${inactiveAlpha})`, active: `rgba(0, 136, 254, ${activeAlpha})` },
{ normal: `rgba(0, 196, 159, ${inactiveAlpha})`, active: `rgba(0, 196, 159, ${activeAlpha})` },
{ normal: `rgba(255, 187, 40, ${inactiveAlpha})`, active: `rgba(255, 187, 40, ${activeAlpha})` },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { HaztrakSite } from 'components/HaztrakSite/haztrakSiteSchema';
import { useSearchParams } from 'react-router-dom';

interface SiteFilterFormProps {
sites: Array<HaztrakSite>;
sites: HaztrakSite[];
setFilteredSites: Dispatch<SetStateAction<HaztrakSite[]>>;
onClear?: () => void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import winkingRobot from '/assets/img/robot/robot-wink.jpg';
import { useAutoAnimate } from '@formkit/auto-animate/react';

interface SiteListGroupProps {
sites: Array<HaztrakSite>;
sites: HaztrakSite[];
}

export function SiteListGroup({ sites }: SiteListGroupProps) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Layout/Sidebar/SidebarRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface RoutesSection {
routes: Route[];
}

export const routes: Array<Route | RoutesSection> = [
export const routes: (Route | RoutesSection)[] = [
{
id: 'Dashboard',
icon: faTachometerAlt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function ManifestStatusSelect({ readOnly, isDraft }: ManifestStatusFieldP
const manifestForm = useFormContext<Manifest>();
const { data: profile, isLoading: profileLoading } = useGetProfileQuery();

const availableStatuses: Array<ManifestStatus> = profile
const availableStatuses: ManifestStatus[] = profile
? manifest.getStatusOptions({
manifest: manifestForm.getValues(),
profile: profile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface SubmissionTypeOption {
label: string;
}

const submissionTypeOptions: Array<SubmissionTypeOption> = [
const submissionTypeOptions: SubmissionTypeOption[] = [
{ value: 'Hybrid', label: 'Hybrid' },
{ value: 'FullElectronic', label: 'Electronic' },
{ value: 'DataImage5Copy', label: 'Data + Image' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useDebounce } from 'hooks';
interface Props {
handleClose: () => void;
handlerType: SiteType;
currentTransporters?: Array<RcraSite>;
currentTransporters?: RcraSite[];
appendTransporter?: UseFieldArrayAppend<Manifest, 'transporters'>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function HandlerSearchModal() {
control: manifestForm.control,
name: 'transporters',
});
const transporters: Array<Transporter> = manifestForm.getValues('transporters');
const transporters: Transporter[] = manifestForm.getValues('transporters');

if (!configs) return null;
const { siteType, open } = configs;
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/Manifest/ManifestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ export interface ManifestContextType {
export const ManifestContext = createContext<ManifestContextType>({
trackingNumber: undefined,
generatorStateCode: undefined,
// eslint-disable-next-line @typescript-eslint/no-empty-function
setGeneratorStateCode: () => {},
tsdfStateCode: undefined,
// eslint-disable-next-line @typescript-eslint/no-empty-function
setTsdfStateCode: () => {},
editWasteLineIndex: undefined,
// eslint-disable-next-line @typescript-eslint/no-empty-function
setEditWasteLineIndex: () => {},
nextSigningSite: undefined,
viewingAsSiteId: undefined,
Expand Down Expand Up @@ -180,7 +183,7 @@ export function ManifestForm({
const [showWasteLineForm, setShowWasteLineForm] = useState<boolean>(false);
const toggleWlFormShow = () => setShowWasteLineForm(!showWasteLineForm);
const [editWasteLine, setEditWasteLine] = useState<number | undefined>(undefined);
const allWastes: Array<WasteLine> = manifestForm.getValues('wastes');
const allWastes: WasteLine[] = manifestForm.getValues('wastes');
const wasteForm = useFieldArray<Manifest, 'wastes'>({
control: manifestForm.control,
name: 'wastes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ afterEach(() => {

describe('QuickerSignForm', () => {
test('displays the MTN to be signed', () => {
const manifestTrackingNumbers: Array<string> = ['123456789ELC', '987654321ELC'];
const manifestTrackingNumbers: string[] = ['123456789ELC', '987654321ELC'];
const handler = createMockMTNHandler();
renderWithProviders(
<QuickerSignForm mtn={manifestTrackingNumbers} mtnHandler={handler} siteType={'Generator'} />
Expand All @@ -21,7 +21,7 @@ describe('QuickerSignForm', () => {
}
});
test('shows what site is signing', () => {
const manifestTrackingNumbers: Array<string> = ['123456789ELC', '987654321ELC'];
const manifestTrackingNumbers: string[] = ['123456789ELC', '987654321ELC'];
const handler = createMockMTNHandler();
renderWithProviders(
<QuickerSignForm mtn={manifestTrackingNumbers} mtnHandler={handler} siteType={'Generator'} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type QuickerSignData = z.infer<typeof quickerSignDataSchema>;
export type QuickerSignature = z.infer<typeof quickerSignatureSchema>;

interface QuickerSignProps {
mtn: Array<string>;
mtn: string[];
mtnHandler: Handler | Transporter;
siteType: RcraSiteType;
handleClose?: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { QuickerSignForm } from './QuickerSignForm';
interface QuickerSignModalProps {
handleClose: () => void;
show: boolean;
mtn?: Array<string>;
mtn?: string[];
mtnHandler?: Handler;
siteType: RcraSiteType;
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Manifest/SiteSelect/SiteSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function SiteSelect({
const selectUserSites = useMemo(() => {
return createSelector(
(res) => res?.data,
(data: Array<HaztrakSite>) => (!data ? [] : Object.values(data).map((site) => site.handler))
(data: HaztrakSite[]) => (!data ? [] : Object.values(data).map((site) => site.handler))
);
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const HANDLER_NAME_2 = 'My Other Transporter';

const mockSetupSign = () => undefined;

const TRAN_ARRAY: Array<Transporter> = [
const TRAN_ARRAY: Transporter[] = [
{
...createMockTransporter({ epaSiteId: HANDLER_ID_1, name: HANDLER_NAME_1, order: 1 }),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { v4 as uuidv4 } from 'uuid';
import { TransporterRowActions } from './TransporterRowActions';

interface TransporterTableProps {
transporters?: Array<Transporter>;
transporters?: Transporter[];
arrayFieldMethods: UseFieldArrayReturn<Manifest, 'transporters', 'id'>;
setupSign: () => void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { WasteLineForm } from './WasteLineForm';
interface Props {
handleClose: () => void;
show: boolean | undefined;
currentWastes: Array<WasteLine>;
currentWastes: WasteLine[];
wasteForm: UseFieldArrayReturn<Manifest, 'wastes'>;
}

Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Manifest/WasteLine/QuantityForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Col, Form, Row } from 'react-bootstrap';
import { Controller, useFormContext } from 'react-hook-form';
import Select from 'react-select';

const unitsOfMeasurements: Array<QuantityUOM> = [
const unitsOfMeasurements: QuantityUOM[] = [
{ code: 'P', description: 'Pounds' },
{ code: 'T', description: 'Tons (2000 Pounds)' },
{ code: 'K', description: 'Kilograms' },
Expand All @@ -21,7 +21,7 @@ const unitsOfMeasurements: Array<QuantityUOM> = [
{ code: 'N', description: 'Cubic Meters' },
];

const containerTypes: Array<ContainerType> = [
const containerTypes: ContainerType[] = [
{ code: 'BA', description: 'Burlap, cloth, paper, or plastic bags' },
{ code: 'DT', description: 'Dump truck' },
{ code: 'CF', description: 'Fiber or plastic boxes, cartons, cases' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface WasteLineSectionProps {
export function WasteLineSection({ toggleWlFormShow }: WasteLineSectionProps) {
const manifestForm = useFormContext<Manifest>();
const { errors } = manifestForm.formState;
const allWastes: Array<WasteLine> = manifestForm.getValues('wastes');
const allWastes: WasteLine[] = manifestForm.getValues('wastes');
const wasteForm = useFieldArray<Manifest, 'wastes'>({
control: manifestForm.control,
name: 'wastes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Accordion, Button, Card, Col, Row, useAccordionButton } from 'react-boo
import { UseFieldArrayReturn } from 'react-hook-form';

interface WasteLineTableProps {
wastes: Array<WasteLine>;
wastes: WasteLine[];
toggleWLModal: () => void;
wasteForm: UseFieldArrayReturn<Manifest, 'wastes'>;
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Mtn/MtnTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const mtnDetailsSchema = z.object({
export type MtnDetails = z.infer<typeof mtnDetailsSchema>;

interface MtnTableProps {
manifests: Array<MtnDetails>;
manifests: MtnDetails[];
pageSize?: number;
}

Expand Down
5 changes: 3 additions & 2 deletions client/src/components/UI/HtModal/HtModal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import '@testing-library/jest-dom';
import { HtModal } from 'components/UI';
import React from 'react';
import { cleanup, render, screen } from 'test-utils';
import { afterEach, describe, expect, test } from 'vitest';
import { afterEach, describe, expect, test, vi } from 'vitest';

afterEach(() => {
cleanup();
});

describe('HtModal', () => {
test('renders', () => {
const handleClose = vi.fn();
render(
<HtModal showModal={true} handleClose={() => {}}>
<HtModal showModal={true} handleClose={handleClose}>
<HtModal.Header>
<HtModal.Title title="Hello world" />
</HtModal.Header>
Expand Down
2 changes: 1 addition & 1 deletion client/src/features/ManifestDetails/ManifestDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useGetManifestQuery } from 'store';
export function ManifestDetails() {
const { mtn, action, siteId } = useParams();
useTitle(`${mtn}`);
const { data, error, isLoading } = useGetManifestQuery(mtn!, { skip: !mtn });
const { data, error, isLoading } = useGetManifestQuery(mtn ?? '', { skip: !mtn });
useReadOnly(true);

const readOnly = action !== 'edit';
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/useUserSiteIds/useUserSiteIds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useUserSiteIds() {
[]
);

const { userSiteIds, ...rest } = useGetProfileQuery(undefined, {
const { userSiteIds, ...rest } = useGetProfileQuery(null, {
selectFromResult: (result) => ({
...result,
userSiteIds: selectUserSiteIds(result),
Expand Down
16 changes: 8 additions & 8 deletions client/src/store/htApi.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ export const haztrakApi = createApi({
}),
endpoints: (build) => ({
// Note: build.query<ReturnType, ArgType>
searchRcrainfoSites: build.query<Array<RcraSite>, RcrainfoSiteSearch>({
searchRcrainfoSites: build.query<RcraSite[], RcrainfoSiteSearch>({
query: (data: RcrainfoSiteSearch) => ({
url: 'rcrainfo/rcrasite/search',
method: 'post',
data: data,
}),
}),
searchRcraSites: build.query<Array<RcraSite>, RcrainfoSiteSearch>({
searchRcraSites: build.query<RcraSite[], RcrainfoSiteSearch>({
query: (data: RcrainfoSiteSearch) => ({
url: 'rcrasite/search',
method: 'get',
Expand All @@ -101,31 +101,31 @@ export const haztrakApi = createApi({
getTaskStatus: build.query<TaskStatus, string>({
query: (taskId) => ({ url: `task/${taskId}`, method: 'get' }),
}),
getFedWasteCodes: build.query<Array<Code>, void>({
getFedWasteCodes: build.query<Code[], null>({
query: () => ({ url: 'waste/code/federal', method: 'get' }),
providesTags: ['code'],
}),
getStateWasteCodes: build.query<Array<Code>, string>({
getStateWasteCodes: build.query<Code[], string>({
query: (state) => ({ url: `waste/code/state/${state}`, method: 'get' }),
providesTags: ['code'],
}),
getDotIdNumbers: build.query<Array<string>, string>({
getDotIdNumbers: build.query<string[], string>({
query: (id) => ({ url: 'waste/dot/id', method: 'get', params: { q: id } }),
providesTags: ['code'],
}),
getOrgSites: build.query<Array<HaztrakSite>, string>({
getOrgSites: build.query<HaztrakSite[], string>({
query: (id) => ({ url: `org/${id}/sites`, method: 'get' }),
providesTags: ['site'],
}),
getUserHaztrakSites: build.query<Array<HaztrakSite>, void>({
getUserHaztrakSites: build.query<HaztrakSite[], null>({
query: () => ({ url: 'site', method: 'get' }),
providesTags: ['site'],
}),
getUserHaztrakSite: build.query<HaztrakSite, string>({
query: (epaId) => ({ url: `site/${epaId}`, method: 'get' }),
providesTags: ['site'],
}),
getMTN: build.query<Array<MtnDetails>, string | undefined>({
getMTN: build.query<MtnDetails[], string | undefined>({
query: (siteId) => ({
url: siteId ? `manifest/mtn/${siteId}` : 'manifest/mtn',
method: 'get',
Expand Down
4 changes: 1 addition & 3 deletions client/src/store/manifestSlice/manifest.slice.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import reducer, {
setManifestStatus,
} from 'store/manifestSlice/manifest.slice';
import { renderWithProviders, screen } from 'test-utils';
import { afterEach, describe, expect, test } from 'vitest';

afterEach(() => {});
import { describe, expect, test } from 'vitest';

const TestComponent = () => {
const readOnly = useAppSelector(selectManifestReadOnly);
Expand Down
15 changes: 7 additions & 8 deletions client/src/store/userSlice/user.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export interface HaztrakSitePermissions {
eManifest: HaztrakModulePermissions;
}

export interface RcrainfoProfileState
extends RcrainfoProfile<Record<string, RcrainfoProfileSite>> {}
export type RcrainfoProfileState = RcrainfoProfile<Record<string, RcrainfoProfileSite>>;

export interface RcrainfoProfile<T> {
user: string;
Expand Down Expand Up @@ -75,14 +74,14 @@ interface HaztrakOrgResponse {

export interface HaztrakProfileResponse {
user: string;
sites: Array<{
sites: {
site: HaztrakSite;
eManifest: HaztrakModulePermissions;
}>;
}[];
org?: HaztrakOrgResponse;
}

interface RcrainfoProfileResponse extends RcrainfoProfile<Array<RcrainfoProfileSite>> {}
type RcrainfoProfileResponse = RcrainfoProfile<RcrainfoProfileSite[]>;

export const userApi = haztrakApi.injectEndpoints({
endpoints: (build) => ({
Expand All @@ -102,7 +101,7 @@ export const userApi = haztrakApi.injectEndpoints({
}),
invalidatesTags: ['auth'],
}),
getUser: build.query<HaztrakUser, void>({
getUser: build.query<HaztrakUser, null>({
query: () => ({
url: 'user',
method: 'GET',
Expand All @@ -117,7 +116,7 @@ export const userApi = haztrakApi.injectEndpoints({
}),
invalidatesTags: ['user'],
}),
getProfile: build.query<ProfileSlice, void>({
getProfile: build.query<ProfileSlice, null>({
query: () => ({
url: 'profile',
method: 'GET',
Expand Down Expand Up @@ -167,7 +166,7 @@ export const userApi = haztrakApi.injectEndpoints({
}),
invalidatesTags: ['rcrainfoProfile'],
}),
syncRcrainfoProfile: build.mutation<TaskResponse, void>({
syncRcrainfoProfile: build.mutation<TaskResponse, null>({
query: () => ({
url: `rcrainfo-profile/sync`,
method: 'POST',
Expand Down
Loading

0 comments on commit 8b0fa6e

Please sign in to comment.