From ef156275e2bc6f807395dc443967fa7cdb5cf5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Pintos=20L=C3=B3pez?= Date: Sat, 18 Jan 2025 03:06:09 +0100 Subject: [PATCH 1/2] chore: clean dependencies clean unused dependencies clean unused exports --- package.json | 4 +++- packages/container/libraries/common/package.json | 4 ---- .../common/src/services/models/LazyServiceIdentifier.ts | 2 +- packages/container/libraries/container/package.json | 4 ---- .../container/src/error/models/InversifyContainerError.ts | 2 +- packages/container/libraries/core/package.json | 4 ---- .../libraries/core/src/common/models/OneToManyMapStar.ts | 2 +- .../libraries/core/src/error/models/InversifyCoreError.ts | 2 +- packages/container/libraries/strongly-typed/package.json | 4 ---- packages/container/tools/e2e-tests/package.json | 3 --- .../tools/e2e-tests/src/common/models/InversifyWorld.ts | 4 ++-- packages/docs/services/inversify-site/package.json | 3 --- packages/docs/tools/inversify-code-examples/package.json | 4 ---- packages/foundation/libraries/prototype-utils/package.json | 4 ---- .../foundation/libraries/reflect-metadata-utils/package.json | 4 ---- .../tools/jest-config/lib/config/getJestJsProjectConfig.js | 2 +- .../tools/jest-config/lib/config/getJestTsProjectConfig.js | 2 +- packages/foundation/tools/scripts/package.json | 3 +++ packages/foundation/tools/stryker-config/package.json | 3 ++- packages/foundation/tools/typescript-config/package.json | 3 +++ 20 files changed, 19 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index 1d41c9f9..8323efac 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,15 @@ "@commitlint/cli": "19.6.1", "@commitlint/config-conventional": "19.6.0", "@commitlint/prompt-cli": "19.7.0", - "@inversifyjs/foundation-prettier-config": "workspace:*", "@inversifyjs/foundation-eslint-config": "workspace:*", "@inversifyjs/foundation-jest-config": "workspace:*", + "@inversifyjs/foundation-prettier-config": "workspace:*", "@inversifyjs/foundation-rollup-config": "workspace:*", "@inversifyjs/foundation-scripts": "workspace:*", "@inversifyjs/foundation-stryker-config": "workspace:*", "@inversifyjs/foundation-typescript-config": "workspace:*", "husky": "9.1.7", + "knip": "5.42.2", "lint-staged": "15.4.1", "turbo": "2.3.3" }, @@ -34,6 +35,7 @@ "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", diff --git a/packages/container/libraries/common/package.json b/packages/container/libraries/common/package.json index db7760ba..57d33aad 100644 --- a/packages/container/libraries/common/package.json +++ b/packages/container/libraries/common/package.json @@ -5,14 +5,11 @@ }, "description": "InversifyJs common utils", "devDependencies": { - "@eslint/js": "9.18.0", "@jest/globals": "29.7.0", "@stryker-mutator/core": "8.7.1", "@stryker-mutator/jest-runner": "8.7.1", "@stryker-mutator/typescript-checker": "8.7.1", "@types/node": "22.10.7", - "@typescript-eslint/eslint-plugin": "8.20.0", - "@typescript-eslint/parser": "8.20.0", "eslint": "9.18.0", "jest": "29.7.0", "prettier": "3.4.2", @@ -20,7 +17,6 @@ "rollup": "4.30.1", "ts-loader": "9.5.2", "ts-jest": "29.2.5", - "ts-node": "10.9.2", "tslib": "2.8.1", "typescript": "5.7.3" }, diff --git a/packages/container/libraries/common/src/services/models/LazyServiceIdentifier.ts b/packages/container/libraries/common/src/services/models/LazyServiceIdentifier.ts index fb97a547..2a7adb00 100644 --- a/packages/container/libraries/common/src/services/models/LazyServiceIdentifier.ts +++ b/packages/container/libraries/common/src/services/models/LazyServiceIdentifier.ts @@ -1,6 +1,6 @@ import { ServiceIdentifier } from './ServiceIdentifier'; -export const islazyServiceIdentifierSymbol: unique symbol = Symbol.for( +const islazyServiceIdentifierSymbol: unique symbol = Symbol.for( '@inversifyjs/common/islazyServiceIdentifier', ); diff --git a/packages/container/libraries/container/package.json b/packages/container/libraries/container/package.json index 79424904..2830e382 100644 --- a/packages/container/libraries/container/package.json +++ b/packages/container/libraries/container/package.json @@ -10,14 +10,11 @@ "@inversifyjs/reflect-metadata-utils": "workspace:*" }, "devDependencies": { - "@eslint/js": "9.18.0", "@jest/globals": "29.7.0", "@stryker-mutator/core": "8.7.1", "@stryker-mutator/jest-runner": "8.7.1", "@stryker-mutator/typescript-checker": "8.7.1", "@types/node": "22.10.7", - "@typescript-eslint/eslint-plugin": "8.20.0", - "@typescript-eslint/parser": "8.20.0", "eslint": "9.18.0", "jest": "29.7.0", "prettier": "3.4.2", @@ -25,7 +22,6 @@ "rollup": "4.30.1", "ts-loader": "9.5.2", "ts-jest": "29.2.5", - "ts-node": "10.9.2", "tslib": "2.8.1", "typescript": "5.7.3" }, diff --git a/packages/container/libraries/container/src/error/models/InversifyContainerError.ts b/packages/container/libraries/container/src/error/models/InversifyContainerError.ts index b1c1a2ee..f22dfefd 100644 --- a/packages/container/libraries/container/src/error/models/InversifyContainerError.ts +++ b/packages/container/libraries/container/src/error/models/InversifyContainerError.ts @@ -1,6 +1,6 @@ import { InversifyContainerErrorKind } from './InversifyContainerErrorKind'; -export const isAppErrorSymbol: unique symbol = Symbol.for( +const isAppErrorSymbol: unique symbol = Symbol.for( '@inversifyjs/container/InversifyContainerError', ); diff --git a/packages/container/libraries/core/package.json b/packages/container/libraries/core/package.json index b2cf70d1..18c275fc 100644 --- a/packages/container/libraries/core/package.json +++ b/packages/container/libraries/core/package.json @@ -10,14 +10,11 @@ "@inversifyjs/reflect-metadata-utils": "workspace:*" }, "devDependencies": { - "@eslint/js": "9.18.0", "@jest/globals": "29.7.0", "@stryker-mutator/core": "8.7.1", "@stryker-mutator/jest-runner": "8.7.1", "@stryker-mutator/typescript-checker": "8.7.1", "@types/node": "22.10.7", - "@typescript-eslint/eslint-plugin": "8.20.0", - "@typescript-eslint/parser": "8.20.0", "eslint": "9.18.0", "jest": "29.7.0", "prettier": "3.4.2", @@ -26,7 +23,6 @@ "rollup": "4.30.1", "ts-loader": "9.5.2", "ts-jest": "29.2.5", - "ts-node": "10.9.2", "tslib": "2.8.1", "typescript": "5.7.3" }, diff --git a/packages/container/libraries/core/src/common/models/OneToManyMapStar.ts b/packages/container/libraries/core/src/common/models/OneToManyMapStar.ts index 477a17cd..4f2aa392 100644 --- a/packages/container/libraries/core/src/common/models/OneToManyMapStar.ts +++ b/packages/container/libraries/core/src/common/models/OneToManyMapStar.ts @@ -2,7 +2,7 @@ import { Cloneable } from './Cloneable'; const NOT_FOUND_INDEX: number = -1; -export type OneToManyMapStartSpec = { +type OneToManyMapStartSpec = { [TKey in keyof TRelation]: { isOptional: undefined extends TRelation[TKey] ? true : false; }; diff --git a/packages/container/libraries/core/src/error/models/InversifyCoreError.ts b/packages/container/libraries/core/src/error/models/InversifyCoreError.ts index 726e4f6d..412dabe1 100644 --- a/packages/container/libraries/core/src/error/models/InversifyCoreError.ts +++ b/packages/container/libraries/core/src/error/models/InversifyCoreError.ts @@ -1,6 +1,6 @@ import { InversifyCoreErrorKind } from './InversifyCoreErrorKind'; -export const isAppErrorSymbol: unique symbol = Symbol.for( +const isAppErrorSymbol: unique symbol = Symbol.for( '@inversifyjs/core/InversifyCoreError', ); diff --git a/packages/container/libraries/strongly-typed/package.json b/packages/container/libraries/strongly-typed/package.json index 14d5b522..9e55f166 100644 --- a/packages/container/libraries/strongly-typed/package.json +++ b/packages/container/libraries/strongly-typed/package.json @@ -5,11 +5,8 @@ }, "description": "InversifyJs strong type definitions", "devDependencies": { - "@eslint/js": "9.18.0", "@jest/globals": "29.7.0", "@types/node": "22.10.7", - "@typescript-eslint/eslint-plugin": "8.20.0", - "@typescript-eslint/parser": "8.20.0", "eslint": "9.18.0", "jest": "29.7.0", "prettier": "3.4.2", @@ -17,7 +14,6 @@ "rollup": "4.30.1", "ts-loader": "9.5.2", "ts-jest": "29.2.5", - "ts-node": "10.9.2", "tslib": "2.8.1", "typescript": "5.7.3" }, diff --git a/packages/container/tools/e2e-tests/package.json b/packages/container/tools/e2e-tests/package.json index 391c1036..ad2b9cd4 100644 --- a/packages/container/tools/e2e-tests/package.json +++ b/packages/container/tools/e2e-tests/package.json @@ -11,9 +11,6 @@ "@inversifyjs/core": "workspace:*" }, "devDependencies": { - "@eslint/js": "9.18.0", - "@typescript-eslint/eslint-plugin": "8.20.0", - "@typescript-eslint/parser": "8.20.0", "eslint": "9.18.0", "prettier": "3.4.2", "rimraf": "6.0.1", diff --git a/packages/container/tools/e2e-tests/src/common/models/InversifyWorld.ts b/packages/container/tools/e2e-tests/src/common/models/InversifyWorld.ts index 61e17a88..5368a46d 100644 --- a/packages/container/tools/e2e-tests/src/common/models/InversifyWorld.ts +++ b/packages/container/tools/e2e-tests/src/common/models/InversifyWorld.ts @@ -3,12 +3,12 @@ import { Container } from '@inversifyjs/container'; import { BindingParameter } from '../../binding/models/BindingParameter'; -export interface EntitiesMap { +interface EntitiesMap { bindings: Map; containers: Map; } -export interface ContainerRequests { +interface ContainerRequests { get: Map; } diff --git a/packages/docs/services/inversify-site/package.json b/packages/docs/services/inversify-site/package.json index 45108c0e..107f65f9 100644 --- a/packages/docs/services/inversify-site/package.json +++ b/packages/docs/services/inversify-site/package.json @@ -18,10 +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", - "@typescript-eslint/eslint-plugin": "8.20.0", - "@typescript-eslint/parser": "8.20.0", "eslint": "9.18.0", "eslint-plugin-prettier": "5.2.2", "eslint-plugin-simple-import-sort": "12.1.1", diff --git a/packages/docs/tools/inversify-code-examples/package.json b/packages/docs/tools/inversify-code-examples/package.json index 75e48577..7c3a5c1a 100644 --- a/packages/docs/tools/inversify-code-examples/package.json +++ b/packages/docs/tools/inversify-code-examples/package.json @@ -9,11 +9,8 @@ "inversify7": "npm:inversify@7.0.0-alpha.0" }, "devDependencies": { - "@eslint/js": "9.18.0", "@jest/globals": "29.7.0", "@types/node": "22.10.7", - "@typescript-eslint/eslint-plugin": "8.20.0", - "@typescript-eslint/parser": "8.20.0", "eslint": "9.18.0", "glob": "11.0.1", "jest": "29.7.0", @@ -21,7 +18,6 @@ "reflect-metadata": "0.2.2", "rimraf": "6.0.1", "ts-jest": "29.2.5", - "ts-node": "10.9.2", "typescript": "5.7.3" }, "homepage": "https://inversify.io", diff --git a/packages/foundation/libraries/prototype-utils/package.json b/packages/foundation/libraries/prototype-utils/package.json index b4181969..72b5af0b 100644 --- a/packages/foundation/libraries/prototype-utils/package.json +++ b/packages/foundation/libraries/prototype-utils/package.json @@ -29,14 +29,11 @@ "@inversifyjs/common": "workspace:*" }, "devDependencies": { - "@eslint/js": "9.18.0", "@jest/globals": "29.7.0", "@stryker-mutator/core": "8.7.1", "@stryker-mutator/jest-runner": "8.7.1", "@stryker-mutator/typescript-checker": "8.7.1", "@types/node": "22.10.7", - "@typescript-eslint/eslint-plugin": "8.20.0", - "@typescript-eslint/parser": "8.20.0", "eslint": "9.18.0", "jest": "29.7.0", "prettier": "3.4.2", @@ -44,7 +41,6 @@ "rollup": "4.30.1", "ts-loader": "9.5.2", "ts-jest": "29.2.5", - "ts-node": "10.9.2", "tslib": "2.8.1", "typescript": "5.7.3" }, diff --git a/packages/foundation/libraries/reflect-metadata-utils/package.json b/packages/foundation/libraries/reflect-metadata-utils/package.json index 89c12304..b9647e7b 100644 --- a/packages/foundation/libraries/reflect-metadata-utils/package.json +++ b/packages/foundation/libraries/reflect-metadata-utils/package.json @@ -31,14 +31,11 @@ "url": "https://github.com/inversify/monorepo/issues" }, "devDependencies": { - "@eslint/js": "9.18.0", "@jest/globals": "29.7.0", "@stryker-mutator/core": "8.7.1", "@stryker-mutator/jest-runner": "8.7.1", "@stryker-mutator/typescript-checker": "8.7.1", "@types/node": "22.10.7", - "@typescript-eslint/eslint-plugin": "8.20.0", - "@typescript-eslint/parser": "8.20.0", "eslint": "9.18.0", "jest": "29.7.0", "prettier": "3.4.2", @@ -46,7 +43,6 @@ "rollup": "4.30.1", "ts-loader": "9.5.2", "ts-jest": "29.2.5", - "ts-node": "10.9.2", "tslib": "2.8.1", "typescript": "5.7.3" }, diff --git a/packages/foundation/tools/jest-config/lib/config/getJestJsProjectConfig.js b/packages/foundation/tools/jest-config/lib/config/getJestJsProjectConfig.js index 0854eaa2..f55f5739 100644 --- a/packages/foundation/tools/jest-config/lib/config/getJestJsProjectConfig.js +++ b/packages/foundation/tools/jest-config/lib/config/getJestJsProjectConfig.js @@ -5,7 +5,7 @@ import getTestMatch from './getTestMatch.js'; * @param { !string } projectName Jest project's name * @param { !Array } testPathIgnorePatterns Expressions to match to ignored file paths by jest * @param { ?string } extension Test extension to match - * @returns { !import("jest").Config } Jest config + * @returns { !import("@jest/types").Config.ProjectConfig } Jest config */ function getJestJsProjectConfig( projectName, diff --git a/packages/foundation/tools/jest-config/lib/config/getJestTsProjectConfig.js b/packages/foundation/tools/jest-config/lib/config/getJestTsProjectConfig.js index 227d6fd5..808a1831 100644 --- a/packages/foundation/tools/jest-config/lib/config/getJestTsProjectConfig.js +++ b/packages/foundation/tools/jest-config/lib/config/getJestTsProjectConfig.js @@ -5,7 +5,7 @@ import getTestMatch from './getTestMatch.js'; * @param { !string } projectName Jest project's name * @param { !Array } testPathIgnorePatterns Expressions to match to ignored file paths by jest * @param { ?string } extension Test extension to match - * @returns @returns { !import("jest").Config } Jest config + * @returns @returns { !import("@jest/types").Config.ProjectConfig } Jest config */ function getJestTsProjectConfig( projectName, diff --git a/packages/foundation/tools/scripts/package.json b/packages/foundation/tools/scripts/package.json index 8fd2fe64..8fae48c3 100644 --- a/packages/foundation/tools/scripts/package.json +++ b/packages/foundation/tools/scripts/package.json @@ -2,6 +2,9 @@ "name": "@inversifyjs/foundation-scripts", "private": true, "description": "Common scripts for monorepo packages", + "devDependencies": { + "prettier": "3.4.2" + }, "repository": { "type": "git", "url": "git+https://github.com/inversify/monorepo.git" diff --git a/packages/foundation/tools/stryker-config/package.json b/packages/foundation/tools/stryker-config/package.json index 53458d63..addfa0c5 100644 --- a/packages/foundation/tools/stryker-config/package.json +++ b/packages/foundation/tools/stryker-config/package.json @@ -5,7 +5,8 @@ }, "description": "Stryker config for monorepo packages", "devDependencies": { - "@stryker-mutator/api": "8.7.1" + "@stryker-mutator/api": "8.7.1", + "prettier": "3.4.2" }, "exports": "./lib/index.js", "homepage": "https://github.com/inversify/monorepo#readme", diff --git a/packages/foundation/tools/typescript-config/package.json b/packages/foundation/tools/typescript-config/package.json index 2a648913..a1cc76b1 100644 --- a/packages/foundation/tools/typescript-config/package.json +++ b/packages/foundation/tools/typescript-config/package.json @@ -2,6 +2,9 @@ "author": "Roberto Pintos López", "name": "@inversifyjs/foundation-typescript-config", "description": "Common typescript config for inversify monorepo packages", + "devDependencies": { + "prettier": "3.4.2" + }, "license": "MIT", "bugs": { "url": "https://github.com/inversify/monorepo/issues" From 48955a16f9b972472ac25331aea5b62bc9056f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Pintos=20L=C3=B3pez?= Date: Sat, 18 Jan 2025 03:07:41 +0100 Subject: [PATCH 2/2] chore: add knix config --- knip.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 knip.ts diff --git a/knip.ts b/knip.ts new file mode 100644 index 00000000..4114aeba --- /dev/null +++ b/knip.ts @@ -0,0 +1,47 @@ +import { KnipConfig } from "knip"; + +type RecordValues = T extends Record ? U : never; + +type WorkspaceProjectConfig = RecordValues>; + +const defaultWorkspaceProjectConfig: WorkspaceProjectConfig = { + entry: [ + "{index,cli,main}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", + "src/{index,cli,main}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", + ], + project: [ + "**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!", + "!jest.config.stryker.mjs", + "!**/__mocks__", + ], +}; + +export default { + workspaces: { + ".": { + entry: ["config/commitlint/commitlint.config.js"], + project: [], + }, + "packages/container/libraries/*": defaultWorkspaceProjectConfig, + "packages/container/tools/*": defaultWorkspaceProjectConfig, + "packages/docs/services/*": defaultWorkspaceProjectConfig, + "packages/docs/tools/inversify-code-examples": { + entry: ["src/examples/**/*.ts", "src/scripts/generateExamples.mts"], + project: defaultWorkspaceProjectConfig.project, + }, + "packages/docs/tools/*": defaultWorkspaceProjectConfig, + "packages/foundation/libraries/*": defaultWorkspaceProjectConfig, + "packages/foundation/tools/*": defaultWorkspaceProjectConfig, + "packages/container/tools/e2e-tests": { + entry: [ + "src/*/parameters/*.ts", + "src/*/step-definitions/*.ts", + "src/app/hooks/*.ts", + ], + project: [ + ...(defaultWorkspaceProjectConfig.project as string[]), + "!config/*", + ], + }, + }, +} satisfies KnipConfig;