Skip to content

Commit

Permalink
Ignore Kubb files in linter
Browse files Browse the repository at this point in the history
Add ignorePattern in eslint config to skip the app/gen directory
Clean up linting and testing messages that were made apparent

Closes #21

Co-authored-by: horatio <[email protected]>
  • Loading branch information
horatiorosa authored and TangoYankee committed Jul 17, 2024
1 parent fdd56b8 commit 2213b22
Show file tree
Hide file tree
Showing 18 changed files with 6,125 additions and 5,827 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module.exports = {
// Base config
extends: ["eslint:recommended", "plugin:prettier/recommended"],

ignorePatterns: ["/app/gen/"],

overrides: [
// React
{
Expand Down
2 changes: 1 addition & 1 deletion app/components/AdminDropdown/BoroughDropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Borough, createBorough } from "~/gen";
import { BoroughDropdown } from "./BoroughDropdown";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { userEvent } from "@testing-library/user-event";

describe("BoroughDropdown", () => {
let boroughs: Array<Borough> = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { render, screen } from "@testing-library/react";
import { CityCouncilDistrict, createCityCouncilDistrict } from "~/gen";
import { CityCouncilDistrictDropdown } from "./CityCouncilDistrictDropdown";
import userEvent from "@testing-library/user-event";
import { userEvent } from "@testing-library/user-event";
import { act } from "react";

describe("CityCouncilDistrictDropdown", () => {
let cityCouncilDistricts: Array<CityCouncilDistrict> = [];
Expand Down Expand Up @@ -36,7 +37,7 @@ describe("CityCouncilDistrictDropdown", () => {
/>,
);

await userEvent.selectOptions(screen.getByRole("combobox"), "");
await act(() => userEvent.selectOptions(screen.getByRole("combobox"), ""));
expect(updateSearchParams).toHaveBeenCalledWith({
districtType: "ccd",
});
Expand All @@ -52,9 +53,11 @@ describe("CityCouncilDistrictDropdown", () => {
/>,
);

await userEvent.selectOptions(
screen.getByRole("combobox"),
firstCityCouncilDistrictId,
await act(() =>
userEvent.selectOptions(
screen.getByRole("combobox"),
firstCityCouncilDistrictId,
),
);
expect(updateSearchParams).toHaveBeenCalledWith({
districtType: "ccd",
Expand Down
17 changes: 10 additions & 7 deletions app/components/AdminDropdown/CommunityDistrictDropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { render, screen } from "@testing-library/react";
import { CommunityDistrictDropdown } from "./CommunityDistrictDropdown";
import { CommunityDistrict, createCommunityDistrict } from "~/gen";
import userEvent from "@testing-library/user-event";
import { userEvent } from "@testing-library/user-event";
import { act } from "react";

describe("CommunityDistrictDropdown", () => {
let communityDistricts: Array<CommunityDistrict> = [];
Expand Down Expand Up @@ -41,14 +42,14 @@ describe("CommunityDistrictDropdown", () => {
/>,
);

await userEvent.selectOptions(screen.getByRole("combobox"), "");
await act(() => userEvent.selectOptions(screen.getByRole("combobox"), ""));
expect(updateSearchParams).toHaveBeenCalledWith({ districtType: "cd" });
});

it("should set search params when nextDistrictID is empty", async () => {
const updateSearchParams = vi.fn();
const firstCommunityDistrictId = communityDistricts[0].id;
console.debug("fcd", firstCommunityDistrictId);

render(
<CommunityDistrictDropdown
boroughId={boroughId}
Expand All @@ -58,7 +59,7 @@ describe("CommunityDistrictDropdown", () => {
/>,
);

await userEvent.selectOptions(screen.getByRole("combobox"), "");
await act(() => userEvent.selectOptions(screen.getByRole("combobox"), ""));
expect(updateSearchParams).toHaveBeenCalledWith({
districtType: "cd",
boroughId,
Expand All @@ -77,9 +78,11 @@ describe("CommunityDistrictDropdown", () => {
/>,
);

await userEvent.selectOptions(
screen.getByRole("combobox"),
firstCommunityDistrictId,
await act(() =>
userEvent.selectOptions(
screen.getByRole("combobox"),
firstCommunityDistrictId,
),
);
expect(updateSearchParams).toHaveBeenCalledWith({
districtType: "cd",
Expand Down
7 changes: 5 additions & 2 deletions app/components/AdminDropdown/DistrictTypeDropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render, screen } from "@testing-library/react";
import { DistrictTypeDropdown } from "./DistrictTypeDropdown";
import userEvent from "@testing-library/user-event";
import { userEvent } from "@testing-library/user-event";
import { act } from "react";

describe("DistrictTypeDropdown", () => {
it("should render district type form details and options", () => {
Expand All @@ -14,7 +15,9 @@ describe("DistrictTypeDropdown", () => {
it("should update search params when changing the district type", async () => {
const updateSearchParams = vi.fn();
render(<DistrictTypeDropdown updateSearchParams={updateSearchParams} />);
await userEvent.selectOptions(screen.getByRole("combobox"), "cd");
await act(() =>
userEvent.selectOptions(screen.getByRole("combobox"), "cd"),
);
expect(updateSearchParams).toHaveBeenCalledWith({ districtType: "cd" });
});
});
3 changes: 2 additions & 1 deletion app/components/AdminDropdown/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { userEvent } from "@testing-library/user-event";
import { AdminDropdown } from ".";
import { act } from "react";

describe("AdminDropdown", () => {
it("should render with form details", () => {
Expand Down Expand Up @@ -88,7 +89,7 @@ describe("AdminDropdown", () => {
expect(defaultSelect?.selected).toBe(false);

// Select the default option
await userEvent.selectOptions(screen.getByRole("combobox"), "");
await act(() => userEvent.selectOptions(screen.getByRole("combobox"), ""));
expect(onSelectValueChange).toHaveBeenCalledWith(null);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Agency,
} from "~/gen";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { userEvent } from "@testing-library/user-event";

describe("CapitalProjectDetailPanel", () => {
let capitalProject: CapitalProjectBudgeted;
Expand Down
2 changes: 1 addition & 1 deletion app/components/CapitalProjectDetailPanel/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { CapitalProjectDetailPanel } from './CapitalProjectDetailPanel';
export { CapitalProjectDetailPanel } from "./CapitalProjectDetailPanel";
3 changes: 1 addition & 2 deletions app/components/Overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Flex, Show } from "@nycplanning/streetscape";
import { Flex } from "@nycplanning/streetscape";
import { ReactNode } from "react";
import { FilterMenu } from "./FilterMenu";

export interface OverlayProps {
children: ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface CityCouncilDistrictProperties {
id: string;
}
export function useCityCouncilDistrictsLayer() {
const [searchParams, setSearchParams] = useSearchParams();
const [searchParams] = useSearchParams();
const districtType = searchParams.get("districtType");

return new MVTLayer<CityCouncilDistrictProperties>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface CommunityDistrictProperties {
abbr: string | null;
}
export function useCommunityDistrictsLayer() {
const [searchParams, setSearchParams] = useSearchParams();
const [searchParams] = useSearchParams();
const districtType = searchParams.get("districtType");

return new MVTLayer<CommunityDistrictProperties>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
} from "../types/FindCapitalCommitmentsByManagingCodeCapitalProjectId";

/**
* @summary 🚧 Find capital commitments associated with a specific capital project
* @summary Find capital commitments associated with a specific capital project
* @link /capital-projects/:managingCode/:capitalProjectId/capital-commitments
*/
export async function findCapitalCommitmentsByManagingCodeCapitalProjectId(
Expand Down
2 changes: 1 addition & 1 deletion app/gen/mocks/createCapitalCommitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function createCapitalCommitment(
plannedDate: faker.date.anytime().toString(),
budgetLineCode: faker.string.alpha(),
budgetLineId: faker.string.alpha(),
sponsoringAgencies: faker.string.alpha(),
sponsoringAgency: faker.string.alpha(),
budgetType: faker.string.alpha(),
totalValue: faker.number.float(),
},
Expand Down
4 changes: 2 additions & 2 deletions app/gen/types/CapitalCommitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export type CapitalCommitment = {
* @description A string of variable length containing the initials of the sponsoring agency.
* @type string
*/
sponsoringAgencies: string;
sponsoringAgency: string | null;
/**
* @description A string of variable length denoting the type of budget.
* @type string
*/
budgetType: string;
budgetType: string | null;
/**
* @description A numeric string used to refer to the amount of total planned commitments.
* @type number
Expand Down
8 changes: 5 additions & 3 deletions app/gen/zod/capitalCommitmentSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ export const capitalCommitmentSchema = z.object({
budgetLineId: z
.string()
.describe("A string used to refer to the budget line."),
sponsoringAgencies: z
sponsoringAgency: z
.string()
.describe(
"A string of variable length containing the initials of the sponsoring agency.",
),
)
.nullable(),
budgetType: z
.string()
.describe("A string of variable length denoting the type of budget."),
.describe("A string of variable length denoting the type of budget.")
.nullable(),
totalValue: z
.number()
.describe(
Expand Down
2 changes: 1 addition & 1 deletion kubb.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default defineConfig({
},
}),
pluginFaker({
regexGenerator: 'randexp'
regexGenerator: "randexp",
}),
pluginMsw({
output: {
Expand Down
Loading

0 comments on commit 2213b22

Please sign in to comment.