no_alert

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 NoAlertRule = rule.Rule{
	Name: "no-alert",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		return rule.RuleListeners{
			ast.KindCallExpression: func(node *ast.Node) {
				callee := ast.SkipOuterExpressions(node.Expression(), outerExpressionKinds)
				if callee == nil {
					return
				}

				var name string

				switch callee.Kind {
				case ast.KindIdentifier:

					name = callee.Text()
					if !isProhibitedIdentifier(name) {
						return
					}
					if utils.IsShadowed(callee, name) {
						return
					}

				case ast.KindPropertyAccessExpression, ast.KindElementAccessExpression:
					// Member access: window.alert(), window['alert'](), globalThis.alert(), this.alert()
					var ok bool
					name, ok = utils.AccessExpressionStaticName(callee)
					if !ok || !isProhibitedIdentifier(name) {
						return
					}
					if !isGlobalThisOrWindow(utils.AccessExpressionObject(callee)) {
						return
					}

				default:
					return
				}

				ctx.ReportNode(node, rule.RuleMessage{
					Id:          "unexpected",
					Description: fmt.Sprintf("Unexpected %s.", name),
				})
			},
		}
	},
}

https://eslint.org/docs/latest/rules/no-alert

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