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

tools: update capital-comments eslint rule #27675

Closed
wants to merge 4 commits into from

Conversation

BridgeAR
Copy link
Member

Please have a look at the commit messages for details.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@BridgeAR BridgeAR requested a review from Trott May 13, 2019 13:10
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label May 13, 2019
@Fishrock123
Copy link
Contributor

These changes seem needless, and have caused us (NodeSource) plenty of unnecessary rebase grief (for our Node runtime, N|Solid).

Clearly, that's what we signed up for but it is certainly very annoying when the changes have little functional or even human documentation purpose aside from minor grammatical correctness.

This makes sure comments from 10 characters on are validated instead
of 20 characters as lower bound.
The regular expression was also updated to ignore variable
declarations which might happen while commenting out some code during
development.
@BridgeAR
Copy link
Member Author

BridgeAR commented May 13, 2019

@Fishrock123 I did indeed not think about third parties in this case. Do you cherry-pick individual commits or does it hurt backporting commits?

That aside: I changed the PR to only reduce the length check to 18 instead of 10 and now there are only 35 lines of code impacted. I can also keep it at 20 if you still think that might still cause trouble but I would definitely like to add the other changes (that relax the rule instead of making it stricter). That way some comments won't complain anymore (like commenting out code).

@addaleax
Copy link
Member

@BridgeAR Regardless of forks of Node’s codebase, and regardless of this specific PR, these types of changes generally just create a lot of work with almost nothing gained from them. I think it makes far more sense to keep doing these as drive-by changes when neighbouring lines are being modified.

And in terms of backporting, I’ve just had multiple unnecessary conflicts because of changed comment casing with backporting brotli to v10.x. I’d really prefer to just not do this.

@BridgeAR
Copy link
Member Author

@addaleax we currently work a bit on our backporting strategy in the release working group to make backporting easier (we try to backport as much as possible in the correct order and use compatibility patches for semver-major changes). That should ideally remove most conflicts, no matter of a change like this.

I updated the PR to only relax the rule (so it'll complain about less comments). That should be pretty uncontroversial?

@BridgeAR BridgeAR changed the title tools: more capital comments tools: update capital-comments eslint rule May 13, 2019
@@ -66,7 +66,8 @@ module.exports = {
line: {
// Ignore all lines that have less characters than 20 and all lines that
// start with something that looks like a variable name or code.
ignorePattern: '.{0,20}$|[a-z]+ ?[0-9A-Z_.(/=:[#-]|std',
// eslint-disable-next-line max-len
ignorePattern: '.{0,20}$|[a-z]+ ?[0-9A-Z_.(/=:[#-]|std|http|ssh|ftp|(let|var|const) [a-z_A-Z0-9]+ =|[b-z] |[a-z]*[0-9].* ',
Copy link
Member

Choose a reason for hiding this comment

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

This regexp is so long and complex, might it just be better to not have the rule at all?

From my perspective, the only reason to have a rule like this is so that people don't get nits about it in code reviews. If a tool can point it out, let's save everyone the work. But back-porting headaches and discussion about this rule and having to debug that regexp should it ever come to that...all of that time/energy may exceed the benefit of not having to leave/discuss those nits. Maybe we can better invest the time/energy to get consensus that we really don't actually care about capitalization, punctuation, and even spelling in code comments as long as the comments are clear first and foremost, and relatively professional and welcoming beyond that. (Honestly, I think @bnoordhuis was the only one who left nits about comment capitalization more than once or twice, and they didn't exactly do it very often and generally oppose churn anyway so might prefer to not land this too?)

Copy link
Member Author

Choose a reason for hiding this comment

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

I personally like the rule. It feels wrong to me to have lower cased comments but that might just be me. It's indeed not easy to find all exceptions but it worked relatively well (the code base is huge and we have a bunch of different comments while this expression seems to handle pretty much all cases that should not be updated well).

The only reason I wanted to update this again is that my linter would auto correct e.g. var to Var as soon as I comment out some code. While being on it I also added some further exceptions.

Copy link
Member

@Trott Trott May 13, 2019

Choose a reason for hiding this comment

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

(Just to be clear in case my comment above seems blocking: I don't oppose this change.)

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

I rather like this. The more consistent the code base, the easier it is to maintain, and the less you have to think about style issues (just do what the code around you does.)

@BridgeAR
Copy link
Member Author

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 14, 2019
Copy link
Member

@ZYSzys ZYSzys left a comment

Choose a reason for hiding this comment

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

The only reason I wanted to update this again is that my linter would auto correct e.g. var to Var as soon as I comment out some code. While being on it I also added some further exceptions.

LGTM on this point.

BridgeAR added a commit to BridgeAR/node that referenced this pull request May 16, 2019
The regular expression is updated to ignore variable declarations
which might happen while commenting out some code during development
and adds a couple more exceptions to prevent false negatives.

PR-URL: nodejs#27675
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
@BridgeAR
Copy link
Member Author

Landed in 5b26609 🎉

@BridgeAR BridgeAR closed this May 16, 2019
targos pushed a commit that referenced this pull request May 17, 2019
The regular expression is updated to ignore variable declarations
which might happen while commenting out some code during development
and adds a couple more exceptions to prevent false negatives.

PR-URL: #27675
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
@BridgeAR BridgeAR mentioned this pull request May 21, 2019
4 tasks
@BridgeAR BridgeAR deleted the more-capital-comments branch January 20, 2020 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants