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

New option: jsx-one-expression-per-line non-jsx #3669

Closed
reediculous456 opened this issue Dec 21, 2023 · 13 comments · Fixed by #3677
Closed

New option: jsx-one-expression-per-line non-jsx #3669

reediculous456 opened this issue Dec 21, 2023 · 13 comments · Fixed by #3677

Comments

@reediculous456
Copy link

reediculous456 commented Dec 21, 2023

Examples of incorrect code for this rule:

<Hello
  foo="bar
>Children
</Hello>

Examples of correct code for this rule:

<Hello
  foo="bar
>
  Children
</Hello>
@ljharb ljharb closed this as completed Dec 21, 2023
@reediculous456
Copy link
Author

I don't believe this rule quite accomplishes my use case. For example, I want this to be correct:

<>Some text is: {variable} and goes here.</>

but with that rule it wants to make it:

<>
  Some text is:
  {` `}
  {variable}
  {` `}
  and goes here.
</>

I'm specifically looking to prevent the case of having multiline props but not multiline children

@ljharb
Copy link
Member

ljharb commented Dec 21, 2023

If you set allow to literal?

@reediculous456
Copy link
Author

reediculous456 commented Dec 21, 2023

Ends up with the same result. I think the rule interprets putting in a variable as a non-literal causing it to force it to multiline.

The single-child option seems closest to what I want, but I would want it to consider Some text is: {variable} and goes here. as a single child and allow that to stay on one line

@ljharb
Copy link
Member

ljharb commented Dec 21, 2023

ah, well sure, a variable isn't a literal.

hmm, that seems like a reasonable option to add - non-jsx, which would allow a single line child for anything that's not a literal jsx element?

@ljharb ljharb reopened this Dec 21, 2023
@reediculous456 reediculous456 changed the title New rule: jsx-children-newline New option: jsx-one-expression-per-line non-jsx Dec 21, 2023
@burtek
Copy link
Contributor

burtek commented Jan 10, 2024

@ljharb happy to tackle this in coming days

@ljharb
Copy link
Member

ljharb commented Jan 10, 2024

That'd be great, thanks!

@burtek
Copy link
Contributor

burtek commented Jan 11, 2024

@ljharb So just to be sure I understand it correctly. The allow: 'non-jsx' would disallow:

<Foo>
    <Bar /><Bar /><Bar />
</Foo>
<Foo>
    aaa<Bar />bbb
</Foo>

but allow:

<Foo>
    aaa {variable} bbb
</Foo>

Right?

@reediculous456
Copy link
Author

That’s what I’m looking for

@burtek
Copy link
Contributor

burtek commented Jan 11, 2024

ok, will work on this then. Hopefully will have PR ready this evening (Europe time)

@reediculous456
Copy link
Author

@ljharb whats the release timeline for this project? I see there haven’t been any releases since August and there are a couple of merged things I’m waiting on

@ljharb
Copy link
Member

ljharb commented Jan 12, 2024

@reediculous456 there's no strict timeline, but i'll likely cut a release sooner than later.

@burtek
Copy link
Contributor

burtek commented Jan 12, 2024

I hope to get #3678 in as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants