Skip to content

Commit 501ddb2

Browse files
feat: add the plugin:vitest/recommended in extends array (#822)
## PR Checklist - [x] Addresses an existing open issue: fixes #809 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview This PR is responsible for adding the `plugin:vitest/recommended` to the extends array in the `.eslintrc.cjs` file. This PR also updates a few of the tests because once the `plugin:vitest/recommended` was added, some of the tests failed the lint checks. For the following files, I replaced the `toEqual ` methods with the `toBe` methods per the vitest recommendations - src/bin/index.test.ts - src/shared/doesRepositoryExist.test.ts - src/shared/runOrRestore.test.ts - src/steps/writing/creation/dotGitHub/createWorkflowFile.test.ts For the following files, I replaced the `toBe(undefined)` with `toBeUndefined()` per the vitest recommendations - src/shared/options/readGitAndNpmDefaults/readTitleFromReadme.test.ts - src/shared/tryCatchLazyValueAsync.test.ts --------- Co-authored-by: Josh Goldberg ✨ <[email protected]>
1 parent b6c6f12 commit 501ddb2

File tree

8 files changed

+17
-14
lines changed

8 files changed

+17
-14
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module.exports = {
2020
"plugin:n/recommended",
2121
"plugin:perfectionist/recommended-natural",
2222
"plugin:regexp/recommended",
23+
"plugin:vitest/recommended",
2324
"prettier",
2425
],
2526
overrides: [

src/bin/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe("bin", () => {
7373
expect(mockOutro).toHaveBeenCalledWith(
7474
chalk.red("Operation cancelled. Exiting - maybe another time? 👋"),
7575
);
76-
expect(result).toEqual(1);
76+
expect(result).toBe(1);
7777
});
7878

7979
it("returns 1 when promptForMode returns an error", async () => {
@@ -83,7 +83,7 @@ describe("bin", () => {
8383
const result = await bin([]);
8484

8585
expect(mockOutro).toHaveBeenCalledWith(chalk.red(error.message));
86-
expect(result).toEqual(1);
86+
expect(result).toBe(1);
8787
});
8888

8989
it("returns the success result of the corresponding runner without cancel logging when promptForMode returns a mode that succeeds", async () => {

src/shared/doesRepositoryExist.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("doesRepositoryExist", () => {
2121

2222
const actual = await doesRepositoryExist(octokit, { owner, repository });
2323

24-
expect(actual).toEqual(true);
24+
expect(actual).toBe(true);
2525
});
2626

2727
it("returns false when the octokit GET rejects with a 404", async () => {
@@ -31,7 +31,7 @@ describe("doesRepositoryExist", () => {
3131

3232
const actual = await doesRepositoryExist(octokit, { owner, repository });
3333

34-
expect(actual).toEqual(false);
34+
expect(actual).toBe(false);
3535
});
3636

3737
it("throws the error when awaiting the octokit GET throws a non-404 error", async () => {

src/shared/options/readGitAndNpmDefaults/readTitleFromReadme.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ describe("readTitleFromReadme", () => {
2828
it("returns undefined when title does not exist", async () => {
2929
mockReadFileSafe.mockResolvedValue("");
3030
const result = await readTitleFromReadme();
31-
expect(result).toBe(undefined);
31+
expect(result).toBeUndefined();
3232
});
3333
});

src/shared/runOrRestore.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("runOrRestore", () => {
4646
skipRestore: true,
4747
});
4848

49-
expect(actual).toEqual(0);
49+
expect(actual).toBe(0);
5050
});
5151

5252
it("returns 2 and does not restore the repository when run rejects and skipRestore is true", async () => {
@@ -63,7 +63,7 @@ describe("runOrRestore", () => {
6363
skipRestore: true,
6464
});
6565

66-
expect(actual).toEqual(2);
66+
expect(actual).toBe(2);
6767
expect(mock$).toHaveBeenCalledTimes(0);
6868
});
6969

@@ -81,7 +81,7 @@ describe("runOrRestore", () => {
8181
skipRestore: false,
8282
});
8383

84-
expect(actual).toEqual(2);
84+
expect(actual).toBe(2);
8585
expect(mock$.mock.calls).toMatchInlineSnapshot(`
8686
[
8787
[

src/shared/tryCatchLazyValueAsync.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ describe("tryCatchLazyValueAsync", () => {
2525

2626
const lazy = tryCatchLazyValueAsync(get);
2727

28-
expect(await lazy()).toEqual(undefined);
28+
expect(await lazy()).toBeUndefined();
2929
});
3030
});

src/steps/initializeBranchProtectionSettings.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ describe("migrateBranchProtectionSettings", () => {
1414
it("does not throw when the request receives a non-error response", async () => {
1515
const mockRequest = vi.fn().mockResolvedValue({ status: 200 });
1616

17-
await initializeBranchProtectionSettings(
18-
createMockOctokit(mockRequest),
19-
stubValues,
20-
);
17+
await expect(
18+
initializeBranchProtectionSettings(
19+
createMockOctokit(mockRequest),
20+
stubValues,
21+
),
22+
).resolves.not.toThrow();
2123
});
2224

2325
it("returns false when the request receives a 403 response", async () => {

src/steps/writing/creation/dotGitHub/createWorkflowFile.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("createWorkflowFile", () => {
99
runs: ["pnpm build"],
1010
});
1111

12-
expect(actual).toEqual(
12+
expect(actual).toBe(
1313
`jobs:
1414
test_name:
1515
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)