Skip to content

Tabs: Fix style issues #1494

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

Merged
merged 1 commit into from
Mar 18, 2015
Merged

Tabs: Fix style issues #1494

merged 1 commit into from
Mar 18, 2015

Conversation

jzaefferer
Copy link
Member

Powered by esformatter! Will do more of these with individual files.

.attr({
this.anchors = this.tabs.map( function() {
return $( "a", this )[ 0 ];
} )
Copy link
Member

Choose a reason for hiding this comment

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

I think we either need to clarify this in our style guide or change how this is formatted. The current rule is:

When a chain of method calls is too long to fit on one line, there must be one call per line, with the first call on a separate line from the object the methods are called on. If the method changes the context, an extra level of indentation must be used.

So, presumably this should be:

this.anchors = this.tabs
    .map( function() {
        return $( "a", this )[ 0 ];
    } )
        .attr( {
            ...
        } );

Copy link
Member

Choose a reason for hiding this comment

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

There are other instances of this below.

@jzaefferer
Copy link
Member Author

Updated with a second commit. Addresses several cases where line breaks were missing. If these changes are correct, I can look into update my esformatter-jquery-chain plugin to address those line breaks as well.

@scottgonzalez
Copy link
Member

I don't remember where we had the conversation, but I thought we decided that filtering as the first action was allowed on the first line.

/cc @mikesherov

@jzaefferer
Copy link
Member Author

That's pretty random - both find and filter change context.

Can I merge the first commit and open a new PR for the other?

@scottgonzalez
Copy link
Member

That's pretty random - both find and filter change context.

And .not() and .children() and lots of other methods. I thought this existing block was valid:

this.tabs.not( this.active ).attr( {
    "aria-selected": "false",
    "aria-expanded": "false",
    tabIndex: -1
} );

Or maybe:

this.tabs.not( this.active )
    .attr( {
        "aria-selected": "false",
        "aria-expanded": "false",
        tabIndex: -1
    } );

But I didn't expect it to be:

this.tabs
    .not( this.active )
        .attr( {
            "aria-selected": "false",
            "aria-expanded": "false",
            tabIndex: -1
        } );

Though I understand that's the rule as written.

@dmethvin
Copy link
Member

The first looks best to me as a reader and is still very clear. I'm not sure how the style guide should balance human readability vs absolute rules that can be enforced by a formatter, but it seems sad to lose the former in search of the latter.

@jzaefferer
Copy link
Member Author

My second commit was created by hand, no esformatter involved. Both esformatter and my esformatter-jquery-chain plugin tolerate line breaks as-is. The plugin only fixes indent.

@jzaefferer jzaefferer merged commit 92a9d8d into jquery:master Mar 18, 2015
@jzaefferer jzaefferer deleted the tabs-style-fixes branch March 18, 2015 13:53
@jzaefferer
Copy link
Member Author

I merged my first commit, created a new PR for the other, #1508

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

Successfully merging this pull request may close these issues.

4 participants