GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tools: always use a trailing comma in arrays by BridgeAR · Pull Request #20703 · nodejs/node

Conversation

@BridgeAR

@BridgeAR BridgeAR commented May 13, 2018

Copy link
Copy Markdown
Member

This makes sure all arrays in /lib end with a comma to prevent
future churn. Other options are set as before to minimize the
change.

Something like this just came up in a review and I guess it is indeed a good idea
to slowly migrate to a code base that has trailing commas.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig and tniessen reacted with thumbs down emoji
All reactions
  • 👎 2 reactions
@BridgeAR
tools: always use a trailing comma in arrays
2b65165
This makes sure all arrays in /lib end with a comma to prevent
future churn. Other options are set as before to minimize the
change.
@BridgeAR
BridgeAR requested a review from bnoordhuis May 13, 2018 17:06
@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs involving general changes in the lib/ or src/ directories. label May 13, 2018
@BridgeAR

BridgeAR commented May 13, 2018

Copy link
Copy Markdown
Member Author

Btw: I personally do not care how this is done but I think we should all agree on one way and enforce that so it does not come up in reviews.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented May 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

CI https://ci.nodejs.org/job/node-test-pull-request-lite/701/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vsemozhetbyt

vsemozhetbyt commented May 13, 2018

Copy link
Copy Markdown
Contributor

Refs: #19131, #19133, #5091,

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented May 13, 2018

Copy link
Copy Markdown
Member Author

@vsemozhetbyt thanks for pointing these out. @nodejs/collaborators I think we shouldd all agree on one way instead of having such comments in reviews. Therefore I suggest a simple vote and hope we can move forward into that direction afterwards:

🎉 No trailing comma at all
❤️ Always trailing comma

Be aware that moving to always trailing commas would mean that we have to slowly migrate quite a lot of code. The other way around means little code has to be changed.

Trott, tniessen, mcollina, cjihrig, hybrist, and benjamingr reacted with thumbs down emoji lpinca, tniessen, and cjihrig reacted with hooray emoji
All reactions
  • 👎 6 reactions
  • 🎉 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented May 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@BridgeAR I used 👎 for neither suggestion.

I know I once suggested enforcing the comma-dangle rule, but I backed down pretty quickly. The churn was big once you include the entire code base. And more importantly perhaps, I don't think comma comments come up that often. Did one come up recently or something?

If we really want the comma dangle rule, here's my suggestion:

  • Open a pull request in the ESLint repo to add a consistent option for comma-dangle such that the rule doesn't care if you always use trailing commas or never use trailing commas, but it does care if you do both of those things in a single file. In other words, be consistent within a file. (Other rules in ESLint have a consistent option that behaves like that.)

  • Once that lands and is released, implement that.

mcollina and benjamingr reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented May 13, 2018

Copy link
Copy Markdown
Member

Hmmm...it looks like they either no longer had (or never had?) consistent options for whole files, They tend to apply to whole objects, etc. Might be worth opening an issue or chatting in the ESLint gitter first to see if there would be any opposition to a applies-to-a-whole-file consistent option.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina requested changes May 13, 2018
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I am -1. We already had to work hard in backporting several PRs due to change of linting. We do not need more as a community.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tniessen
tniessen requested changes May 13, 2018
View reviewed changes

@tniessen tniessen left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Not a fan of dangling commas, ref #19131 (comment)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Trott

Trott commented May 13, 2018

Copy link
Copy Markdown
Member

Hmmm...it looks like they either no longer had (or never had?) consistent options for whole files, They tend to apply to whole objects, etc. Might be worth opening an issue or chatting in the ESLint gitter first to see if there would be any opposition to a applies-to-a-whole-file consistent option.

I asked in the eslint gitter and while a new option would of course need to be discussed, there was no immediate "no, we don't do consistent-within-a-file" so my original suggestion (implement 'consistent' in eslint and then use that in the nodejs code base) is a potentially viable way to go.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR mentioned this pull request May 14, 2018
Add consistent option to comma-dangle eslint/eslint#10350
Closed
@BridgeAR

BridgeAR commented May 14, 2018

Copy link
Copy Markdown
Member Author

I opened an issue in eslint.

I am going to close this now as it is clear that this is not something where we want to go to. Using trailing commas seems like something most people do not want in general as well, so please do not ask for such in reviews.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR closed this May 14, 2018
@bnoordhuis

bnoordhuis commented May 14, 2018

Copy link
Copy Markdown
Member

The one time I wouldn't object to churn and people vote it down...

Dangling commas reduce the size of the diff when lines are added. It makes code review a bit easier and is helpful with git blame.

I'm of the opinion that once eslint adds an option that lets us migrate on a file-by-file basis, we should.

targos and mmarchini reacted with thumbs up emoji Trott reacted with laugh emoji
All reactions
  • 👍 2 reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 14, 2018

Copy link
Copy Markdown
Member

I'm definitely 👍 on having a file-by-file rule.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR mentioned this pull request May 28, 2018
util: add computeTime option to inspect #19994
Closed
4 tasks done
@lpinca lpinca mentioned this pull request Jun 6, 2018
test,tools: refactor custom ESLint for readability #21134
Closed
2 tasks done
@tniessen tniessen mentioned this pull request Jun 6, 2018
Remove crypto.Credentials API #21153
Closed
3 tasks done
@BridgeAR
BridgeAR deleted the comma-dongle-start branch January 20, 2020 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina requested changes
@tniessen tniessen tniessen requested changes
@bnoordhuis bnoordhuis Awaiting requested review from bnoordhuis

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

lib / src Issues and PRs involving general changes in the lib/ or src/ directories.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@BridgeAR @vsemozhetbyt @Trott @bnoordhuis @mcollina @tniessen @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.