v0.2.2-beta

Reference

Configuration.

ngcompass is configured via ngcompass.config.ts in your project root. Run ng add ngcompass to install locally and generate a starter config. Run npx ngcompass config health to validate it.

Full example

ngcompass.config.ts
01import { defineConfig } from '@ngcompass/config';
02
03export default defineConfig({
04 // Preset to extend (string or array of strings)
05 extends: 'ngcompass:recommended',
06
07 // Files to scan
08 include: [
09 'src/**/*.ts',
10 'src/**/*.html',
11 ],
12 exclude: [
13 'node_modules/**',
14 'dist/**',
15 'build/**',
16 'coverage/**',
17 '**/*.d.ts',
18 '**/*.spec.ts',
19 '**/*.test.ts',
20 ],
21
22 // Rule overrides - 'off' | 'warn' | 'error'
23 rules: {
24 'prefer-on-push-component-change-detection': 'error',
25 'no-document-access': 'warn',
26 'rxjs-no-subscribe-in-component': 'error',
27 'template-prefer-control-flow': 'warn',
28 'spec-no-focused-test': 'off',
29 },
30
31 // Severity threshold for non-zero exit
32 failOnSeverity: 'error', // 'warn' | 'error'
33 maxWarnings: 10, // fail if warnings exceed this
34
35 // Cache settings
36 cache: {
37 enabled: true,
38 strategy: 'local', // 'memory' | 'local'
39 location: 'node_modules/.cache/ngcompass',
40 ttl: 86400000, // 24 hours in ms
41 },
42
43 // Concurrency (default: CPU count - 1)
44 maxWorkers: 4,
45
46 // Output defaults (can be overridden on the CLI)
47 outputFormat: 'console', // 'console' | 'json' | 'sarif' | 'html'
48 outputPath: 'ngcompass-report.html',
49
50 // Per-file-pattern overrides
51 overrides: [
52 {
53 files: ['src/app/legacy/**/*.ts'],
54 rules: {
55 'prefer-inject-over-constructor-di': 'off',
56 },
57 },
58 ],
59
60 // Named profiles - activate with --profile <name>
61 profiles: {
62 ci: {
63 failOnSeverity: 'warn',
64 rules: {
65 'spec-no-focused-test': 'error',
66 },
67 },
68 },
69
70 // TypeScript project reference
71 parserOptions: {
72 project: './tsconfig.json',
73 tsconfigRootDir: '.',
74 },
75});

Options reference

  • extendsstring | string[]

    Preset or array of presets to extend. See the Presets page for available values.

  • includestring[]default "src/**/*.ts"

    Glob patterns for files to analyze.

  • excludestring[]default "**/*.spec.ts"

    Glob patterns to exclude. Spec and stories files are excluded by default.

  • rulesRecord<ruleId, severity>

    Per-rule severity overrides. Values: "off" | "warn" | "error". Can also accept an object with { severity, options }.

  • failOnSeverity"warn" | "error"default "error"

    Exit with a non-zero code when violations at this severity or above are found.

  • maxWarningsnumberdefault 10

    Maximum allowed warnings before the process exits with a non-zero code.

  • cacheboolean | CacheOptionsdefault true

    Enable or configure incremental caching. When true, uses local disk cache in node_modules/.cache/ngcompass with a 24h TTL.

  • maxWorkersnumberdefault CPU count - 1

    Maximum worker threads for parallel analysis. Syntax-only rules run in workers; type-aware rules serialize on the main thread.

  • outputFormat"console" | "json" | "sarif" | "html"default "console"

    Default output format. Overridden by --format on the CLI.

  • outputPathstringdefault "ngcompass-report.html"

    Path for the UI/HTML report file.

  • overridesOverride[]

    File-pattern-scoped rule overrides. Each entry has a files glob array and a rules object.

  • profilesRecord<name, PartialConfig>

    Named partial configs. Activate with --profile <name> on the CLI.

  • ignorePatternsstring[]

    Additional glob patterns to ignore beyond exclude.

  • parserOptionsParserOptions

    TypeScript project options. Accepts project, tsconfigRootDir, sourceType, and ecmaVersion.

File-pattern overrides

Use overrides to apply different rule severities to specific file patterns — useful for legacy code or generated files.

typescript
01overrides: [
02 {
03 files: ['src/app/legacy/**/*.ts'],
04 rules: {
05 'prefer-inject-over-constructor-di': 'off',
06 'prefer-on-push-component-change-detection': 'warn',
07 },
08 },
09],

Profiles

Profiles let you define partial config overrides that you activate with the --profile <name> flag. Useful for running stricter rules in CI than locally.

typescript
01profiles: {
02 ci: {
03 failOnSeverity: 'warn',
04 maxWarnings: 0,
05 rules: {
06 'spec-no-focused-test': 'error',
07 },
08 },
09 local: {
10 failOnSeverity: 'error',
11 },
12},

Activate a profile:

bash
01npx ngcompass analyze --profile ci

Validate your config

bash
01npx ngcompass config health

Validates the active config, reports unknown rule IDs, invalid severity values, and schema errors.

CLI flags reference

Flags passed on the command line override the equivalent config-file settings for that run only.

  • --profile <name>

    Activate a named profile defined in the profiles config key.

  • --format <fmt>

    Output format for this run: console | json | sarif | html | ui (ui is an alias for html). Overrides outputFormat from config.

  • --compact

    Use ESLint-style single-line output (only applies to console format).

  • -q, --quiet

    Show summary counts only — suppress individual violation details. Useful in CI when you only care about pass/fail.

  • --no-recommendation

    Suppress fix recommendations from output. Violations are still reported; only the fix hint line is hidden.

  • --output <path>

    Output path for HTML reports. Overrides outputPath from config.

  • --force

    Ignore cached results and re-run all checks. Results are not written back to cache.

  • --rule <id>

    Run only a single rule by ID. Useful for debugging or focused checks on one pattern.

  • --max-workers <n>number

    Cap the number of worker threads. Lower values use less memory (e.g. --max-workers 2). Overrides maxWorkers from config.

  • --mode <mode>

    Performance preset: balanced | turbo. balanced is the default, turbo maximises throughput on capable machines.

  • --skip-type-check

    Skip rules that require the TypeScript type checker. Fastest mode with lowest memory usage — syntax-only rules still run.