Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

jsx-newline: support for checking newline at the start and end of children#3678

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
burtek wants to merge1 commit intojsx-eslint:master
base:master
Choose a base branch
Loading
fromburtek:jsx-newline

Conversation

burtek
Copy link
Contributor

Fixes#3663

Comment on lines +49 to +52
checkStartEnd: {
default: false,
type: 'boolean',
},
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@ljharb this makes sense but I wonder if we shouldn't also include option for banning start/end newlines while forcing empty lines between children 🤔

So this might actually become an enum offorce |prevent rather than boolean. What do you think, what should I go with?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Or we might go with:

undefined andfalse = do nothing
true = behaves same as between children (as perprevent)
force = forces an empty line
prevent = prevents empty line

And it will still takeallowMultilines into account

@codecovCodecov
Copy link

codecovbot commentedJan 11, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base(3730edb) 97.65% compared to head(1b3be40) 97.74%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@##           master    #3678      +/-   ##==========================================+ Coverage   97.65%   97.74%   +0.08%==========================================  Files         132      132                Lines        9397     9405       +8       Branches     3445     3446       +1     ==========================================+ Hits         9177     9193      +16+ Misses        220      212       -8

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

@ljharb
Copy link
Member

prevent: true or false obv need to continue working.

I like the idea of effectively deprecating the boolean config, and instead allowing an enum of'ignore' (false),'siblings' (true),'adjacent' (lexically adjacent, ie everything) - that way if someone wants different options we can easily add them later, but for now we're only addingadjacent to cover the likely reading of the existing docs. Thoughts?

@burtek
Copy link
ContributorAuthor

Kinda feel like deprecating (while still supporting) old config, but making new config be:

{between:'force'|'force-one'|'prevent'|'ignore'// between childrenadjecent:'force'|'force-one'|'prevent'|'ignore'// before first child and after last child}

force - must be at least 1 empty line
force-one - must be exactly 1 empty line
prevent - must be 0 empty lines
ignore - ignore case

Obviously if both areignore then rule does nothing.

Those properties might probably be called something else (better?).

@ljharb
Copy link
Member

"between" seems weird for a parent/child relationship. Are you just trying to think of possible combinations, or do you have use cases?

A linter saying "adjacent" usually means lexically, not like "siblings" in terms of the AST graph.

@burtek
Copy link
ContributorAuthor

burtek commentedJan 12, 2024
edited
Loading

So I want to distinguish all four options I saw in different projects:

<parent><childA/><childB/></parent>
<parent><childA/><childB/></parent>
<parent><childA/><childB/></parent>
<parent><childA/><childB/></parent>

Easiest way would be allow configuring the rule for newlines between siblings separately from newlines before first and after last sibling.between andadjecent are names that came to my mind, but as non-native speaker I'm not sure what those names should actually be.

And the choice betweenforce,force-one,prevent andignore is just all the possible options that came to my mind, based on current config scheme

@ljharb
Copy link
Member

ljharb commentedJan 12, 2024
edited
Loading

OK, let's aim for those 4 options, with an eye for future extensibility.

That means two keys, one for siblings and one for directly inside of a parent, each of which a "must have a newline" value, and a "must not have a newline" value. I suppose we could also have "ignore", too.

What aboutbetweenSiblings andaroundChildren?

(allowMultilines would apply to all permutations)

@burtek
Copy link
ContributorAuthor

Sounds good

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Bug]:react/jsx-newline does not remove empty lines for surrounding tags
2 participants
@burtek@ljharb

[8]ページ先頭

©2009-2025 Movatter.jp