Skip to content

Instantly share code, notes, and snippets.

@christianklotz
Created July 21, 2020 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianklotz/58d54270049732f7b4ae0f52aa016758 to your computer and use it in GitHub Desktop.
Save christianklotz/58d54270049732f7b4ae0f52aa016758 to your computer and use it in GitHub Desktop.
Create Sketch Assistant using existing rules
/**
Simple Assistant setting exactly one rule, limiting the number of layers that should be
allowed per group. The rule is provided by the Sketch Core Assistant.
1. Use Assistant Template from https://github.com/sketch-hq/sketch-assistant-template/
2. Find and replace all `sketch-assistant-template` with `sketch-organisation-assistant`
3. Install dependencies and add Core Assistant
npm install
npm install --save @sketch-hq/sketch-core-assistant
4. Replace src/index.ts with this gist's content
5. Create Assistant package
npm run package-tarball
6. Test resulting `.tgz` with your Sketch document via Assistants window › Manage Assistants… › Add from Archive…
*/
import { AssistantPackage } from '@sketch-hq/sketch-assistant-types'
import CoreAssistant from '@sketch-hq/sketch-core-assistant'
const assistant: AssistantPackage = [
CoreAssistant,
async () => {
return {
name: 'sketch-organisation-assistant',
rules: [],
config: {
rules: {
'@sketch-hq/sketch-core-assistant/groups-max-layers': {
active: true,
maxLayers: 3,
skipClasses: ['artboard'],
},
},
},
}
},
]
export default assistant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment