# self-closing-comp

Rule `react/self-closing-comp`. Disallow extra closing tags for components without children

- Source: react
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 6.7M weekly downloads of presets that enable it
- Trend: +26.2% last quarter
- Rank: #1155 by reach, #1362 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `react/self-closing-comp` | no | safe | package `eslint-plugin-react` | [docs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/self-closing-comp.md) |
| Oxlint | `react/self-closing-comp` | no | safe | plugin `react`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/react/self-closing-comp.html) |
| Biome | `style/useSelfClosingElements` | no | safe | group style, since 1.0.0 | [docs](https://biomejs.dev/linter/rules/use-self-closing-elements/) |

## Code examples

### Incorrect: the rule reports this

```jsx
var contentContainer = <div className="content"></div>;

var HelloJohn = <Hello name="John"></Hello>;

var HelloJohnCompound = <Hello.Compound name="John"></Hello.Compound>;
```

### Correct: the rule accepts this

```jsx
var contentContainer = <div className="content" />;

var intentionalSpace = <div>{' '}</div>;

var HelloJohn = <Hello name="John" />;

var HelloJohnCompound = <Hello.Compound name="John" />;

var Profile = <Hello name="John"><img src="picture.png" /></Hello>;

var ProfileCompound = <Hello.Compound name="John"><img src="picture.png" /></Hello.Compound>;

var HelloSpace = <Hello>{' '}</Hello>;
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import react from "eslint-plugin-react";

export default [
  {
    plugins: { react },
    rules: {
      "react/self-closing-comp": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "react"
  ],
  "rules": {
    "react/self-closing-comp": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "useSelfClosingElements": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [React Native](https://lintradar.dev/presets/react-native.md) | ESLint | `@react-native/eslint-config` | 79 | 1.2M | +5.8% |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [react/forbid-foreign-prop-types](https://lintradar.dev/rules/react/forbid-foreign-prop-types.md): Disallow using another component's propTypes
- [react/no-typos](https://lintradar.dev/rules/react/no-typos.md): Disallow common typos
- [react/style-prop-object](https://lintradar.dev/rules/react/style-prop-object.md): Enforce style prop value is an object
- [react/jsx-pascal-case](https://lintradar.dev/rules/react/jsx-pascal-case.md): Enforce PascalCase for user-defined JSX components
- [react/jsx-fragments](https://lintradar.dev/rules/react/jsx-fragments.md): Enforce shorthand or standard form for React fragments
- [react/jsx-no-bind](https://lintradar.dev/rules/react/jsx-no-bind.md): Disallow `.bind()` or arrow functions in JSX props

---

Web page: https://lintradar.dev/rules/react/self-closing-comp. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
