prefer-self-closing-tree Prefer self-closing tree elements without children Separate opening and closing tags imply that a tree element contains children even when its body is empty. Instead, you SHOULD write an element without children as one self-closing tag. - Category: style - Level: warning - Fix: automatic - Scope: module Reported import { TreeBuilder } from "destack:tree"; class Panel { id: int32 = 0; } extension of Panel implements TreeBuilder { type Tags = { hr: {} }; static element( tag: Tag, attributes: this.Tags[Tag], children: Children, ): Panel { return new Panel(); } static fragment(children: Children): Panel { return new Panel(); } } function render(): Panel { return
; } Accepted import { TreeBuilder } from "destack:tree"; class Panel { id: int32 = 0; } extension of Panel implements TreeBuilder { type Tags = { hr: {} }; static element( tag: Tag, attributes: this.Tags[Tag], children: Children, ): Panel { return new Panel(); } static fragment(children: Children): Panel { return new Panel(); } } function render(): Panel { return
; } Prior art - eslint-plugin-react ยท self-closing-comp language/linter/src/rules/style/preferselfclosingtree.rs:8