Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
codeFrame,
hints,
filePath,
language,
skipFormatting,
} = diagnostic;
let result = {
message: '',
stack: '',
codeframe: '',
hints: [],
};
result.message =
mdAnsi(`**${origin ?? 'unknown'}**: `) +
(skipFormatting ? message : mdAnsi(message));
result.stack = stack || '';
if (codeFrame !== undefined) {
let highlights = Array.isArray(codeFrame.codeHighlights)
? codeFrame.codeHighlights
: [codeFrame.codeHighlights];
let formattedCodeFrame = formatCodeFrame(codeFrame.code, highlights, {
useColor: true,
syntaxHighlighting: true,
language:
// $FlowFixMe sketchy null checks do not matter here...
language || (filePath ? path.extname(filePath).substr(1) : undefined),
});
hints,
filePath,
language,
skipFormatting,
} = diagnostic;
let result = {
message: '',
stack: '',
codeframe: '',
hints: [],
};
result.message =
mdAnsi(`**${origin ?? 'unknown'}**: `) +
(skipFormatting ? message : mdAnsi(message));
result.stack = stack || '';
if (codeFrame !== undefined) {
let highlights = Array.isArray(codeFrame.codeHighlights)
? codeFrame.codeHighlights
: [codeFrame.codeHighlights];
let formattedCodeFrame = formatCodeFrame(codeFrame.code, highlights, {
useColor: true,
syntaxHighlighting: true,
language:
// $FlowFixMe sketchy null checks do not matter here...
language || (filePath ? path.extname(filePath).substr(1) : undefined),
});
result.codeframe +=
result.hints = hints.map(h => {
return mdAnsi(h);
});
}