@putout/engine-runner
Version:
23 lines (17 loc) • 572 B
JavaScript
;
const {declare: index} = require('@putout/operator-declare');
const {stringify} = JSON;
const isFn = (a) => typeof a === 'function';
module.exports.declare = ({rule, plugin, msg, options}) => {
validateDeclare(plugin.declare);
return {
rule,
plugin: index(plugin.declare()),
msg,
options,
};
};
function validateDeclare(declare) {
if (!isFn(declare))
throw Error(`☝️ Looks like 'declare' property value is not a 'function', but '${typeof declare}' with value '${stringify(declare)}'.`);
}