require_atomic_updates

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 RequireAtomicUpdatesRule = rule.Rule{
	Name:             "require-atomic-updates",
	RequiresTypeInfo: true,
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		allowProperties := false
		optsMap := utils.GetOptionsMap(options)
		if optsMap != nil {
			if v, ok := optsMap["allowProperties"]; ok {
				if b, ok := v.(bool); ok {
					allowProperties = b
				}
			}
		}

		enterFunction := func(node *ast.Node) {
			flags := ast.GetFunctionFlags(node)
			if flags&(ast.FunctionFlagsAsync|ast.FunctionFlagsGenerator) == 0 {
				return
			}
			a := newAnalyzer(ctx, node, allowProperties)
			a.run()
		}

		return rule.RuleListeners{
			ast.KindFunctionDeclaration: enterFunction,
			ast.KindFunctionExpression:  enterFunction,
			ast.KindArrowFunction:       enterFunction,
			ast.KindMethodDeclaration:   enterFunction,
			ast.KindGetAccessor:         enterFunction,
			ast.KindSetAccessor:         enterFunction,
		}
	},
}

RequireAtomicUpdatesRule disallows assignments that can lead to race conditions due to usage of `await` or `yield`.

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