UNPKG

@salesforce-ux/eslint-plugin-slds

Version:

ESLint plugin provides custom linting rules specifically built for Salesforce Lightning Design System 2 (SLDS 2 beta)

61 lines (60 loc) 2.26 kB
import type { HandlerContext } from '../types'; import type { ParsedUnitValue } from './value-utils'; /** * Common replacement data structure used by both color and density handlers */ export interface ReplacementInfo { start: number; end: number; replacement: string; displayValue: string; hasHook: boolean; } /** * Position information from CSS tree parsing */ export interface PositionInfo { start?: { offset: number; line: number; column: number; }; end?: { offset: number; line: number; column: number; }; } /** * Generic callback for processing values with position information */ export type ValueCallback<T> = (value: T, positionInfo?: PositionInfo) => void; /** * Check if a value is a known font-weight */ export declare function isKnownFontWeight(value: string | number): boolean; /** * Generic shorthand auto-fix handler * Handles the common logic for reconstructing shorthand values with replacements */ export declare function handleShorthandAutoFix(declarationNode: any, context: HandlerContext, valueText: string, replacements: ReplacementInfo[]): void; /** * Generic CSS tree traversal with position tracking * Always provides position information since both handlers need it */ export declare function forEachValue<T>(valueText: string, extractValue: (node: any) => T | null, shouldSkipNode: (node: any) => boolean, callback: (value: T, positionInfo: PositionInfo) => void): void; /** * Specialized color value traversal * Handles color-specific extraction and skipping logic */ export declare function forEachColorValue(valueText: string, callback: (colorValue: string, positionInfo: PositionInfo) => void): void; /** * Specialized density value traversal * Handles dimension-specific extraction and skipping logic */ export declare function forEachDensityValue(valueText: string, cssProperty: string, callback: (parsedDimension: ParsedUnitValue, positionInfo: PositionInfo) => void): void; /** * Specialized font value traversal * Handles font-specific extraction and skipping logic */ export declare function forEachFontValue(valueText: string, callback: (fontValue: ParsedUnitValue, positionInfo: PositionInfo) => void): void;