@sketch-hq/sketch-assistant-utils
Version:
Utility functions and types for Sketch Assistants.
60 lines • 2.96 kB
TypeScript
import { Assistant, AssistantConfig, AssistantDefinition, AssistantEnv, AssistantPackage, AssistantRuntime, AssistantSuccessResult, FileFormat, RuleConfig, RuleConfigGroup, RuleDefinition, RuleFunction, RuleOptionsCreator, ViolationSeverity } from '@sketch-hq/sketch-assistant-types';
/**
* Create a dummy rule definition.
*/
declare const createRule: ({ title, description, rule, getOptions, name, debug, runtime, }?: {
title?: string | ((ruleConfig: RuleConfig) => string) | undefined;
description?: string | ((ruleConfig: RuleConfig) => string) | undefined;
rule?: RuleFunction | undefined;
name?: string | undefined;
getOptions?: RuleOptionsCreator | undefined;
debug?: boolean | undefined;
runtime?: AssistantRuntime | undefined;
}) => RuleDefinition;
/**
* Create a dummy assistant configuration.
*/
declare const createAssistantConfig: ({ rules, defaultSeverity, }?: {
rules?: RuleConfigGroup | undefined;
defaultSeverity?: ViolationSeverity | undefined;
}) => AssistantConfig;
/**
* Create a dummy assistant definition.
*/
declare const createAssistantDefinition: ({ name, config, rules, }?: {
title?: string | undefined;
description?: string | undefined;
name?: string | undefined;
config?: AssistantConfig | undefined;
rules?: RuleDefinition[] | undefined;
}) => AssistantDefinition;
/**
* Create a dummy assistant function.
*/
declare const createAssistant: ({ title, description, name, config, rules, }?: {
title?: string | undefined;
description?: string | undefined;
name?: string | undefined;
config?: AssistantConfig | undefined;
rules?: RuleDefinition[] | undefined;
}) => Assistant;
declare const createDummyRect: () => FileFormat.Rect;
declare const createDummySwatch: (id?: string) => FileFormat.Swatch;
declare type TestResult = Omit<AssistantSuccessResult, 'metadata' | 'profile'>;
/**
* Test an Assistant.
*/
declare const testAssistant: (filepath: string, assistant: AssistantPackage, env?: AssistantEnv) => Promise<TestResult>;
/**
* Test a rule by running it against a custom config within the context of a
* temporary Assistant.
*/
declare const testRule: (filepath: string, rule: RuleDefinition, ruleConfig?: RuleConfig, env?: AssistantEnv) => Promise<TestResult>;
/**
* Test a rule in isolation within the context of an Assistant. Only the rule under test is
* activated, so violations or rule errors from other rules are ignored. A custom rule config can
* be supplied, but if omitted the config currently configured in the Assistant is used.
*/
declare const testRuleInAssistant: (filepath: string, assistant: AssistantPackage, ruleName: string, ruleConfig?: RuleConfig | undefined, env?: AssistantEnv) => Promise<TestResult>;
export { createRule, createDummyRect, createDummySwatch, createAssistantConfig, createAssistant, createAssistantDefinition, testRule, testRuleInAssistant, testAssistant, };
//# sourceMappingURL=index.d.ts.map