no_dupe_args

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoDupeArgsRule = rule.Rule{
	Name: "no-dupe-args",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {

		checkParams := func(node *ast.Node) {
			params := node.Parameters()
			if params == nil {
				return
			}

			seen := make(map[string]bool)
			for _, param := range params {
				paramDecl := param.AsParameterDeclaration()
				if paramDecl == nil {
					continue
				}
				nameNode := param.Name()
				if nameNode == nil {
					continue
				}
				utils.CollectBindingNames(nameNode, func(ident *ast.Node, name string) {
					if seen[name] {
						ctx.ReportNode(ident, rule.RuleMessage{
							Id:          "unexpected",
							Description: fmt.Sprintf("Duplicate param '%s'.", name),
						})
					} else {
						seen[name] = true
					}
				})
			}
		}

		return rule.RuleListeners{
			ast.KindFunctionDeclaration: checkParams,
			ast.KindFunctionExpression:  checkParams,
		}
	},
}

https://eslint.org/docs/latest/rules/no-dupe-args

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL