Skip to content

Commit 89ce0b6

Browse files
committed
Add knip and fix all issues
1 parent 16ca74d commit 89ce0b6

File tree

13 files changed

+187
-68
lines changed

13 files changed

+187
-68
lines changed

.github/workflows/main.yml

+17
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,20 @@ jobs:
5757

5858
- name: Check Formatting
5959
run: yarn format:check
60+
61+
knip:
62+
name: Knip
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v3
66+
67+
- name: Set Node.js 18.x
68+
uses: actions/setup-node@v3
69+
with:
70+
node-version: 18.x
71+
72+
- name: Install Dependencies
73+
run: yarn
74+
75+
- name: Check Knip
76+
run: yarn knip

knip.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@5/schema.json",
3+
"ignoreWorkspaces": ["test-gatsby", "packages/gatsby-source-workspace"],
4+
"workspaces": {
5+
".": {
6+
"ignoreBinaries": ["gatsby", "manypkg"]
7+
}
8+
},
9+
"ignore": ["__fixtures__/**"]
10+
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"format:check": "prettier --check .",
1313
"postinstall": "preconstruct dev && manypkg check",
1414
"release": "preconstruct build && changeset publish",
15+
"knip": "knip",
1516
"test": "jest",
1617
"test-gatsby": "cd test-gatsby && gatsby develop"
1718
},
@@ -29,13 +30,13 @@
2930
"@changesets/changelog-github": "^0.4.8",
3031
"@changesets/cli": "^2.26.0",
3132
"@preconstruct/cli": "^2.2.2",
32-
"@types/fs-extra": "^8.0.1",
3333
"@types/jest": "^29.2.4",
3434
"@types/normalize-path": "^3.0.0",
3535
"@types/parse-github-url": "^1.0.0",
3636
"@types/semver": "^6.0.1",
3737
"jest": "^29.3.1",
3838
"jest-watch-typeahead": "^2.2.1",
39+
"knip": "^5.33.3",
3940
"prettier": "^2.8.1",
4041
"prettier-plugin-packagejson": "^2.3.0",
4142
"typescript": "^5.3.2"

packages/cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"@manypkg/get-packages": "^2.2.1",
1717
"chalk": "^2.4.2",
1818
"detect-indent": "^6.0.0",
19-
"find-up": "^4.1.0",
2019
"normalize-path": "^3.0.0",
2120
"p-limit": "^2.2.1",
2221
"package-json": "^8.1.0",
@@ -27,6 +26,7 @@
2726
"validate-npm-package-name": "^3.0.0"
2827
},
2928
"devDependencies": {
29+
"@changesets/types": "^5.2.1",
3030
"fixturez": "^1.1.0",
3131
"strip-ansi": "^6.0.0"
3232
},

packages/cli/src/checks/WORKSPACE_REQUIRED.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { makeCheck, NORMAL_DEPENDENCY_TYPES } from "./utils";
22
import { Package } from "@manypkg/get-packages";
33

4-
export type ErrorType = {
4+
type ErrorType = {
55
type: "WORKSPACE_REQUIRED";
66
workspace: Package;
77
depType: typeof NORMAL_DEPENDENCY_TYPES[number];

packages/cli/src/checks/utils.ts

-6
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ type AllCheckWithFix<ErrorType> = {
7979
print: (error: ErrorType, options: Options) => string;
8080
};
8181

82-
export type Check<ErrorType> =
83-
| RootCheck<ErrorType>
84-
| AllCheck<ErrorType>
85-
| RootCheckWithFix<ErrorType>
86-
| AllCheckWithFix<ErrorType>;
87-
8882
export function sortObject(prevObj: { [key: string]: string }) {
8983
let newObj: { [key: string]: string } = {};
9084

packages/cli/src/logger.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import chalk from "chalk";
22
import util from "util";
33

4-
export function format(
4+
function format(
55
args: Array<any>,
66
messageType: "error" | "success" | "info",
77
scope?: string

packages/cli/src/npm-tag.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getPackages } from "@manypkg/get-packages";
2-
import { PackageJSON } from "@changesets/types";
2+
import type { PackageJSON } from "@changesets/types";
33
import spawn from "spawndamnit";
44
import pLimit from "p-limit";
55

packages/cli/src/upgrade.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export async function upgradeDependency([name, tag = "latest"]: string[]) {
9696

9797
const npmRequestLimit = pLimit(40);
9898

99-
export function getPackageInfo(pkgName: string) {
99+
function getPackageInfo(pkgName: string) {
100100
return npmRequestLimit(async () => {
101101
const getPackageJson = (await import("package-json")).default;
102102

packages/get-packages/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"@manypkg/find-root": "^2.2.2",
1313
"@manypkg/tools": "^1.1.1"
1414
},
15-
"devDependencies": {
16-
"jest-fixtures": "^0.6.0"
17-
},
1815
"engines": {
1916
"node": ">=14.18.0"
17+
},
18+
"devDependencies": {
19+
"fixturez": "^1.1.0"
2020
}
2121
}

packages/tools/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
},
1616
"devDependencies": {
1717
"@types/jju": "^1.4.2",
18-
"@types/js-yaml": "^4.0.9",
19-
"jest-fixtures": "^0.6.0"
18+
"@types/js-yaml": "^4.0.9"
2019
},
2120
"engines": {
2221
"node": ">=14.18.0"

packages/tools/src/PnpmTool.ts

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ function readYamlFileSync<T = unknown>(path: string): T {
1919
return yaml.load(fs.readFileSync(path, "utf8")) as T;
2020
}
2121

22-
export interface PnpmWorkspaceYaml {
23-
packages?: string[];
24-
}
25-
2622
export const PnpmTool: Tool = {
2723
type: "pnpm",
2824

0 commit comments

Comments
 (0)