All files / packages/sds-stylelint-config/src/validators/global helpers.ts

100% Statements 9/9
100% Branches 5/5
100% Functions 3/3
100% Lines 9/9

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            71x             42x 42x 73x 73x 5x           5x   68x   42x    
import type { ValidationWarning } from '../../types.js';
 
// Re-export err from shared helpers (single source of truth)
export { err } from '../shared/helpers.js';
 
export function hasNumericRange(segments: string[]): boolean {
  return segments.length > 0 && !Number.isNaN(Number(segments.at(-1)));
}
 
export function resolveDescriptor(
  segments: string[],
  aliases: Record<string, string> = {},
): { descriptor: string; warnings: ValidationWarning[] } {
  const warnings: ValidationWarning[] = [];
  const resolved = segments.map((seg) => {
    const canonical = aliases[seg];
    if (canonical) {
      warnings.push({
        type: 'legacy-syntax',
        segment: 'descriptor',
        received: seg,
        canonical,
      });
      return canonical;
    }
    return seg;
  });
  return { descriptor: resolved.join('-'), warnings };
}