diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 00830f9..852ba86 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -35,6 +35,9 @@ jobs: - name: Lint affected source files run: pnpm run lint --filter=[origin/${{github.base_ref}}] + - name: Check for unused code + run: pnpm run unused --no-config-hints + - name: Get current git commit hash id: get-git-commit-hash run: | diff --git a/knip.ts b/knip.ts index 4114aeb..3580218 100644 --- a/knip.ts +++ b/knip.ts @@ -4,11 +4,16 @@ type RecordValues = T extends Record ? U : never; type WorkspaceProjectConfig = RecordValues>; -const defaultWorkspaceProjectConfig: WorkspaceProjectConfig = { +const defaultWorkspaceProjectConfig: WorkspaceProjectConfig & { + entry: string[]; + ignoreDependencies: string[]; + project: string[]; +} = { entry: [ "{index,cli,main}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", "src/{index,cli,main}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", ], + ignoreDependencies: ["ts-loader", "tslib"], project: [ "**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!", "!jest.config.stryker.mjs", @@ -17,31 +22,50 @@ const defaultWorkspaceProjectConfig: WorkspaceProjectConfig = { }; export default { + commitlint: { + config: "config/commitlint/commitlint.config.js", + }, + ignoreWorkspaces: ["packages/docs/services/inversify-site"], workspaces: { ".": { - entry: ["config/commitlint/commitlint.config.js"], + entry: [], + ignoreDependencies: defaultWorkspaceProjectConfig.ignoreDependencies, project: [], }, "packages/container/libraries/*": defaultWorkspaceProjectConfig, "packages/container/tools/*": defaultWorkspaceProjectConfig, "packages/docs/services/*": defaultWorkspaceProjectConfig, + "packages/docs/tools/*": defaultWorkspaceProjectConfig, "packages/docs/tools/inversify-code-examples": { entry: ["src/examples/**/*.ts", "src/scripts/generateExamples.mts"], + ignoreDependencies: [ + ...defaultWorkspaceProjectConfig.ignoreDependencies, + "@docusaurus/Link", + "@docusaurus/plugin-content-docs", + "@docusaurus/useDocusaurusContext", + "@theme/*", + ], project: defaultWorkspaceProjectConfig.project, }, - "packages/docs/tools/*": defaultWorkspaceProjectConfig, "packages/foundation/libraries/*": defaultWorkspaceProjectConfig, "packages/foundation/tools/*": defaultWorkspaceProjectConfig, + "packages/foundation/tools/prettier-config": { + entry: ["{cjs,esm}/index.{js,d.ts}"], + ignoreDependencies: defaultWorkspaceProjectConfig.ignoreDependencies, + project: defaultWorkspaceProjectConfig.project, + }, "packages/container/tools/e2e-tests": { entry: [ + "config/*.mjs", "src/*/parameters/*.ts", "src/*/step-definitions/*.ts", "src/app/hooks/*.ts", ], - project: [ - ...(defaultWorkspaceProjectConfig.project as string[]), - "!config/*", + ignoreDependencies: [ + ...defaultWorkspaceProjectConfig.ignoreDependencies, + "ts-node", ], + project: [...defaultWorkspaceProjectConfig.project, "!config/*"], }, }, } satisfies KnipConfig; diff --git a/package.json b/package.json index 8323efa..8c94a7a 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "build": "turbo run build", "commit": "commit", "format": "turbo run format", - "knip": "knip", "lint": "turbo run lint", "prepare": "husky && turbo telemetry disable", "prerelease": "pnpm run build", @@ -49,6 +48,7 @@ "test": "turbo run test", "test:e2e": "turbo run test:e2e", "test:e2e:cjs": "turbo run test:e2e:cjs", - "test:e2e:esm": "turbo run test:e2e:esm" + "test:e2e:esm": "turbo run test:e2e:esm", + "unused": "knip" } } diff --git a/packages/container/libraries/container/src/error/models/InversifyContainerError.ts b/packages/container/libraries/container/src/error/models/InversifyContainerError.ts index f22dfef..eea7d5b 100644 --- a/packages/container/libraries/container/src/error/models/InversifyContainerError.ts +++ b/packages/container/libraries/container/src/error/models/InversifyContainerError.ts @@ -32,6 +32,7 @@ export class InversifyContainerError extends Error { value: unknown, kind: InversifyContainerErrorKind, ): value is InversifyContainerError { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition return InversifyContainerError.is(value) && value.kind === kind; } } diff --git a/packages/container/libraries/container/src/error/models/InversifyContainerErrorKind.ts b/packages/container/libraries/container/src/error/models/InversifyContainerErrorKind.ts index 5b55980..d649ec1 100644 --- a/packages/container/libraries/container/src/error/models/InversifyContainerErrorKind.ts +++ b/packages/container/libraries/container/src/error/models/InversifyContainerErrorKind.ts @@ -1,4 +1,3 @@ export enum InversifyContainerErrorKind { invalidOperation, - unknown, } diff --git a/packages/container/libraries/strongly-typed/package.json b/packages/container/libraries/strongly-typed/package.json index 9e55f16..9bafaf5 100644 --- a/packages/container/libraries/strongly-typed/package.json +++ b/packages/container/libraries/strongly-typed/package.json @@ -10,6 +10,7 @@ "eslint": "9.18.0", "jest": "29.7.0", "prettier": "3.4.2", + "reflect-metadata": "0.2.2", "rimraf": "6.0.1", "rollup": "4.30.1", "ts-loader": "9.5.2", diff --git a/packages/docs/services/inversify-site/package.json b/packages/docs/services/inversify-site/package.json index 22c3a3f..28feed4 100644 --- a/packages/docs/services/inversify-site/package.json +++ b/packages/docs/services/inversify-site/package.json @@ -18,6 +18,7 @@ "devDependencies": { "@docusaurus/module-type-aliases": "3.7.0", "@docusaurus/types": "3.7.0", + "@eslint/js": "9.18.0", "@types/react": "18.3.18", "eslint": "9.18.0", "eslint-plugin-prettier": "5.2.3", diff --git a/packages/docs/tools/inversify-code-examples/package.json b/packages/docs/tools/inversify-code-examples/package.json index 7c3a5c1..4eccc88 100644 --- a/packages/docs/tools/inversify-code-examples/package.json +++ b/packages/docs/tools/inversify-code-examples/package.json @@ -18,6 +18,7 @@ "reflect-metadata": "0.2.2", "rimraf": "6.0.1", "ts-jest": "29.2.5", + "tslib": "2.8.1", "typescript": "5.7.3" }, "homepage": "https://inversify.io", diff --git a/packages/foundation/tools/typescript-config/tsconfig.base.json b/packages/foundation/tools/typescript-config/tsconfig.base.json index ad3d83a..e09a24c 100644 --- a/packages/foundation/tools/typescript-config/tsconfig.base.json +++ b/packages/foundation/tools/typescript-config/tsconfig.base.json @@ -7,6 +7,7 @@ "esModuleInterop": true, "exactOptionalPropertyTypes": true, "forceConsistentCasingInFileNames": true, + "importHelpers": true, "lib": ["ES2022"], "noFallthroughCasesInSwitch": true, "noImplicitOverride": true,