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] jsx-first-prop-new-line: add multiprop option #3533

Merged
merged 1 commit into from
Mar 14, 2023
Merged

[New] jsx-first-prop-new-line: add multiprop option #3533

merged 1 commit into from
Mar 14, 2023

Conversation

haydncomley
Copy link
Contributor

@haydncomley haydncomley commented Feb 15, 2023

The jsx-first-prop-new-line rule is great but it just falls short in one place for me. This addition allows the rule to enforce a new line, but only if there are multiple props, else it forces it inline - a hybrid between multiline and multiline-multiprop.

Before Linting (currently the div element thinks that it is valid, but I want it to throw a linting error)

After Linting (the div is automatically formatted to put the prop on the first line, but the component below is kept multiline)

(I hope I've formatted this okay as I couldn't find a template for PRs)

@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Merging #3533 (45184ef) into master (3ab81d2) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3533   +/-   ##
=======================================
  Coverage   97.60%   97.60%           
=======================================
  Files         132      132           
  Lines        9282     9285    +3     
  Branches     3392     3395    +3     
=======================================
+ Hits         9060     9063    +3     
  Misses        222      222           
Impacted Files Coverage Δ
lib/rules/jsx-first-prop-new-line.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ljharb ljharb added enhancement semver-major Breaking change. labels Mar 6, 2023
@ljharb
Copy link
Member

ljharb commented Mar 6, 2023

So, just to clarify, this is multiline-multiprop but with an additional restriction that only multi prop elements may be multiline?

@ljharb ljharb removed the semver-major Breaking change. label Mar 6, 2023
@haydncomley
Copy link
Contributor Author

haydncomley commented Mar 7, 2023

So, just to clarify, this is multiline-multiprop but with an additional restriction that only multi prop elements may be multiline?

Yes indeed 🙂 - so it will force multiline for multiple props only, or force single line for up to 1 prop.

@ljharb ljharb changed the title [Improvement] jsx-first-prop-new-line - 'multiprop' option [New] jsx-first-prop-new-line: add multiprop option Mar 14, 2023
@ljharb ljharb merged commit 45184ef into jsx-eslint:master Mar 14, 2023
@sanketnaik99
Copy link

@ljharb Is there an ETA on when this will be released?

@mindnektar
Copy link

@ljharb just spent some time debugging why i couldn't use this even though it's in the docs. guess i found the answer. i'd love to use this option, so i've got the same question: when is the next release? :)

@mindnektar
Copy link

by the way: what if the prop itself is multiline? i would like to enforce something like this in such cases:

<div
    className={classnames(
        'foo',
        { 'foo--bar': props.bar }
    )}
>
    ...
</div>

right now, the multiprop option would cause this:

<div className={classnames(
    'foo,
    { 'foo--bar': props.bar }
)}
>

@ljharb
Copy link
Member

ljharb commented May 17, 2023

@mindnektar everywhere on github, you have to look at the docs on the tagged release and not on the default branch. For your other question, you'd combine it with the jsx-indent and indent rules.

@sanketnaik99 no, there is no ETA. hopefully soon.

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

Successfully merging this pull request may close these issues.

4 participants