@sketch-hq/sketch-assistant-utils
Version:
Utility functions and types for Sketch Assistants.
34 lines • 1.6 kB
TypeScript
import { ErrorObject } from 'ajv';
import { AssistantConfig, Maybe, RuleConfig, ViolationSeverity, RuleDefinition } from '@sketch-hq/sketch-assistant-types';
/**
* Get rule configuration from an assistant config.
*/
declare const getRuleConfig: (config: AssistantConfig, ruleName: string) => Maybe<RuleConfig>;
/**
* Determine if the rule has been mentioned in a given config.
*/
declare const isRuleConfigured: (config: AssistantConfig, ruleName: string) => boolean;
/**
* Get the value of a specific rule option.
*/
declare const getRuleOption: (config: AssistantConfig, ruleName: string, optionKey: string) => null | unknown;
/**
* Validate a rule's options in a config object according to the schema defined
* on the rule module.
*/
declare const isRuleConfigValid: (config: AssistantConfig, rule: RuleDefinition) => true | ErrorObject[];
/**
* Determine if a rule is active. An active rule must both be mentioned in the
* config and have its `active` option set to `true`.
*/
declare const isRuleActive: (config: AssistantConfig, ruleName: string) => boolean;
/**
* Determine a rule's severity, falling back to default values if not specified.
*/
declare const getRuleSeverity: (config: AssistantConfig, ruleName: string) => ViolationSeverity;
/**
* Return the custom title for a rule if its been defined at configuration-time.
*/
declare const getRuleTitle: (config: AssistantConfig, ruleName: string) => string | null;
export { getRuleConfig, getRuleOption, isRuleConfigured, isRuleActive, getRuleSeverity, isRuleConfigValid, getRuleTitle, };
//# sourceMappingURL=index.d.ts.map