UNPKG

@stylable/core

Version:

CSS for Components

38 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.emitDiagnostics = exports.reportDiagnostic = void 0; /** * Helper function to report diagnostics for every diagnosticsMode */ function reportDiagnostic(ctx, diagnosticsMode, { code, message, severity }, from) { const messageToPrint = `[${severity}: ${code}]: ${message}`; const error = new Error(from ? `[${from}]:\n\n${messageToPrint}` : messageToPrint); if (severity === 'info') { ctx.emitWarning(error); return; } if (diagnosticsMode === 'auto') { if (severity === 'warning') { ctx.emitWarning(error); } else if (severity === 'error') { ctx.emitError(error); } } else if (diagnosticsMode === 'strict') { ctx.emitError(error); } else if (diagnosticsMode === 'loose') { ctx.emitWarning(error); } } exports.reportDiagnostic = reportDiagnostic; function emitDiagnostics(ctx, meta, diagnosticsMode, filePath) { meta.diagnostics?.reports.forEach(handleReport); meta.transformDiagnostics?.reports.forEach(handleReport); function handleReport(diagnostic) { reportDiagnostic(ctx, diagnosticsMode, diagnostic, filePath); } } exports.emitDiagnostics = emitDiagnostics; //# sourceMappingURL=report-diagnostic.js.map