diff --git a/src/index.ts b/src/index.ts index 34342423e..0917208e9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -46,7 +46,7 @@ class DXScannerCommand extends Command { const scanPath = args.path || process.cwd(); cli.action.start(`Scanning URI: ${scanPath}`); - const container = createRootContainer({ uri: scanPath, auth: authorization, json: json, fail: fail }); + const container = createRootContainer({ uri: scanPath, auth: authorization, json: json, fail: fail }); const scanner = container.get(Scanner); try { diff --git a/src/scanner/ScannerUtils.ts b/src/scanner/ScannerUtils.ts index fd91a3030..2e0e466e6 100644 --- a/src/scanner/ScannerUtils.ts +++ b/src/scanner/ScannerUtils.ts @@ -7,6 +7,7 @@ import { PracticeImpact } from '../model'; import { IPracticeWithMetadata } from '../practices/DxPracticeDecorator'; import { IPractice } from '../practices/IPractice'; import { PracticeWithContext } from './Scanner'; +import { assertNever } from '../lib/assertNever'; /** * Scanner helpers & utilities @@ -99,4 +100,22 @@ export class ScannerUtils { return { customApplicablePractices, practicesOff }; } + + /** + * Get all levels to fail on + */ + static getImpactFailureLevels = (impact: PracticeImpact | 'all' | undefined) => { + switch (impact) { + case PracticeImpact.high: + return [PracticeImpact.high]; + case PracticeImpact.medium: + return [PracticeImpact.high, PracticeImpact.medium]; + case PracticeImpact.small: + return [PracticeImpact.high, PracticeImpact.medium, PracticeImpact.small]; + case PracticeImpact.hint: + return [PracticeImpact.high, PracticeImpact.medium, PracticeImpact.small, PracticeImpact.hint]; + default: + return []; + } + }; }