Skip to content

Commit cd9fa57

Browse files
committed
chore: finalize config, fix all non-prod knip issues
1 parent 7139b80 commit cd9fa57

File tree

4 files changed

+110
-107
lines changed

4 files changed

+110
-107
lines changed

knip.ts

Lines changed: 104 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import type { KnipConfig } from "knip";
22

33
const config: KnipConfig = {
4+
rules: {
5+
// Disable checking for unused exports, unused exported types, and duplicate dependencies.
6+
exports: "off",
7+
types: "off",
8+
duplicates: "off",
9+
},
410
// Ignore patterns for files that should not be analyzed
511
ignore: [
612
// Build outputs
@@ -12,135 +18,151 @@ const config: KnipConfig = {
1218
// Generated files
1319
"**/tmp/**",
1420
"**/.sbom/**",
15-
// Test fixtures and data
16-
"**/test/fixtures/**",
1721
"**/test/data/**",
18-
// Docker and scripts that are executed directly
19-
"scripts/docker/**",
20-
// Async rewriter3 has its own build system (Rust/WASM)
21-
"packages/async-rewriter3/**",
22-
// Configuration files
22+
// Configuration files (from depcheck ignore-patterns)
2323
".evergreen/**",
2424
"config/**",
2525
"configs/**",
26+
"**/.eslintrc.js",
2627
],
2728

28-
// Ignore dependencies that are used in build processes or special contexts
29-
ignoreDependencies: [
30-
// Used in build scripts and webpack configs
31-
"terser-webpack-plugin",
32-
"webpack-bundle-analyzer",
33-
"webpack-cli",
34-
"webpack-merge",
35-
// Used in special build contexts
36-
"mongodb-runner",
37-
"mongodb-crypt-library-dummy",
38-
// Used in scripts
39-
"mongodb-sbom-tools",
40-
"@pkgjs/nv",
41-
// Used for husky git hooks
42-
"husky",
43-
// CLI tool
44-
"depcheck",
45-
],
46-
47-
// Ignore binaries that are used in scripts
48-
ignoreBinaries: ["depalign", "monorepo-where", "precommit"],
49-
50-
// Global entry files at root level
51-
entry: ["scripts/**/*.{js,ts,mjs}", "testing/**/*.ts"],
52-
53-
// Project files to analyze at root level
54-
project: [
55-
"scripts/**/*.{js,ts,mjs}",
56-
"testing/**/*.ts",
57-
"configs/**/*.{js,ts}",
58-
],
29+
// Received from @mongodb-js/sbom-tools
30+
ignoreBinaries: ["mongodb-sbom-tools"],
5931

6032
// Workspace-specific configurations
6133
workspaces: {
34+
// Root package (monorepo root, no entry file needed)
6235
".": {
63-
// Root workspace configuration
64-
entry: ["scripts/**/*.{js,ts,mjs}", "testing/**/*.ts"],
36+
entry: ["scripts/*.ts"],
37+
project: [],
38+
ignoreBinaries: [
39+
// Lerna is listed as an optional dependency.
40+
"lerna",
41+
],
6542
},
6643

6744
// Config packages
6845
"configs/eslint-config-mongosh": {
69-
entry: ["index.js", "utils.js"],
46+
entry: ["utils.js"],
7047
},
7148

7249
"configs/tsconfig-mongosh": {
7350
entry: ["tsconfig.common.json"],
7451
},
7552

76-
// Main packages
77-
"packages/*": {
78-
entry: ["src/index.ts", "src/index.tsx", "lib/index.js", "bin/**/*.js"],
79-
project: ["src/**/*.{ts,tsx}", "bin/**/*.js"],
80-
},
81-
8253
// Special cases for packages with different entry points
8354
"packages/cli-repl": {
84-
entry: ["bin/mongosh.js", "src/run.ts", "dist/add-module-mapping.js"],
85-
project: ["src/**/*.ts", "bin/**/*.js"],
55+
project: ["src/**/*.ts", "bin/**/*.js", "test/**/*.ts"],
56+
ignoreDependencies: [
57+
// Eagerly loaded startup snapshot dependencies
58+
"@mongodb-js/saslprep",
59+
"socks",
60+
"emphasize",
61+
"ipv6-normalize",
62+
"bindings",
63+
"system-ca",
64+
// Used for monkey-patching our s390x fix
65+
"@tootallnate/quickjs-emscripten",
66+
],
8667
},
8768

8869
"packages/shell-api": {
8970
entry: ["src/api.ts"],
90-
project: ["src/**/*.ts"],
9171
},
9272

93-
"packages/build": {
94-
entry: [
95-
"src/evergreen-release.ts",
96-
"src/release.ts",
97-
"src/update-cta.ts",
98-
],
99-
project: ["src/**/*.ts"],
73+
"packages/mongosh": {
74+
project: ["bin/**/*.js"],
10075
},
10176

10277
"packages/e2e-tests": {
103-
entry: ["test/**/*.ts"],
104-
project: ["test/**/*.ts"],
78+
entry: ["test/**/*", "test/fixtures/**/*"],
79+
ignoreDependencies: [
80+
// Used indirectly
81+
"@mongosh/cli-repl",
82+
],
83+
},
84+
85+
"scripts/docker": {
86+
ignoreDependencies: [
87+
// Used by build.sh script.
88+
"mongodb-crypt-library-version",
89+
],
90+
},
91+
92+
"packages/service-provider-node-driver": {
93+
ignoreDependencies: [
94+
// Used for MONGODB-AWS auth
95+
// See: https://github.com/mongodb-js/mongosh/pull/1149
96+
// See: https://jira.mongodb.org/browse/NODE-5005
97+
"aws4",
98+
],
99+
},
100+
101+
"packages/node-runtime-worker-thread": {
102+
ignoreDependencies: [
103+
// Used in worker thread context
104+
"system-ca",
105+
],
106+
ignoreFiles: [
107+
// Used in package.json
108+
"tests/register-worker.js",
109+
],
105110
},
106111

107112
"packages/browser-repl": {
108-
entry: ["src/index.tsx"],
113+
entry: ["config/*.js"],
109114
project: ["src/**/*.{ts,tsx}"],
115+
ignoreDependencies: [
116+
"@wojtekmaj/enzyme-adapter-react-17",
117+
"enzyme",
118+
// Karma test runner plugins
119+
"karma-chrome-launcher",
120+
"karma-mocha",
121+
"karma-mocha-reporter",
122+
"karma-typescript",
123+
// Resolved as `<depname>/` so depcheck doesn't see it being used
124+
"buffer",
125+
"util",
126+
],
110127
},
111128

112129
"packages/java-shell": {
113-
entry: [
114-
"src/main/kotlin/**/*.kt",
115-
"src/test/kotlin/**/*.kt",
116-
"gen-doc/**/*.js",
117-
"gen-kotlin/**/*.js",
118-
],
119-
project: [
120-
"src/main/kotlin/**/*.kt",
121-
"gen-doc/**/*.js",
122-
"gen-kotlin/**/*.js",
130+
entry: ["src/test/js/run-tests.ts"],
131+
project: ["src/main/js/**/*"],
132+
ignoreDependencies: [
133+
// Used in webpack and build scripts
134+
"bson",
135+
"tr46",
136+
"assert",
137+
"buffer",
138+
"util",
123139
],
124140
},
125141

126142
"packages/connectivity-tests": {
127-
entry: ["index.js"],
128-
project: ["**/*.js"],
143+
entry: ["scripts/disable-dns-srv.js"],
144+
// This package only contains bash test scripts
145+
ignoreDependencies: [
146+
// Used by test scripts
147+
"mongosh",
148+
],
129149
},
130150

131-
testing: {
132-
entry: [
133-
"eventually.ts",
134-
"fake-kms.ts",
135-
"integration-testing-hooks.ts",
136-
"disable-dns-srv.js",
151+
"packages/async-rewriter2": {
152+
entry: ["test/fixtures/**/*"],
153+
ignoreFiles: [
154+
// Used by make-runtime-support.js
155+
"src/runtime-support.nocov.js",
137156
],
138-
project: ["**/*.{ts,js}"],
139157
},
140158

141-
"scripts/docker": {
142-
entry: ["**/*.js"],
143-
project: ["**/*.js"],
159+
"packages/snippet-manager": {
160+
entry: ["test/fixtures/**/*"],
161+
},
162+
163+
testing: {
164+
entry: ["src/**/*.ts"],
165+
project: ["src/**/*.ts"],
144166
},
145167
},
146168

package-lock.json

Lines changed: 1 addition & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "mongosh",
33
"description": "The MongoDB Shell",
4-
"main": "index.js",
54
"bin": {
65
"mongosh": "packages/cli-repl/bin/mongosh.js"
76
},
@@ -15,9 +14,7 @@
1514
"check-ci": "npm run check --workspaces --if-present",
1615
"depalign": "depalign",
1716
"predepcheck": "npm run depalign",
18-
"depcheck": "npm run depcheck --workspaces --if-present",
19-
"knip": "knip",
20-
"knip:summary": "knip --reporter summary",
17+
"depcheck": "knip",
2118
"knip:production": "knip --production --strict",
2219
"lint": "npm run lint --workspaces --if-present",
2320
"test": "rimraf .nyc_output && npm run test-coverage --workspaces --if-present && npm run report-coverage",
@@ -101,31 +98,24 @@
10198
"node": ">=20.19.3"
10299
},
103100
"devDependencies": {
104-
"@babel/compat-data": "^7.26.8",
105101
"@mongodb-js/monorepo-tools": "^1.1.10",
106102
"@pkgjs/nv": "^0.2.2",
107103
"@types/chai": "^5.2.3",
108104
"@types/mocha": "^5.2.7",
109105
"@types/node": "^22.15.30",
110-
"@types/rimraf": "^3.0.0",
111106
"@types/semver": "^7.3.4",
112107
"@types/sinon-chai": "^4.0.0",
113-
"@types/which": "^1.3.2",
114108
"chai": "^6.2.1",
115109
"cross-env": "^6.0.3",
116-
"depcheck": "^1.4.7",
117-
"duplexpair": "^1.0.2",
118110
"find-up": "^5.0.0",
119111
"glob": "^10.3.12",
120112
"husky": "^9.0.11",
113+
"knip": "^5.69.1",
121114
"mocha": "^10.2.0",
122-
"mongodb": "^6.19.0",
123115
"mongodb-runner": "^6.0.0",
124-
"node-gyp": "^11.5.0",
125116
"nyc": "^15.1.0",
126117
"pkg-up": "^3.1.0",
127118
"rimraf": "^3.0.2",
128-
"semver": "^7.6.3",
129119
"sinon": "^7.5.0",
130120
"sinon-chai": "^4.0.1",
131121
"terser-webpack-plugin": "^5.3.11",
@@ -136,9 +126,7 @@
136126
"webpack": "^5.99.9",
137127
"webpack-bundle-analyzer": "^4.7.0",
138128
"webpack-cli": "^6.0.1",
139-
"which": "^2.0.2",
140-
"yaml": "^1.10.0",
141-
"knip": "^5.69.1"
129+
"yaml": "^1.10.0"
142130
},
143131
"optionalDependencies": {
144132
"lerna": "^8.1.8"

packages/java-shell/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"path-browserify": "^1.0.1",
2929
"stream-browserify": "^3.0.0",
3030
"util": "^0.12.5",
31-
"webpack-merge": "^5.8.0"
31+
"webpack-merge": "^5.8.0",
32+
"@mongosh/testing": "0.0.0-dev.0"
3233
},
3334
"license": "SSPL",
3435
"publishConfig": {

0 commit comments

Comments
 (0)