Skip to content

Commit

Permalink
Add knip and fix all issues
Browse files Browse the repository at this point in the history
  • Loading branch information
VanTanev committed Oct 13, 2024
1 parent 16ca74d commit 89ce0b6
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 68 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,20 @@ jobs:

- name: Check Formatting
run: yarn format:check

knip:
name: Knip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install Dependencies
run: yarn

- name: Check Knip
run: yarn knip
10 changes: 10 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"ignoreWorkspaces": ["test-gatsby", "packages/gatsby-source-workspace"],
"workspaces": {
".": {
"ignoreBinaries": ["gatsby", "manypkg"]
}
},
"ignore": ["__fixtures__/**"]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"format:check": "prettier --check .",
"postinstall": "preconstruct dev && manypkg check",
"release": "preconstruct build && changeset publish",
"knip": "knip",
"test": "jest",
"test-gatsby": "cd test-gatsby && gatsby develop"
},
Expand All @@ -29,13 +30,13 @@
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",
"@preconstruct/cli": "^2.2.2",
"@types/fs-extra": "^8.0.1",
"@types/jest": "^29.2.4",
"@types/normalize-path": "^3.0.0",
"@types/parse-github-url": "^1.0.0",
"@types/semver": "^6.0.1",
"jest": "^29.3.1",
"jest-watch-typeahead": "^2.2.1",
"knip": "^5.33.3",
"prettier": "^2.8.1",
"prettier-plugin-packagejson": "^2.3.0",
"typescript": "^5.3.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@manypkg/get-packages": "^2.2.1",
"chalk": "^2.4.2",
"detect-indent": "^6.0.0",
"find-up": "^4.1.0",
"normalize-path": "^3.0.0",
"p-limit": "^2.2.1",
"package-json": "^8.1.0",
Expand All @@ -27,6 +26,7 @@
"validate-npm-package-name": "^3.0.0"
},
"devDependencies": {
"@changesets/types": "^5.2.1",
"fixturez": "^1.1.0",
"strip-ansi": "^6.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/checks/WORKSPACE_REQUIRED.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { makeCheck, NORMAL_DEPENDENCY_TYPES } from "./utils";
import { Package } from "@manypkg/get-packages";

export type ErrorType = {
type ErrorType = {
type: "WORKSPACE_REQUIRED";
workspace: Package;
depType: typeof NORMAL_DEPENDENCY_TYPES[number];
Expand Down
6 changes: 0 additions & 6 deletions packages/cli/src/checks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ type AllCheckWithFix<ErrorType> = {
print: (error: ErrorType, options: Options) => string;
};

export type Check<ErrorType> =
| RootCheck<ErrorType>
| AllCheck<ErrorType>
| RootCheckWithFix<ErrorType>
| AllCheckWithFix<ErrorType>;

export function sortObject(prevObj: { [key: string]: string }) {
let newObj: { [key: string]: string } = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from "chalk";
import util from "util";

export function format(
function format(
args: Array<any>,
messageType: "error" | "success" | "info",
scope?: string
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/npm-tag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getPackages } from "@manypkg/get-packages";
import { PackageJSON } from "@changesets/types";
import type { PackageJSON } from "@changesets/types";
import spawn from "spawndamnit";
import pLimit from "p-limit";

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function upgradeDependency([name, tag = "latest"]: string[]) {

const npmRequestLimit = pLimit(40);

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

Expand Down
6 changes: 3 additions & 3 deletions packages/get-packages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"@manypkg/find-root": "^2.2.2",
"@manypkg/tools": "^1.1.1"
},
"devDependencies": {
"jest-fixtures": "^0.6.0"
},
"engines": {
"node": ">=14.18.0"
},
"devDependencies": {
"fixturez": "^1.1.0"
}
}
3 changes: 1 addition & 2 deletions packages/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
},
"devDependencies": {
"@types/jju": "^1.4.2",
"@types/js-yaml": "^4.0.9",
"jest-fixtures": "^0.6.0"
"@types/js-yaml": "^4.0.9"
},
"engines": {
"node": ">=14.18.0"
Expand Down
4 changes: 0 additions & 4 deletions packages/tools/src/PnpmTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ function readYamlFileSync<T = unknown>(path: string): T {
return yaml.load(fs.readFileSync(path, "utf8")) as T;
}

export interface PnpmWorkspaceYaml {
packages?: string[];
}

export const PnpmTool: Tool = {
type: "pnpm",

Expand Down
Loading

0 comments on commit 89ce0b6

Please sign in to comment.