no_nested_ternary

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 NoNestedTernaryRule = rule.Rule{
	Name: "no-nested-ternary",
	Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
		return rule.RuleListeners{
			ast.KindConditionalExpression: func(node *ast.Node) {
				cond := node.AsConditionalExpression()

				if ast.IsConditionalExpression(ast.SkipParentheses(cond.WhenTrue)) ||
					ast.IsConditionalExpression(ast.SkipParentheses(cond.WhenFalse)) {
					ctx.ReportNode(node, rule.RuleMessage{
						Id:          "noNestedTernary",
						Description: "Do not nest ternary expressions.",
					})
				}
			},
		}
	},
}

https://eslint.org/docs/latest/rules/no-nested-ternary

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