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

Add a trailing comma #44

Open
vogella opened this issue Nov 26, 2019 · 1 comment
Open

Add a trailing comma #44

vogella opened this issue Nov 26, 2019 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@vogella
Copy link

vogella commented Nov 26, 2019

Thanks for your tools. Would be nice to always add a trailing comma, which is the standard in Dart.

Example:

{
    "tags": [
        "flutter"
    ],
    "owner": {
        "reputation": 354,
        "user_id": 6324029,
        "user_type": "registered",
        "profile_image": "https://www.gravatar.com/avatar/293ab6d0d3810adb641b0d37b800f774?s=128&d=identicon&r=PG&f=1",
        "display_name": "hoangquyy",
        "link": "https://stackoverflow.com/users/6324029/hoangquyy"
    },
    "is_answered": false,
    "view_count": 6,
    "answer_count": 1,
    "score": 0,
    "last_activity_date": 1574754851,
    "creation_date": 1574754058,
    "question_id": 59045950,
    "link": "https://stackoverflow.com/questions/59045950/can-we-download-video-and-play-it-with-flutter-without-add-it-into-asset",
    "title": "Can we download video and play it with flutter without add it into asset?"
}

Should write (basically adding a , after this.link

  Owner({
    this.reputation,
    this.userId,
    this.userType,
    this.profileImage,
    this.displayName,
    this.link,
  });

instead of:

Owner(
      {this.reputation,
      this.userId,
      this.userType,
      this.profileImage,
      this.displayName,
      this.link});
@javiercbk
Copy link
Owner

Thanks for your suggestion. The library relies on dart_style for all the formatting. I'm surprised that dart_style does not add the trailing comma.

The using dart_style is something mentioned in "Effective Dart". But the same page makes this explicit point:

Note that dartfmt does 99% of this for you, but the last 1% is you. It does not split long string literals to fit in 80 columns, so you have to do that manually.

So I think it is fair to say that this library should fix this, but I won't be able to easily fix this if the dart_style library erases the trailing comma.

I'll research this.

@javiercbk javiercbk added enhancement New feature or request good first issue Good for newcomers labels Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants