Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Fixes for requirePaddingNewLinesBeforeLineComments (consecutive and in blocks) #1102

Closed

Conversation

elicwhite
Copy link
Contributor

requirePaddingNewLinesBeforeLineComments: Allowing multiple line comments together. Allowing no padding if first line in block.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 98.86% when pulling fa00241 on TheSavior:fix/newLinesBeforeComments into a0c2461 on jscs-dev:master.

return;
}

if (prevToken.type === 'Punctuator' && prevToken.value === '{') {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be optional. allExcept: 'firstInBlock.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this isn't really correct as it allows inside Objects, which aren't blocks, but I suppose it's fine for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking that since we haven't rolled this rule out yet, we aren't breaking backwards compatibility. I don't think I've met anyone who would expect this rule to force:

if (true) {

  // comment
}

While I could totally see it being optional in the future and adding more options, I think it is fine to leave it like this for the initial release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, your comment on the other PR implies that jQuery would expect the form I put on my last comment. Interesting...

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's why I mentioned it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do we decide on the default behavior here?

It seems like if this rule is used 99% of the time with allExcept: 'firstInBlock'then that should be the default. But it would be speculation on both of our sides to try to guess which would be the 'more common' case.

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 #698 and #136 (probably something else) where we can change the default value. And also #1064 could help us to know what default value should be for each rule. ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Default should be the version without exceptions. Principle of least surprise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hshoff: Can you weigh in here? Would Airbnb want an override that wouldn't require a blank line before a comment if it is the first in the block?

Aka, should this be an option at all or just always require a blank line?

Copy link

Choose a reason for hiding this comment

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

@TheSavior in Airbnb land:

// bad
if (true) {

  // comment
}

// good
if (true) {
  // comment
}

@mikesherov
Copy link
Contributor

@TheSavior, thanks again for contributing!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 98.87% when pulling 751436b on TheSavior:fix/newLinesBeforeComments into a0c2461 on jscs-dev:master.

@elicwhite
Copy link
Contributor Author

Alrighty. An additional configuration option has been added. Can you guys review my doc block? I copied it from another rule but I want to make sure that it will be parsed correctly and is in the correct style.

@elicwhite
Copy link
Contributor Author

59532802

}

if (allowFirstInBlock && prevToken.type === 'Punctuator' && prevToken.value === '{') {
console.log('skip');
Copy link
Member

Choose a reason for hiding this comment

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

don't need this now

…ents together. Allowing no padding if first line in block.

requirePaddingNewLinesBeforeLineComments: Adding an optional configuration for allExcept: firstInBlock
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 98.93% when pulling d6e8abc on TheSavior:fix/newLinesBeforeComments into c9265a1 on jscs-dev:master.

@elicwhite
Copy link
Contributor Author

Bump?

@mikesherov
Copy link
Contributor

@TheSavior no reason to bump. This will land before we release 1.12 regardless of when it actually makes it in

@elicwhite
Copy link
Contributor Author

Ah, gotcha. The flow of when things get merged in on JSCS is just a bit different than what I would expect. Still getting used to it. :)

I was figuring that I would update #1103 after this and #1101 were merged, perhaps I should update it now so it will be ready for you to merge them all at the same time.

@mikesherov mikesherov closed this in afc670d Mar 2, 2015
@mikesherov
Copy link
Contributor

Thanks again!

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

Successfully merging this pull request may close these issues.

6 participants