@sketch-hq/sketch-assistant-types
Advanced tools
Comparing version 3.0.0-next.1 to 3.0.0-next.2
# @sketch-hq/sketch-assistant-types | ||
## 3.0.0-next.2 | ||
### Minor Changes | ||
- d696d99: Allow rule titles and descriptions to interpolate config values. | ||
## 3.0.0-next.1 | ||
@@ -4,0 +10,0 @@ |
@@ -113,14 +113,29 @@ import { FileFormat3 } from '@sketch-hq/sketch-file-format-ts'; | ||
/** | ||
* The result of running an assistant. One or more `violations` implies the assistant’s rules found | ||
* issues with the Sketch document. One or more `errors` implies that some rules didn’t run because | ||
* they encountered errors. Metadata (`title`, `description` etc) relating to the Assistant that | ||
* produced the result, and the rules that were invoked is also provided | ||
* The result of running an assistant. | ||
*/ | ||
export declare type RunResult = { | ||
export declare type AssistantResult = { | ||
/** | ||
* One or more `violations` implies the assistant’s rules found issues with the Sketch document. | ||
*/ | ||
violations: Violation[]; | ||
/** | ||
* One or more `errors` implies that some rules didn’t run because they encountered errors. | ||
*/ | ||
errors: PlainRuleError[]; | ||
/** | ||
* Metadata relating to the Assistant that produced the result, and the rules that were invoked. | ||
*/ | ||
metadata: { | ||
assistant: Omit<AssistantDefinition, 'rules'>; | ||
assistant: { | ||
config: AssistantConfig; | ||
name: string; | ||
}; | ||
rules: { | ||
[ruleName: string]: Omit<RuleDefinition, 'rule' | 'getOptions'>; | ||
[ruleName: string]: { | ||
name: string; | ||
title: string; | ||
description: string; | ||
debug: boolean; | ||
platform: Platform; | ||
}; | ||
}; | ||
@@ -130,4 +145,3 @@ }; | ||
/** | ||
* Contains all the values and utils exposed to individual rule functions. The | ||
* values are scoped to the rule itself, to simplify the API surface. | ||
* Contains all the values and utils exposed to individual rule functions. | ||
*/ | ||
@@ -152,3 +166,5 @@ export declare type RuleContext = { | ||
/** | ||
* Object contain utilities to be used within rule functions. | ||
* Object containing utilities passed into rule functions. Where needed the util functions are | ||
* scoped to the current rule, e.g. `report` reports a violation for the current rule and | ||
* `getOption` retrieves an option value for the current rule etc. | ||
*/ | ||
@@ -370,9 +386,11 @@ export declare type RuleUtils = { | ||
/** | ||
* Human readable title for the rule, e.g. "Groups Max Layers". | ||
* Human readable title for the rule. Can either be a string e.g. "Groups should not be empty", or | ||
* a function that returns a string, whicg enables the title to interpolate configuration values | ||
* e.g. "Maximum height is 44px". | ||
*/ | ||
title: string; | ||
title: string | ((ruleConfig: RuleConfig) => string); | ||
/** | ||
* Longer human readable description for the rule. | ||
*/ | ||
description: string; | ||
description: string | ((ruleConfig: RuleConfig) => string); | ||
/** | ||
@@ -379,0 +397,0 @@ * Rules that require options (i.e. are not just simply "on" or "off") need to describe the schema |
{ | ||
"name": "@sketch-hq/sketch-assistant-types", | ||
"version": "3.0.0-next.1", | ||
"version": "3.0.0-next.2", | ||
"main": "dist/types", | ||
@@ -5,0 +5,0 @@ "types": "dist/types", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
33791
585