|
| 1 | +import type { KnipConfig } from "knip"; |
| 2 | + |
| 3 | +const config: KnipConfig = { |
| 4 | + // Ignore patterns for files that should not be analyzed |
| 5 | + ignore: [ |
| 6 | + // Build outputs |
| 7 | + "**/lib/**", |
| 8 | + "**/dist/**", |
| 9 | + "**/build/**", |
| 10 | + "**/coverage/**", |
| 11 | + "**/.nyc_output/**", |
| 12 | + // Generated files |
| 13 | + "**/tmp/**", |
| 14 | + "**/.sbom/**", |
| 15 | + // Test fixtures and data |
| 16 | + "**/test/fixtures/**", |
| 17 | + "**/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 |
| 23 | + ".evergreen/**", |
| 24 | + "config/**", |
| 25 | + "configs/**", |
| 26 | + ], |
| 27 | + |
| 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 | + ], |
| 59 | + |
| 60 | + // Workspace-specific configurations |
| 61 | + workspaces: { |
| 62 | + ".": { |
| 63 | + // Root workspace configuration |
| 64 | + entry: ["scripts/**/*.{js,ts,mjs}", "testing/**/*.ts"], |
| 65 | + }, |
| 66 | + |
| 67 | + // Config packages |
| 68 | + "configs/eslint-config-mongosh": { |
| 69 | + entry: ["index.js", "utils.js"], |
| 70 | + }, |
| 71 | + |
| 72 | + "configs/tsconfig-mongosh": { |
| 73 | + entry: ["tsconfig.common.json"], |
| 74 | + }, |
| 75 | + |
| 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 | + |
| 82 | + // Special cases for packages with different entry points |
| 83 | + "packages/cli-repl": { |
| 84 | + entry: ["bin/mongosh.js", "src/run.ts", "dist/add-module-mapping.js"], |
| 85 | + project: ["src/**/*.ts", "bin/**/*.js"], |
| 86 | + }, |
| 87 | + |
| 88 | + "packages/shell-api": { |
| 89 | + entry: ["src/api.ts"], |
| 90 | + project: ["src/**/*.ts"], |
| 91 | + }, |
| 92 | + |
| 93 | + "packages/build": { |
| 94 | + entry: [ |
| 95 | + "src/evergreen-release.ts", |
| 96 | + "src/release.ts", |
| 97 | + "src/update-cta.ts", |
| 98 | + ], |
| 99 | + project: ["src/**/*.ts"], |
| 100 | + }, |
| 101 | + |
| 102 | + "packages/e2e-tests": { |
| 103 | + entry: ["test/**/*.ts"], |
| 104 | + project: ["test/**/*.ts"], |
| 105 | + }, |
| 106 | + |
| 107 | + "packages/browser-repl": { |
| 108 | + entry: ["src/index.tsx"], |
| 109 | + project: ["src/**/*.{ts,tsx}"], |
| 110 | + }, |
| 111 | + |
| 112 | + "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", |
| 123 | + ], |
| 124 | + }, |
| 125 | + |
| 126 | + "packages/connectivity-tests": { |
| 127 | + entry: ["index.js"], |
| 128 | + project: ["**/*.js"], |
| 129 | + }, |
| 130 | + |
| 131 | + testing: { |
| 132 | + entry: [ |
| 133 | + "eventually.ts", |
| 134 | + "fake-kms.ts", |
| 135 | + "integration-testing-hooks.ts", |
| 136 | + "disable-dns-srv.js", |
| 137 | + ], |
| 138 | + project: ["**/*.{ts,js}"], |
| 139 | + }, |
| 140 | + |
| 141 | + "scripts/docker": { |
| 142 | + entry: ["**/*.js"], |
| 143 | + project: ["**/*.js"], |
| 144 | + }, |
| 145 | + }, |
| 146 | + |
| 147 | + // Mocha test files configuration |
| 148 | + mocha: { |
| 149 | + config: ["**/mocharc.{js,json,yml,yaml}", "**/.mocharc.{js,json,yml,yaml}"], |
| 150 | + entry: ["**/*.spec.{ts,tsx,js}", "**/*.test.{ts,tsx,js}"], |
| 151 | + }, |
| 152 | + |
| 153 | + // TypeScript configuration |
| 154 | + typescript: { |
| 155 | + config: [ |
| 156 | + "tsconfig.json", |
| 157 | + "tsconfig-lint.json", |
| 158 | + "**/tsconfig.json", |
| 159 | + "**/tsconfig-lint.json", |
| 160 | + "configs/tsconfig-mongosh/tsconfig.common.json", |
| 161 | + ], |
| 162 | + }, |
| 163 | + |
| 164 | + // Webpack configuration |
| 165 | + webpack: { |
| 166 | + config: ["config/webpack.base.config.js", "**/webpack.config.js"], |
| 167 | + }, |
| 168 | + |
| 169 | + // ESLint configuration |
| 170 | + eslint: { |
| 171 | + config: [ |
| 172 | + "configs/eslint-config-mongosh/index.js", |
| 173 | + "**/.eslintrc.{js,json}", |
| 174 | + ], |
| 175 | + }, |
| 176 | + |
| 177 | + // Prettier configuration |
| 178 | + prettier: { |
| 179 | + config: [ |
| 180 | + ".prettierrc", |
| 181 | + ".prettierrc.{js,json,yml,yaml}", |
| 182 | + "prettier.config.js", |
| 183 | + ], |
| 184 | + }, |
| 185 | + |
| 186 | + // Nyc (test coverage) configuration |
| 187 | + nyc: { |
| 188 | + config: [".nycrc", ".nycrc.{json,yml,yaml}", "nyc.config.js"], |
| 189 | + }, |
| 190 | +}; |
| 191 | + |
| 192 | +export default config; |
0 commit comments