palantir / tslint-react

:orange_book: Lint rules related to React & JSX for TSLint.
Apache License 2.0
749 stars 76 forks source link

New rule suggestion: no-singleton-divs #148

Closed pelotom closed 5 years ago

pelotom commented 6 years ago

<div>s without attributes and containing only a single child are usually useless and can be eliminated.

cheeZery commented 6 years ago

Imho you sometimes use div containers for styling purposes, e.g. when working with flexbox.

<div style={{ display: "flexbox", justifyContent: "space-between", height: "200px" }}>
    <div>foo</div>
    <div>bar</div>
</div>

How would you prevent using <div> in this example and what are other common use cases of useless <div>s?

pelotom commented 6 years ago

@cheeZery this is certainly true, but IME pretty rare, and I’m happy to provide lint-disabling pragmas for the few cases where I need this.

adidahiya commented 5 years ago

Closing due to deprecation timeline, see #210