Configuration
Configuration is optional. nestjs-doctor applies reasonable defaults when no configuration file is present.
Config File
Create nestjs-doctor.config.json in your project root:
{
"minScore": 75,
"ignore": {
"rules": ["architecture/no-orm-in-services"],
"files": ["src/generated/**"]
},
"rules": {
"architecture/no-barrel-export-internals": false
},
"categories": {
"performance": false
}
}
Or use a "nestjs-doctor" key in package.json:
{
"nestjs-doctor": {
"minScore": 75,
"rules": {
"architecture/no-barrel-export-internals": false
}
}
}
Config Resolution
The config loader searches for configuration in this order:
- Explicit path via
--configflag nestjs-doctor.config.jsonin the project root.nestjs-doctor.jsonin the project root"nestjs-doctor"key inpackage.json- Built-in defaults
The first match takes precedence. See Config Loading for implementation details.
Options
| Key | Type | Description |
|---|---|---|
include | string[] | Glob patterns to scan (default: ["**/*.ts"]) |
exclude | string[] | Glob patterns to skip (additive with defaults) |
minScore | number | Minimum passing score (0-100) |
ignore.rules | string[] | Rule IDs to suppress |
ignore.files | string[] | Glob patterns for files whose diagnostics are hidden |
rules | Record<string, RuleOverride | boolean> | Enable/disable individual rules, or override severity |
categories | Record<string, boolean> | Enable/disable entire categories |
customRulesDir | string | Path to a directory of custom .ts rule files |
Rules can be set to false to disable them, or configured with an object to override severity:
{
"rules": {
"architecture/no-barrel-export-internals": false,
"security/no-hardcoded-secret": { "enabled": true, "severity": "error" }
}
}
Rule objects can also include rule-specific options. Example for no-manual-instantiation:
{
"rules": {
"architecture/no-manual-instantiation": {
"excludeClasses": ["Logger", "PinoLogger"]
}
}
}
Default Excludes
These patterns are always excluded (your exclude config is additive):
node_modules/**,dist/**,build/**,coverage/****/*.spec.ts,**/*.test.ts,**/*.e2e-spec.ts,**/*.e2e-test.ts**/*.d.ts**/test/**,**/tests/**,**/__tests__/****/__mocks__/**,**/__fixtures__/**,**/mock/**,**/mocks/**,**/*.mock.ts**/seeder/**,**/seeders/**,**/*.seed.ts,**/*.seeder.ts
Include vs Exclude Behavior
excludepatterns are additive to defaults. Your patterns are appended, so safety exclusions likenode_modulesare never accidentally removed.includepatterns replace defaults entirely. If you setinclude, only those patterns are scanned.
Monorepo Support
Monorepo mode is auto-detected using five strategies (checked in priority order — first match wins):
1. nest-cli.json (takes precedence)
{
"monorepo": true,
"projects": {
"api": { "root": "apps/api" },
"admin": { "root": "apps/admin" },
"shared": { "root": "libs/shared" }
}
}
2. pnpm-workspace.yaml (pnpm / Turborepo)
packages:
- "apps/*"
- "packages/*"
3. package.json workspaces (npm / Yarn)
Both array and object formats are supported. Skipped when pnpm-workspace.yaml exists.
{
"workspaces": ["apps/*", "packages/*"]
}
4. nx.json (Nx)
Discovers sub-projects by scanning for project.json files alongside nx.json.
5. lerna.json (standalone Lerna)
Used when useWorkspaces is not set. Defaults to ["packages/*"] if no packages globs are specified. When useWorkspaces is true, detection falls through to strategy 3.
{
"packages": ["packages/*"]
}
Non-NestJS packages are always filtered out — only packages with @nestjs/core or @nestjs/common are included. If a monorepo is detected but no NestJS packages are found, nestjs-doctor emits a warning and falls back to single-project mode.
Each sub-project is scanned independently. Per-project config files are supported — place a nestjs-doctor.config.json inside a sub-project's root to override the root config for that project.
The report shows a combined score plus a per-project breakdown.
Scoring
Scores are weighted by severity and category, normalized by file count:
| Severity | Weight | Category | Multiplier | |
|---|---|---|---|---|
| error | 3.0 | security | 1.5x | |
| warning | 1.5 | correctness | 1.3x | |
| info | 0.5 | schema | 1.1x | |
| architecture | 1.0x | |||
| performance | 0.8x |
| Score | Label |
|---|---|
| 90-100 | Excellent |
| 75-89 | Good |
| 50-74 | Fair |
| 25-49 | Poor |
| 0-24 | Critical |
See Scoring for the full formula and calibration details.