import type { DtifFlattenedToken, RuleContext, RuleListener, RuleMeta, RuleModule } from '../../core/types.js'; /** * Configuration for creating a token-based rule via {@link tokenRule}. * * @typeParam TOptions - Shape of the rule options. * @typeParam TAllowed - Structure representing the computed allowed values. */ interface TokenRuleConfig { /** The rule name, e.g. `design-token/example`. */ name: string; meta: RuleMeta; tokens: string | string[]; /** Message to report when no allowed tokens are found. */ message: string; getAllowed: (context: RuleContext, tokens: readonly DtifFlattenedToken[]) => TAllowed; create: (context: RuleContext, allowed: TAllowed) => RuleListener; /** Determines whether the allowed set is effectively empty. */ isEmpty?: (allowed: TAllowed) => boolean; } /** * Simplifies writing rules that operate on design tokens by handling token * collection, allowed-value preparation, and empty-state reporting. * * @typeParam TOptions - Shape of the rule options. * @typeParam TAllowed - Structure representing the computed allowed values. * * @example * const myRule = tokenRule({ * name: 'example/no-red', * meta: { description: 'disallow red tokens' }, * tokens: 'color', * message: 'red tokens are not allowed', * getAllowed: () => new Set(['blue']), * create(ctx, allowed) { * return { * onToken(token) { * if (!allowed.has(token.$value)) { * ctx.report({ message: token.$value, line: 1, column: 1 }); * } * }, * }; * }, * }); */ export declare function tokenRule>(config: TokenRuleConfig): RuleModule; export type { TokenRuleConfig }; //# sourceMappingURL=token-rule.d.ts.map