UNPKG

metal-soy-critic

Version:
25 lines (24 loc) 973 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("./util"); const chalk = require("chalk"); const js_context_1 = require("./js-context"); function isInternalName(name) { return name.startsWith('_') || name.endsWith('_'); } function validateInternal(_, jsContext) { const params = jsContext.getParams(); const missingInternal = params .filter(node => { const name = js_context_1.default.getKeyName(node.key); return isInternalName(name) && !js_context_1.default.hasAttribute(node.value, 'internal'); }) .map(node => js_context_1.default.getKeyName(node.key)); if (!missingInternal.length) { return util_1.toResult(true); } return util_1.toResult(false, `Based on their name, these attributes should have the ${chalk.yellow('.internal()')} config added:\n\n` + util_1.joinErrors(missingInternal)); } exports.default = validateInternal;