prefer_rest_params

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: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PreferRestParamsRule = rule.Rule{
	Name: "prefer-rest-params",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		return rule.RuleListeners{
			ast.KindIdentifier: func(node *ast.Node) {
				if node.Text() != "arguments" {
					return
				}

				if ast.IsIdentifierName(node) {
					return
				}

				if isBindingOrDeclarationName(node) {
					return
				}

				enclosingFunc := ast.FindAncestor(node.Parent, func(n *ast.Node) bool {
					return ast.IsFunctionLikeDeclaration(n) && n.Kind != ast.KindArrowFunction
				})
				if enclosingFunc == nil {
					return
				}

				if isShadowedInFunction(enclosingFunc) {
					return
				}

				if isBlockScopeShadowed(node, enclosingFunc) {
					return
				}

				if isNonComputedMemberAccess(node) {
					return
				}

				ctx.ReportNode(node, rule.RuleMessage{
					Id:          "preferRestParams",
					Description: "Use the rest parameters instead of 'arguments'.",
				})
			},
		}
	},
}

https://eslint.org/docs/latest/rules/prefer-rest-params

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