Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoStaticOnlyClassRule = rule.Rule{ Name: "unicorn/no-static-only-class", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { check := func(node *ast.Node) { if ast.GetExtendsHeritageClauseElement(node) != nil { return } if ast.HasDecorators(node) { return } hasMember := false for _, m := range node.Members() { if m == nil || ast.IsSemicolonClassElement(m) { continue } hasMember = true if !isStaticMember(m) { return } } if !hasMember { return } msg := rule.RuleMessage{ Id: "noStaticOnlyClass", Description: "Use an object instead of a class with only static members.", } headRange := classHeadRange(node, ctx.SourceFile) fixes := buildFix(node, ctx.SourceFile) if len(fixes) == 0 { ctx.ReportRange(headRange, msg) return } ctx.ReportRangeWithFixes(headRange, msg, fixes...) } return rule.RuleListeners{ ast.KindClassDeclaration: check, ast.KindClassExpression: check, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.