> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# self-closing-comp

[Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, reactPlugin } from '@rslint/core';

export default defineConfig([
  reactPlugin.configs.recommended,
  {
    rules: {
      'react/self-closing-comp': 'error',
    },
  },
]);
```

## Rule Details

Enforce components without children to be self-closing. This applies to both custom components and HTML elements.

Examples of **incorrect** code for this rule:

```jsx
<Hello name="John"></Hello>
<div className="content"></div>
```

Examples of **correct** code for this rule:

```jsx
<Hello name="John" />
<div className="content" />
<div>Children</div>
```

## Options

- `component` (default: `true`): Whether to enforce self-closing for custom components.
- `html` (default: `true`): Whether to enforce self-closing for HTML elements.

## Original Documentation

- [eslint-plugin-react: self-closing-comp](https://github.com/jsx-eslint/eslint-plugin-react/blob/v7.37.5/docs/rules/self-closing-comp.md)
- [Source code](https://github.com/jsx-eslint/eslint-plugin-react/blob/v7.37.5/lib/rules/self-closing-comp.js)
