eslint-plugin-func-params-args
Version:
Limit the number of function parameters and arguments with ease and flexibility
1 lines • 909 B
JavaScript
;const{BASE_URL,isOptionConfigured}=require("../utils"),getFuncName=a=>{switch(a.callee.type){case"MemberExpression":return a.callee.property.name;case"Identifier":return a.callee.name}};module.exports={meta:{type:"problem",docs:{description:"enforce the number of arguments used in a function call",url:BASE_URL+"func-args.md"},schema:[{type:"object",properties:{global:{type:"integer",minimum:-1}},additionalProperties:{type:"integer",minimum:-1}}],messages:{exceed:"{{name}} has been called with too many arguments ({{count}}). Maximum allowed is ({{max}})."}},create(a){function b(b,c){a.report({node:b,messageId:"exceed",data:c})}function c(a,c,d){0<=d&&a.arguments.length>d&&b(a,{name:c,count:a.arguments.length,max:d})}const d=a.options[0]||{};return{CallExpression(a){const b=getFuncName(a);let e=-1;isOptionConfigured(d,b)?e=d[b]:isOptionConfigured(d,"global")&&(e=d.global),c(a,b,e)}}}};