Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 22x 23x 23x 22x 5x 6x 5x 2x 2x | import chalk from 'chalk';
import type { ValidationError, ValidationWarning } from '../types.js';
export function formatErrors(prop: string, errors: ValidationError[]): string {
const details = errors
.map((e, i) => {
const exp = Array.isArray(e.expected) ? e.expected.join(', ') : String(e.expected ?? '');
return `${i + 1}.) Expected ${chalk.bold(e.segment)} value(s) of "${chalk.bold(exp)}" but received "${chalk.redBright(e.received)}".`;
})
.join(' ');
return `${errors.length} error(s) on ${chalk.cyan(prop)}: ${details}`;
}
export function formatLegacyWarning(prop: string, warnings: ValidationWarning[]): string {
const details = warnings
.map((w) => `"${chalk.bold(w.received)}" should be "${chalk.greenBright(w.canonical)}" (in ${w.segment})`)
.join('; ');
return `${chalk.black.yellowBright('Deprecated Syntax')} ${chalk.cyan(prop)} uses squash-case: ${details}. Please migrate to hyphenated form.`;
}
export function formatDeprecatedWarning(prop: string, deprecatedKey: string, replacement: string): string {
return `${chalk.black.yellowBright('Deprecated Warning')} The custom property ${chalk.cyan(prop)} includes a deprecated value of "${chalk.bold(deprecatedKey)}", please use "${chalk.greenBright(replacement)}" instead.`;
}
/** Remove when private component hooks are fully retired. */
export function formatPrivateHookWarning(prop: string): string {
return `${chalk.black.yellowBright('Deprecated')} ${chalk.cyan(prop)} uses private component hook syntax (--_slds-c-*). Private component hooks are deprecated and will be removed in a future release.`;
}
|