jsx-eslint/eslint-plugin-react

How to prevent jsx-newline for elements and expressions on one line?

Open

#3,296 创建于 2022年5月23日

在 GitHub 查看
 (9 评论) (2 反应) (0 负责人)JavaScript (8,630 star) (2,797 fork)batch import
help wanted

描述

I have jsx-newline enabled, but how can I allow these cases where I want everything to stay on the same line? Without adding {/* eslint-disable[-line] react/jsx-newline */} around it?

<p>
  {t('text')} <span>{email}</span>
</p>

or

<div>
  {activeStep}/{steps}
</div>

It would be nice if there would be a setting that allowed for cases where everything is on the same line. So:

// BAD
<p>
  {t('text')} 
  <span>{email}</span>
</p>

// BOTH GOOD
<p>
  {t('text')} <span>{email}</span>
</p>

<p>
  {t('text')} 

  <span>{email}</span>
</p>

贡献者指南