Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The first JSX property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties (react/jsx-first-prop-new-line) #696

Closed
feross opened this issue Nov 22, 2016 · 4 comments

Comments

@feross
Copy link
Member

feross commented Nov 22, 2016

Ensure correct position of the first property.

multiline-multiprop: The first property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties.

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md

I've personally run into this while working on WebTorrent Desktop and Brave with @dcposch, where we've been very inconsistent with this.

@dcousens
Copy link
Member

dcousens commented Nov 23, 2016

IMO

OK:

// single-line
<Hello personal={true} />

// follows single-line, but with object spacing
<Hello foo={{
  x: 1,
  ...
}} />

// still single-line with object spacing
<Hello bar foo={{
  x: 1,
  ...
}} personal={true} />

// too many props on 1 line,  therefore, like an object definition, go multi-line
<Hello
    personal={true}
    foo="bar"
/>

Bad:

<Hello
    personal />

<Hello personal
    prop />

<Hello personal={true}
    foo="bar"
/>

(so multiline-multiprop?)

@feross
Copy link
Member Author

feross commented Nov 23, 2016

Yeah, that looks right @dcousens!

@feross
Copy link
Member Author

feross commented Nov 23, 2016

Just ran the test suite. No errors, except on webtorrent-desktop, and I agree that all the things it caught should be changed. So this LGTM

@feross feross added this to the standard v11 milestone Apr 4, 2017
@feross feross modified the milestones: standard v12, standard v13 Aug 28, 2018
@feross feross modified the milestones: standard v13, standard v14 Jul 5, 2019
@feross feross changed the title Configure the position of the first property (jsx-first-prop-new-line) The first JSX property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties (react/jsx-first-prop-new-line) Aug 14, 2019
@feross
Copy link
Member Author

feross commented Aug 14, 2019

This will ship in standard 14.

@feross feross closed this as completed in ee41ee9 Aug 14, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2021
suchitg8 pushed a commit to suchitg8/standard that referenced this issue Apr 9, 2022
…SX tag takes up multiple lines and there are multiple properties (react/jsx-first-prop-new-line)

Fixes: standard/standard#696
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

2 participants