Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var MaxParamsRule = rule.Rule{ Name: "max-params", Run: func(ctx rule.RuleContext, _options []any) rule.RuleListeners { options := rule.LegacyUnwrapOptions(_options) opts := parseOptions(options) check := func(node *ast.Node) { params := node.Parameters() effective := len(params) if thisParam := ast.GetThisParameter(node); thisParam != nil { switch opts.countThis { case countThisNever: effective-- case countThisExceptVoid: if utils.IsThisVoidParameter(thisParam) { effective-- } } } if effective <= opts.max { return } name := utils.UpperCaseFirstASCII(utils.GetFunctionNameWithKindCore(node)) ctx.ReportRange( utils.GetFunctionHeadLoc(ctx.SourceFile, node), rule.RuleMessage{ Id: "exceed", Description: fmt.Sprintf( "%s has too many parameters (%d). Maximum allowed is %d.", name, effective, opts.max, ), }, ) } return rule.RuleListeners{ ast.KindFunctionDeclaration: check, ast.KindFunctionExpression: check, ast.KindArrowFunction: check, ast.KindMethodDeclaration: check, ast.KindConstructor: check, ast.KindGetAccessor: check, ast.KindSetAccessor: check, ast.KindFunctionType: check, } }, }
MaxParamsRule enforces a maximum number of parameters in function definitions. https://eslint.org/docs/latest/rules/max-params
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.