jsx_no_undef

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 JsxNoUndefRule = rule.Rule{
	Name: "react/jsx-no-undef",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		check := func(element *ast.Node) {
			tagName := reactutil.GetJsxTagName(element)
			if tagName == nil {
				return
			}

			if tagName.Kind == ast.KindIdentifier {
				text := tagName.AsIdentifier().Text
				if text != "" && text[0] >= 'a' && text[0] <= 'z' {
					return
				}
			}
			identNode := reactutil.GetJsxTagBaseIdentifier(tagName)
			if identNode == nil {

				return
			}
			name := identNode.AsIdentifier().Text

			if name == "this" {
				return
			}
			if utils.IsShadowed(identNode, name) {
				return
			}
			ctx.ReportNode(identNode, rule.RuleMessage{
				Id:          "undefined",
				Description: "'" + name + "' is not defined.",
			})
		}

		return rule.RuleListeners{

			ast.KindJsxOpeningElement:     check,
			ast.KindJsxSelfClosingElement: check,
		}
	},
}

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