no_await_in_loop

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoAwaitInLoopRule = rule.CreateRule(rule.Rule{
	Name: "no-await-in-loop",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		return rule.RuleListeners{
			ast.KindAwaitExpression: func(node *ast.Node) {
				if node == nil {
					return
				}

				if isInLoop(node) {
					ctx.ReportNode(node, buildUnexpectedAwaitMessage())
				}
			},

			ast.KindForOfStatement: func(node *ast.Node) {
				if node == nil {
					return
				}

				if !isForAwaitOfNode(node) {
					return
				}

				if isInLoop(node) {

					stmt := node.AsForInOrOfStatement()
					if stmt != nil && stmt.AwaitModifier != nil {
						ctx.ReportNode(stmt.AwaitModifier, buildUnexpectedAwaitMessage())
					}
				}
			},
		}
	},
})

NoAwaitInLoopRule disallows await inside of loops

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