Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@sketch-hq/sketch-core-assistant

sketch-hq43MIT6.5.0TypeScript support: included

This Assistant contains the official Sketch rule set.

sketch, sketch files, rules only, core rules, assistant, design ops

readme

sketch-assistant-core-rules

This Assistant contains the official Sketch rule set.

It's a "rules only" Assistant, meaning it contains only rule implementations and no configuration. Adding this Assistant to Sketch won't do anything because rules need to be activated in configuration before they will report anything.

Make use of this Assistant by extending from it in your own Assistants and adding configuration for the rules listed below.

Available rules

This Assistant exports the following rules. Click the links to view their documentation, configuration options and implementation.

Development

This section of the readme deals with development only. If you're just here to install Assistants in Sketch you can safely ignore this section.

Ensure you've followed the Getting Started section in the root README. Having done so the following scripts should work in this folder.

Script Description
yarn build Builds the Assistant to the dist folder
yarn i18n:extract Extracts strings from the JS source to PO files
yarn test Runs the Jest tests

Working on rules

Use a TDD approach, and the existing rules as a guide.

Rule functions can run in Node against plain Sketch file JSON, so the Mac Sketch app isn't required while actively developing rule logic.

When creating a new rule in this repository:

  1. Copy and paste one of the existing rule folders in src/ as a starting point.
  2. Add the new rule to the Assistant definition in src/index.ts.
  3. With Sketch, create some example .sketch files to use as test fixtures. At a minimum these should demonstrate two scenarios - one where you'd expect your rule to report violations, and one where it shouldn't report any
  4. While developing your rule and its tests use Jest in watch mode: yarn test --watch.
  5. If you've added new strings then follow the internationalization workflow too.
  6. Add changeset for your rule, open a Pull Request and once merged release it

Internationalization

This Assistant is internationalized since it's an official Sketch Assistant. We need any user facing strings to display in the correct language. Translating your own Assistants is completely optional however.

Internationalization is handled by LinguiJS, and follows their guides for handling plain JavaScript projects.

The following locales are currently supported in the Sketch Mac app and this project:

  • en (American English)
  • zh-Hans (Chinese Simplified)

When ready to perform a round of translation, for example when there are new untranslated strings in the repository, perform the following workflow:

  1. Run yarn i18n:extract which will update the .po files in src/locale/ with the new strings used throughout the source code.
  2. PR and merge these changes to main.
  3. Translation thereafter happens via CrowdIn automation.

changelog

@sketch-hq/sketch-core-assistant

6.5.0

Patch Changes

6.4.0

Minor Changes

  • dd91ad8: Updated dependencies
  • c857d5c: Updated dependencies

Patch Changes

6.4.0-rc.0

Minor Changes

  • dd91ad8: Updated dependencies
  • c857d5c: Updated dependencies

Patch Changes

6.3.2

Patch Changes

  • 217953f: No longer report violation of layer-styles-prefer-shared rule for images with default layer style

6.3.1

Patch Changes

6.2.0

Minor Changes

  • 9b55837: Added rule colors-prefer-variable to the Core Assistant.

Patch Changes

  • 01c1fd8: Do not count disabled background colors and styles in colors-prefer-variable rule.
  • 01c1fd8: Improve display of alpha values in color-prefer-variable rule.

6.1.0

Minor Changes

  • e9e06af: Reworked all three *-prefer-library rules to *-allowed-libraries rules.

Patch Changes

  • 0ea0381: Improve wording of groups-max-layers rule title.
  • e2264d2: Add Chinese localisation for recently added rule strings.

6.0.0

Major Changes

  • f8a0829: Support for reporting violations that reference multiple Sketch file objects.
  • 81a6e61: Add timeouts to rules.
  • 0b479bc: Refactored violation locations to objects and added a class value.

Patch Changes

  • 532eef0: Add manual ignore check in layers-no-loose rule.
  • 1c36951: Finalised translations.
  • Updated dependencies [f8a0829]
  • Updated dependencies [81a6e61]
  • Updated dependencies [f155f44]
  • Updated dependencies [0b479bc]

6.0.0-rc.1

Major Changes

  • 0b479bc: Refactored violation locations to objects and added a class value.

Patch Changes

6.0.0-rc.0

Major Changes

  • f8a0829: Support for reporting violations that reference multiple Sketch file objects.
  • 81a6e61: Add timeouts to rules.

Patch Changes

  • 532eef0: Add manual ignore check in layers-no-loose rule.
  • 1c36951: Finalised translations.
  • Updated dependencies [f8a0829]
  • Updated dependencies [81a6e61]
  • Updated dependencies [f155f44]

5.0.0

Major Changes

  • 6733a97: Numerous refactors around Sketch file object iteration.
  • e76fabd: Introduction of the Assistants CLI.

Minor Changes

  • 76c8ded: Add the symbols-no-detached rule.

Patch Changes

  • c4615bc: Update rule copy
  • 1698a52: Fix rule title copy in text-styles-prefer-shared.
  • 1c388d9: Add core rules to monorepo.
  • 7a54cbb: Count symbols set as override values as used in symbols-no-unused.
  • 04b71a6: Fix groups-no-empty flagging an empty document.
  • caba0e1: Do not raise violations from the exported-layers-normal-blend-mode rule when the layer is only to be exported as some kind of bitmap-based export format.
  • 0688585: Report loose layers, not the parent page in the the layers-no-loose rule.
  • 581554d: Fix a bug where violation objects weren't passed correctly.
  • Updated dependencies [8351103]
  • Updated dependencies [67f62f2]
  • Updated dependencies [c802b6b]
  • Updated dependencies [21de31c]
  • Updated dependencies [a004097]
  • Updated dependencies [e76fabd]
  • Updated dependencies [2f6f82b]
  • Updated dependencies [6733a97]
  • Updated dependencies [bc13811]

5.0.0-next.22

5.0.0-next.21

Patch Changes

5.0.0-next.20

5.0.0-next.19

Patch Changes

5.0.0-next.18

Patch Changes

5.0.0-next.17

Patch Changes

5.0.0-next.16

Minor Changes

  • 76c8ded: Add the symbols-no-detached rule.

Patch Changes

5.0.0-next.15

Major Changes

  • e76fabd: Introduction of the Assistants CLI.

Patch Changes

5.0.0-next.14

5.0.0-next.13

Patch Changes

  • 1698a52: Fix rule title copy in text-styles-prefer-shared.
  • 7a54cbb: Count symbols set as override values as used in symbols-no-unused.
  • caba0e1: Do not raise violations from the exported-layers-normal-blend-mode rule when the layer is only to be exported as some kind of bitmap-based export format.
  • 0688585: Report loose layers, not the parent page in the the layers-no-loose rule.

5.0.0-next.12

Patch Changes

  • 581554d: Fix a bug where violation objects weren't passed correctly.

5.0.0-next.11

Major Changes

  • 6733a97: Numerous refactors around Sketch file object iteration.

Patch Changes

5.0.0-next.10

Patch Changes

  • 1c388d9: Add core rules to monorepo.