|
| 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; |
0 commit comments