Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update comma style to latest Prettier defaults #1125

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module.exports = {
sourceType: "module",
},
rules: {
"prettier/prettier": ["error", { trailingComma: "es5" }],
"react/forbid-component-props": [
"error",
{
Expand Down
10 changes: 5 additions & 5 deletions src/components/Accordion/Accordion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Accordion", () => {
content: <>More test content</>,
},
]}
/>
/>,
);
expect(screen.getByRole("tablist")).toMatchSnapshot();
});
Expand All @@ -37,11 +37,11 @@ describe("Accordion", () => {
},
]}
titleElement="h4"
/>
/>,
);
// Check for the specific element as defined in the titleElement prop.
expect(
within(screen.getByRole("listitem")).getByRole("heading").tagName
within(screen.getByRole("listitem")).getByRole("heading").tagName,
).toBe("H4");
});

Expand All @@ -60,7 +60,7 @@ describe("Accordion", () => {
content: <>More test content</>,
},
]}
/>
/>,
);
const tab = screen.getByRole("tab", { name: "Advanced topics" });
await userEvent.click(tab);
Expand All @@ -86,7 +86,7 @@ describe("Accordion", () => {
key: "networking",
},
]}
/>
/>,
);
expect(screen.getByRole("tabpanel", { name: "Networking" })).toBeVisible();
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const generateSections = (
sections: Section[],
setExpanded,
expanded,
titleElement
titleElement,
) =>
sections.map(({ key, ...props }, i) => (
<AccordionSection
Expand Down Expand Up @@ -98,7 +98,7 @@ const Accordion = ({
sections,
setExpanded,
externallyControlled ? expanded : expandedSection,
titleElement
titleElement,
)}
</ul>
</aside>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
expanded="abcd-1234"
setExpanded={jest.fn()}
title="Test section"
/>
/>,
);

expect(screen.getByRole("listitem")).toMatchSnapshot();
Expand All @@ -26,7 +26,7 @@
setExpanded={jest.fn()}
title="Test section"
titleElement="h4"
/>
/>,
);
// Query for the specific element as defined in the titleElement prop.
// eslint-disable-next-line testing-library/no-node-access
Expand All @@ -47,7 +47,7 @@
expanded = id;
}}
title="Test section"
/>
/>,
);
await userEvent.click(screen.getByRole("tab", { name: "Test section" }));
expect(onTitleClick).toHaveBeenCalledWith(true, ":r4:");
Expand All @@ -60,7 +60,7 @@
expanded = id;
}}
title="Test section"
/>
/>,
);
// Clicking the title again should close the accordion section.
await userEvent.click(screen.getByRole("tab", { name: "Test section" }));
Expand All @@ -81,7 +81,7 @@
expanded = id;
}}
title="Test section"
/>
/>,
);
await userEvent.click(screen.getByRole("tab", { name: "Test section" }));

Expand All @@ -100,10 +100,10 @@
<span>optional</span>
</>
}
/>
/>,
);
const title = screen.getByRole("tab");
expect(title.children).toHaveLength(2);

Check warning on line 106 in src/components/Accordion/AccordionSection/AccordionSection.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, build and test

Avoid direct Node access. Prefer using the methods from Testing Library
expect(title).toHaveTextContent("Test section optional");
});
});
2 changes: 1 addition & 1 deletion src/components/ActionButton/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const ActionButton = ({
"is-processing": showLoader || showSuccess,
"is-disabled": disabled,
"is-inline": inline,
}
},
);
const showIcon = showLoader || showSuccess;
const icon = (showLoader && "spinner") || (showSuccess && "success") || null;
Expand Down
12 changes: 6 additions & 6 deletions src/components/ApplicationLayout/ApplicationLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
const link = screen.getAllByRole("link", { name: "Juju" })[0];
expect(within(link).getByRole("img", { name: "Juju" })).toHaveAttribute(
"src",
"name.svg"
"name.svg",
);
});

it("displays as light", () => {
render(<ApplicationLayout dark={false} logo={logo} navItems={[]} />);
expect(document.querySelectorAll(".is-dark")).toHaveLength(0);

Check warning on line 26 in src/components/ApplicationLayout/ApplicationLayout.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, build and test

Avoid direct Node access. Prefer using the methods from Testing Library
expect(document.querySelectorAll(".is-light")).toHaveLength(0);

Check warning on line 27 in src/components/ApplicationLayout/ApplicationLayout.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, build and test

Avoid direct Node access. Prefer using the methods from Testing Library
});

it("displays as dark", () => {
render(<ApplicationLayout dark logo={logo} navItems={[]} />);
expect(document.querySelectorAll(".is-dark")).toHaveLength(5);

Check warning on line 32 in src/components/ApplicationLayout/ApplicationLayout.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, build and test

Avoid direct Node access. Prefer using the methods from Testing Library
// Two icons are light so that they appear over the dark background.
expect(document.querySelectorAll(".is-light")).toHaveLength(2);

Check warning on line 34 in src/components/ApplicationLayout/ApplicationLayout.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, build and test

Avoid direct Node access. Prefer using the methods from Testing Library
});

it("displays main content", () => {
Expand All @@ -39,7 +39,7 @@
render(
<ApplicationLayout logo={logo} navItems={[]}>
{content}
</ApplicationLayout>
</ApplicationLayout>,
);
expect(screen.getByText(content)).toBeInTheDocument();
});
Expand All @@ -58,17 +58,17 @@
logo={logo}
navItems={[]}
aside={<AppAside>{content}</AppAside>}
/>
/>,
);
expect(screen.getByText(content)).toBeInTheDocument();
expect(document.querySelector(".l-aside")).toBeInTheDocument();

Check warning on line 64 in src/components/ApplicationLayout/ApplicationLayout.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, build and test

Avoid direct Node access. Prefer using the methods from Testing Library
});

it("pins the menu", async () => {
render(<ApplicationLayout logo={logo} navItems={[]} />);
expect(document.querySelector(".l-navigation")).not.toHaveClass("is-pinned");

Check warning on line 69 in src/components/ApplicationLayout/ApplicationLayout.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, build and test

Avoid direct Node access. Prefer using the methods from Testing Library
await userEvent.click(screen.getByRole("button", { name: "Pin menu" }));
expect(document.querySelector(".l-navigation")).toHaveClass("is-pinned");

Check warning on line 71 in src/components/ApplicationLayout/ApplicationLayout.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, build and test

Avoid direct Node access. Prefer using the methods from Testing Library
});

it("pins the menu using external state", async () => {
Expand All @@ -79,7 +79,7 @@
navItems={[]}
menuPinned={true}
onPinMenu={onPinMenu}
/>
/>,
);
expect(document.querySelector(".l-navigation")).toHaveClass("is-pinned");
await userEvent.click(screen.getByRole("button", { name: "Unpin menu" }));
Expand All @@ -91,7 +91,7 @@
expect(document.querySelector(".l-navigation")).toHaveClass("is-collapsed");
await userEvent.click(screen.getByRole("button", { name: "Menu" }));
expect(document.querySelector(".l-navigation")).not.toHaveClass(
"is-collapsed"
"is-collapsed",
);
await userEvent.click(screen.getByRole("button", { name: "Close menu" }));
expect(document.querySelector(".l-navigation")).toHaveClass("is-collapsed");
Expand All @@ -105,7 +105,7 @@
navItems={[]}
menuCollapsed={true}
onCollapseMenu={onCollapseMenu}
/>
/>,
);
expect(document.querySelector(".l-navigation")).toHaveClass("is-collapsed");
await userEvent.click(screen.getByRole("button", { name: "Menu" }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("ArticlePagination ", () => {
nextURL="#next"
previousLabel="Lorem ipsum dolor sit amet"
previousURL="#previous"
/>
/>,
);
expect(screen.getByRole("contentinfo")).toMatchSnapshot();
});
Expand Down
11 changes: 7 additions & 4 deletions src/components/Badge/Badge.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,26 @@ it("rounds number correctly for thousands", () => {

it("rounds number correctly for millions", () => {
render(
<Badge value={132456455} badgeType={BadgeType.ROUNDED_LARGE_NUMBER} />
<Badge value={132456455} badgeType={BadgeType.ROUNDED_LARGE_NUMBER} />,
);
// Check that the correct value is displayed.
expect(screen.getByText("132M")).toBeInTheDocument();
});

it("rounds number correctly for billions", () => {
render(
<Badge value={13245645512} badgeType={BadgeType.ROUNDED_LARGE_NUMBER} />
<Badge value={13245645512} badgeType={BadgeType.ROUNDED_LARGE_NUMBER} />,
);
// Check that the correct value is displayed.
expect(screen.getByText("13B")).toBeInTheDocument();
});

it("rounds number correctly for trillions", () => {
render(
<Badge value={132456455123112} badgeType={BadgeType.ROUNDED_LARGE_NUMBER} />
<Badge
value={132456455123112}
badgeType={BadgeType.ROUNDED_LARGE_NUMBER}
/>,
);
// Check that the correct value is displayed.
expect(screen.getByText("132T")).toBeInTheDocument();
Expand All @@ -56,7 +59,7 @@ it("displays the correct max value if it exceeds 999T", () => {
<Badge
value={1324564551231125}
badgeType={BadgeType.ROUNDED_LARGE_NUMBER}
/>
/>,
);
// Check that the correct value is displayed.
expect(screen.getByText("999T")).toBeInTheDocument();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const Badge = ({
[`p-badge--negative`]: !!isNegative,
"p-badge": !isNegative,
},
className
className,
);

let safeValue = Math.round(value);
Expand Down
10 changes: 5 additions & 5 deletions src/components/Button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("Button ", () => {
render(
<Button element="a" href="http://example.com">
Test content
</Button>
</Button>,
);
expect(screen.getByRole("link")).toMatchSnapshot();
});
Expand Down Expand Up @@ -53,7 +53,7 @@ describe("Button ", () => {
disabled={true}
href="http://example.com"
onClick={onClick}
/>
/>,
);
const button = screen.getByRole("link");
expect(button).toHaveClass("is-disabled");
Expand All @@ -71,7 +71,7 @@ describe("Button ", () => {
disabled={true}
href="http://example.com"
onClick={onClick}
/>
/>,
);
const button = screen.getByRole("link");
const clickEvent = createEvent.click(button);
Expand Down Expand Up @@ -109,7 +109,7 @@ describe("Button ", () => {
it("puts additional classes at the end", () => {
render(<Button className="extra-class" dense />);
expect(screen.getByRole("button").className).toEqual(
"p-button is-dense extra-class"
"p-button is-dense extra-class",
);
});

Expand All @@ -134,7 +134,7 @@ describe("Button ", () => {
render(<Button element={Link} to="http://example.com" />);
expect(screen.getByRole("link")).toHaveAttribute(
"href",
"http://example.com"
"http://example.com",
);
});
});
2 changes: 1 addition & 1 deletion src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Button = <P,>({
"is-inline": inline,
"is-small": small,
},
className
className,
);
const onClickDisabled = (e: MouseEvent) => e.preventDefault();

Expand Down
2 changes: 1 addition & 1 deletion src/components/Card/Card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Card ", () => {
it("can have a title", () => {
render(<Card title="This is the title">Test content</Card>);
expect(
screen.getByRole("group", { name: "This is the title" })
screen.getByRole("group", { name: "This is the title" }),
).toBeInTheDocument();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CheckableInput from "./CheckableInput";
describe("CheckableInput ", () => {
it("renders a checkable input", () => {
render(
<CheckableInput inputType="checkbox" label="Test label"></CheckableInput>
<CheckableInput inputType="checkbox" label="Test label"></CheckableInput>,
);
expect(screen.getByRole("checkbox")).toBeInTheDocument();
});
Expand All @@ -17,7 +17,7 @@ describe("CheckableInput ", () => {
inputType="checkbox"
label="Test disabled"
disabled
></CheckableInput>
></CheckableInput>,
);
expect(screen.getByRole("checkbox")).toBeDisabled();
});
Expand All @@ -28,7 +28,7 @@ describe("CheckableInput ", () => {
inputType="radio"
label="Test required"
required
></CheckableInput>
></CheckableInput>,
);
// eslint-disable-next-line testing-library/no-node-access
expect(document.querySelector("label")).toHaveClass("is-required");
Expand All @@ -40,7 +40,7 @@ describe("CheckableInput ", () => {
inputType="radio"
label="Test required"
inline
></CheckableInput>
></CheckableInput>,
);
// eslint-disable-next-line testing-library/no-node-access
expect(document.querySelector("label")).toHaveClass("p-radio--inline");
Expand All @@ -52,7 +52,7 @@ describe("CheckableInput ", () => {
inputType="checkbox"
label="Test label"
indeterminate
></CheckableInput>
></CheckableInput>,
);
expect(screen.getByRole("checkbox")).toBePartiallyChecked();
});
Expand All @@ -63,7 +63,7 @@ describe("CheckableInput ", () => {
inputType="checkbox"
label="Test label"
labelClassName="label-class-name"
/>
/>,
);
// eslint-disable-next-line testing-library/no-node-access
expect(document.querySelector("label")).toHaveClass("label-class-name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const CheckableInput = ({
`p-${inputType}${inline ? "--inline" : ""}`,
{
"is-required": checkboxProps.required,
}
},
)}
>
<input
Expand Down
2 changes: 1 addition & 1 deletion src/components/CheckboxInput/CheckboxInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import CheckboxInput from "./CheckboxInput";
it("renders a checkbox", () => {
render(<CheckboxInput label="Test checkbox"></CheckboxInput>);
expect(
screen.getByRole("checkbox", { name: "Test checkbox" })
screen.getByRole("checkbox", { name: "Test checkbox" }),
).toBeInTheDocument();
});
Loading
Loading