Skip to content

Commit 3e962d5

Browse files
authored
chore: use knip for dependency checking (#2613)
1 parent b9c4a5f commit 3e962d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1084
-1141
lines changed

.knipignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Knip ignore file - patterns to exclude from analysis
2+
3+
# Build outputs
4+
**/lib/**
5+
**/dist/**
6+
**/build/**
7+
8+
# Coverage and test outputs
9+
**/coverage/**
10+
**/.nyc_output/**
11+
12+
# Generated files
13+
**/tmp/**
14+
**/.sbom/**
15+
16+
# Test fixtures
17+
**/test/fixtures/**
18+
**/test/data/**
19+
20+
# Evergreen CI specific
21+
.evergreen/**
22+
23+
# Async rewriter3 (Rust/WASM project)
24+
packages/async-rewriter3/**
25+
26+
# Lock files and dependencies
27+
**/node_modules/**
28+
package-lock.json
29+
npm-shrinkwrap.json
30+
yarn.lock
31+
pnpm-lock.yaml
32+
33+
# IDE and editor files
34+
**/.vscode/**
35+
**/.idea/**
36+
**/*.swp
37+
**/*.swo
38+
**/*~
39+
40+
# OS files
41+
**/.DS_Store
42+
**/Thumbs.db
43+

knip.ts

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
import type { KnipConfig } from "knip";
2+
import fs from "fs";
3+
4+
// Create an empty file to satisfy the knip rule for async-rewriter2
5+
fs.writeFileSync(
6+
"packages/async-rewriter2/src/runtime-support.out.nocov.ts",
7+
""
8+
);
9+
10+
const config: KnipConfig = {
11+
rules: {
12+
// Disable checking for unused exports, unused exported types, and duplicate dependencies.
13+
exports: "off",
14+
types: "off",
15+
duplicates: "off",
16+
},
17+
// Ignore patterns for files that should not be analyzed
18+
ignore: [
19+
// Build outputs
20+
"**/lib/**",
21+
"**/dist/**",
22+
"**/build/**",
23+
"**/coverage/**",
24+
"**/.nyc_output/**",
25+
// Generated files
26+
"**/tmp/**",
27+
"**/.sbom/**",
28+
"**/test/data/**",
29+
// Configuration files
30+
".evergreen/**",
31+
"config/**",
32+
"configs/**",
33+
"**/.eslintrc.js",
34+
],
35+
36+
// Received from @mongodb-js/sbom-tools
37+
ignoreBinaries: ["mongodb-sbom-tools"],
38+
39+
// Workspace-specific configurations
40+
workspaces: {
41+
// Root package (monorepo root, no entry file needed)
42+
".": {
43+
entry: ["scripts/*.ts"],
44+
project: [],
45+
ignoreBinaries: [
46+
// Lerna is listed as an optional dependency.
47+
"lerna",
48+
],
49+
},
50+
51+
// Config packages
52+
"configs/eslint-config-mongosh": {
53+
entry: ["utils.js"],
54+
},
55+
56+
"configs/tsconfig-mongosh": {
57+
entry: ["tsconfig.common.json"],
58+
},
59+
60+
// Special cases for packages with different entry points
61+
"packages/cli-repl": {
62+
project: ["src/**/*.ts!", "bin/**/*.js", "test/**/*.ts"],
63+
ignoreDependencies: [
64+
// Eagerly loaded startup snapshot dependencies
65+
"@mongodb-js/saslprep",
66+
"socks",
67+
"emphasize",
68+
"ipv6-normalize",
69+
"bindings",
70+
"system-ca",
71+
// Used for monkey-patching our s390x fix
72+
"@tootallnate/quickjs-emscripten",
73+
],
74+
},
75+
76+
"packages/shell-api": {
77+
entry: ["src/api.ts!", "scripts/*.ts", "test/*.ts"],
78+
},
79+
80+
"packages/mongosh": {
81+
project: ["bin/**/*.js"],
82+
},
83+
84+
"packages/e2e-tests": {
85+
entry: ["test/**/*.ts", "test/fixtures/**/*"],
86+
ignoreDependencies: [
87+
// This is used for version check. TODO: Consider changing that test.
88+
"@mongosh/cli-repl",
89+
],
90+
},
91+
92+
"scripts/docker": {
93+
ignoreDependencies: [
94+
// Used by build.sh script.
95+
"mongodb-crypt-library-version",
96+
],
97+
},
98+
99+
"packages/service-provider-node-driver": {
100+
ignoreDependencies: [
101+
// Used for MONGODB-AWS auth
102+
// See: https://github.com/mongodb-js/mongosh/pull/1149
103+
// See: https://jira.mongodb.org/browse/NODE-5005
104+
"aws4",
105+
],
106+
},
107+
108+
"packages/node-runtime-worker-thread": {
109+
ignoreDependencies: [
110+
// Used in worker thread context
111+
"system-ca",
112+
],
113+
ignoreFiles: [
114+
// Used in package.json
115+
"tests/register-worker.js",
116+
],
117+
},
118+
119+
"packages/errors": {
120+
entry: ["src/index.ts!", "scripts/*.ts"],
121+
},
122+
123+
"packages/browser-repl": {
124+
entry: ["src/index.tsx!", "config/*.js"],
125+
project: ["src/**/*.{ts,tsx}!"],
126+
ignoreDependencies: [
127+
"@wojtekmaj/enzyme-adapter-react-17",
128+
"enzyme",
129+
// Karma test runner plugins
130+
"karma-chrome-launcher",
131+
"karma-mocha",
132+
"karma-mocha-reporter",
133+
"karma-typescript",
134+
// Resolved as `<depname>/`
135+
"buffer",
136+
"util",
137+
],
138+
},
139+
140+
"packages/java-shell": {
141+
entry: ["src/test/js/run-tests.ts"],
142+
project: ["src/main/js/**/*"],
143+
ignoreDependencies: [
144+
// Used in webpack and build scripts
145+
"bson",
146+
"tr46",
147+
"assert",
148+
"buffer",
149+
"util",
150+
],
151+
},
152+
153+
"packages/connectivity-tests": {
154+
entry: ["scripts/disable-dns-srv.js"],
155+
// This package only contains bash test scripts
156+
ignoreDependencies: [
157+
// Used by test scripts
158+
"mongosh",
159+
],
160+
},
161+
162+
"packages/async-rewriter2": {
163+
entry: [
164+
"src/index.ts!",
165+
"bin/*.js!",
166+
"test/fixtures/**/*",
167+
"scripts/*.js",
168+
"benchmark/index.ts",
169+
],
170+
ignoreFiles: [
171+
// Used by make-runtime-support.js
172+
"src/runtime-support.nocov.js",
173+
],
174+
},
175+
176+
"packages/snippet-manager": {
177+
entry: ["test/fixtures/**/*"],
178+
},
179+
180+
testing: {
181+
entry: ["src/**/*.ts"],
182+
project: ["src/**/*.ts"],
183+
},
184+
},
185+
186+
// Mocha test files configuration
187+
mocha: {
188+
config: ["**/mocharc.{js,json,yml,yaml}", "**/.mocharc.{js,json,yml,yaml}"],
189+
entry: ["**/*.spec.{ts,tsx,js}", "**/*.test.{ts,tsx,js}"],
190+
},
191+
192+
// TypeScript configuration
193+
typescript: {
194+
config: [
195+
"tsconfig.json",
196+
"tsconfig-lint.json",
197+
"**/tsconfig.json",
198+
"**/tsconfig-lint.json",
199+
"configs/tsconfig-mongosh/tsconfig.common.json",
200+
],
201+
},
202+
203+
// Webpack configuration
204+
webpack: {
205+
config: [
206+
"config/webpack.base.config.js",
207+
"**/webpack.config.js",
208+
"**/webpack.config.*.js",
209+
],
210+
},
211+
212+
// ESLint configuration
213+
eslint: {
214+
config: [
215+
"configs/eslint-config-mongosh/index.js",
216+
"**/.eslintrc.{js,json}",
217+
],
218+
},
219+
220+
// Prettier configuration
221+
prettier: {
222+
config: [
223+
".prettierrc",
224+
".prettierrc.{js,json,yml,yaml}",
225+
"prettier.config.js",
226+
],
227+
},
228+
229+
// Nyc (test coverage) configuration
230+
nyc: {
231+
config: [".nycrc", ".nycrc.{json,yml,yaml}", "nyc.config.js"],
232+
},
233+
};
234+
235+
export default config;

mongosh.code-workspace

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
"name": "📦 @mongosh/history",
3333
"path": "packages/history"
3434
},
35-
{
36-
"name": "📦 @mongosh/java-shell",
37-
"path": "packages/java-shell"
38-
},
3935
{
4036
"name": "📦 @mongosh/js-multiline-to-singleline",
4137
"path": "packages/js-multiline-to-singleline"
@@ -64,6 +60,10 @@
6460
"name": "📦 @mongosh/arg-parser",
6561
"path": "packages/arg-parser"
6662
},
63+
{
64+
"name": "📦 @mongosh/java-shell",
65+
"path": "packages/java-shell"
66+
},
6767
{
6868
"name": "📦 @mongosh/service-provider-core",
6969
"path": "packages/service-provider-core"

0 commit comments

Comments
 (0)