Skip to content

Latest commit

 

History

History
59 lines (40 loc) · 1.7 KB

jsx-space-before-closing.md

File metadata and controls

59 lines (40 loc) · 1.7 KB

Enforce spacing before closing bracket in JSX (react/jsx-space-before-closing)

❌ This rule is deprecated. It was replaced by react/jsx-tag-spacing.

🔧 This rule is automatically fixable by the --fix CLI option.

Please use the "beforeSelfClosing" option of the jsx-tag-spacing rule instead.

Enforce or forbid spaces before the closing bracket of self-closing JSX elements.

Rule Details

This rule checks if there is one or more spaces before the closing bracket of self-closing JSX elements.

Rule Options

This rule takes one argument. If it is "always" then it warns whenever a space is missing before the closing bracket. If "never" then it warns if a space is present before the closing bracket. The default value of this option is "always".

Examples of incorrect code for this rule, when configured with "always":

<Hello/>
<Hello firstname="John"/>

Examples of correct code for this rule, when configured with "always":

<Hello />
<Hello firstName="John" />
<Hello
  firstName="John"
  lastName="Smith"
/>

Examples of incorrect code for this rule, when configured with "never":

<Hello />
<Hello firstName="John" />

Examples of correct code for this rule, when configured with "never":

<Hello/>
<Hello firstname="John"/>
<Hello
  firstName="John"
  lastName="Smith"
/>

When Not To Use It

You can turn this rule off if you are not concerned with the consistency of spacing before closing brackets.