Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (newRule === 'recommended') {
return existingRule.recommended !== false ? existingSeverity : -1;
}
if (newRule === 'all') {
return existingSeverity;
}
return getSeverityForRule(newRule, existingSeverity);
}
const SEVERITY_MAP: Dictionary = {
error: DiagnosticSeverity.Error,
warn: DiagnosticSeverity.Warning,
info: DiagnosticSeverity.Information,
hint: DiagnosticSeverity.Hint,
off: -1,
};
export function getDiagnosticSeverity(
severity: DiagnosticSeverity | HumanReadableDiagnosticSeverity,
): SpectralDiagnosticSeverity {
if (Number.isNaN(Number(severity))) {
return SEVERITY_MAP[severity];
}
return Number(severity);
}
Object.keys(groupedResults).map((path, index) => {
const pathResults = groupedResults[path];
const {
[DiagnosticSeverity.Error]: errors,
[DiagnosticSeverity.Warning]: warnings,
[DiagnosticSeverity.Information]: infos,
[DiagnosticSeverity.Hint]: hints,
} = groupBySeverity(pathResults);
errorCount += errors.length;
warningCount += warnings.length;
infoCount += infos.length;
hintCount += hints.length;
output += `${chalk.underline(path)}\n`;
const pathTableData = sortResults(pathResults).map((result: IRuleResult) => [
formatRange(result.range),
getMessageType(result.severity),
result.code !== undefined ? result.code : '',
result.message,
]);
*/
function pluralize(word: string, count: number): string {
return count === 1 ? word : `${word}s`;
}
function formatRange(range?: IRange): string {
if (!range) return '';
return ` ${range.start.line + 1}:${range.start.character + 1}`;
}
const SEVERITY_COLORS = {
[DiagnosticSeverity.Error]: 'red',
[DiagnosticSeverity.Warning]: 'yellow',
[DiagnosticSeverity.Information]: 'blue',
[DiagnosticSeverity.Hint]: 'white',
};
function getColorForSeverity(severity: DiagnosticSeverity) {
return SEVERITY_COLORS[severity];
}
function getMessageType(severity: DiagnosticSeverity) {
const color = getColorForSeverity(severity);
switch (severity) {
case DiagnosticSeverity.Error:
return chalk[color]('error');
case DiagnosticSeverity.Warning:
return chalk[color]('warning');
case DiagnosticSeverity.Information:
return chalk[color]('information');