UNPKG

conversation-design-system

Version:

> 💁‍♀️ This repository contains an Assistant to help designers adhere to the conventions in the > Conversation Design System. It defines the following rules...

52 lines (51 loc) 2.3 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.pageNaming = void 0; //Pages Required Rule exports.pageNaming = { rule: (context) => __awaiter(void 0, void 0, void 0, function* () { const { utils } = context; //TODO: need to improve this to use regex, so emoji are do not need to be gendered/color specific. function assertOption(value) { if (!Array.isArray(value)) { throw new Error('Option value is not an array'); } for (let i = 0; i < value.length; i++) { if (typeof value[i] !== 'string') { throw new Error('Option array element is not a string'); } } } // Get a configuration option named "required" const required = utils.getOption('required'); assertOption(required); for (const requirement of required) { var found = false; // Iterate for (const page of utils.objects.page) { const value = page.name; // Test if (value.includes(requirement)) { // Report found = true; } } //Report if (!found) { utils.report(`Page “${requirement}” not found.`); } } }), name: 'conversation-design-system/pages-required', title: 'Require page not found', description: 'Checks the following required pages are present: ⚛️ symbols, 💁‍♂️‍ component overview.', };