UNPKG

metal-soy-critic

Version:
26 lines (25 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("./util"); const chalk = require("chalk"); function validateParams(soyContext, jsContext) { /** * We just skip validation if the default class does not extend from Component. * TODO: See if we can resolve and parse the parent class' STATE. */ if (jsContext.getSuperClassImportPath() !== 'metal-component') { return util_1.toResult(true); } const jsParams = jsContext.getParamNames(); const classMethods = jsContext.getClassMethodNames(); const missingParams = soyContext.getRenderParams() .map(param => param.name) .filter(param => !jsParams.includes(param) && !classMethods.includes(param)); if (missingParams.length) { return util_1.toResult(false, `These params can't be found in ${chalk.yellow('STATE')} or your ${chalk.yellow('Class')}:\n\n` + util_1.joinErrors(missingParams)); } return util_1.toResult(true); } exports.default = validateParams; ;