no_is_mounted

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoIsMountedRule = rule.Rule{
	Name: "react/no-is-mounted",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		return rule.RuleListeners{
			ast.KindCallExpression: func(node *ast.Node) {
				call := node.AsCallExpression()
				callee := ast.SkipParentheses(call.Expression)
				if callee.Kind != ast.KindPropertyAccessExpression {
					return
				}
				prop := callee.AsPropertyAccessExpression()
				if ast.SkipParentheses(prop.Expression).Kind != ast.KindThisKeyword {
					return
				}

				nameNode := prop.Name()
				if nameNode == nil {
					return
				}
				switch nameNode.Kind {
				case ast.KindIdentifier:
					if nameNode.AsIdentifier().Text != "isMounted" {
						return
					}
				case ast.KindPrivateIdentifier:
					if nameNode.AsPrivateIdentifier().Text != "#isMounted" {
						return
					}
				default:
					return
				}
				if ast.FindAncestor(node.Parent, isPropertyOrMethodDefinition) == nil {
					return
				}
				ctx.ReportNode(callee, rule.RuleMessage{
					Id:          "noIsMounted",
					Description: "Do not use isMounted",
				})
			},
		}
	},
}

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