close

self-closing-comp

Configuration

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:

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

Examples of correct code for this rule:

<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