no_hooks

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoHooksRule = rule.Rule{
	Name: "jest/no-hooks",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		opts := parseOptions(options)

		return rule.RuleListeners{
			ast.KindCallExpression: func(node *ast.Node) {
				jestFnCall := utils.ParseJestFnCall(node, ctx)
				if jestFnCall == nil || jestFnCall.Kind != utils.JestFnTypeHook {
					return
				}

				if !slices.Contains(opts.Allow, jestFnCall.Name) {
					ctx.ReportNode(node, buildErrorUnexpectedHookMessage(jestFnCall.Name))
				}
			},
		}
	},
}

Functions

This section is empty.

Types

type Options

type Options struct {
	Allow []string `json:"allow"`
}

Jump to

Keyboard shortcuts

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