Page MenuHomePhabricator

Adjust phpcs/eslint to require Trailing Commas
Closed, ResolvedPublic

Description

Currently, CommunityConfiguration code style rules disallow trailing commas in JavaScript code, and there is no rule regarding trailing commas in effect for PHP code.

I propose that in both languages / linters we adjust the rules to require trailing commas in multi-line contexts (as long as they're allowed by the language, obviously).

The main case in favor of trailing commas is:

  • it is easier to add another element to a multi-line list, reorder lists, etc.
  • the git diffs are sometimes much cleaner if there is not an extra two lines for a comma being added to the previously last element

Event Timeline

Change #1068701 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/CommunityConfiguration@master] chore: require commas in javascript

https://gerrit.wikimedia.org/r/1068701

Change #1068702 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/CommunityConfiguration@master] chore: require trailing commas in all PHP files

https://gerrit.wikimedia.org/r/1068702

This gets more painful the longer we wait, so let's address it.

Change #1068701 merged by jenkins-bot:

[mediawiki/extensions/CommunityConfiguration@master] chore: require commas in javascript

https://gerrit.wikimedia.org/r/1068701

Change #1068787 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/CommunityConfiguration@master] chore: adjust phpcs to require trailing commas

https://gerrit.wikimedia.org/r/1068787

Change #1068702 merged by jenkins-bot:

[mediawiki/extensions/CommunityConfiguration@master] chore: add trailing commas in all PHP files

https://gerrit.wikimedia.org/r/1068702

Change #1068787 merged by jenkins-bot:

[mediawiki/extensions/CommunityConfiguration@master] chore: adjust phpcs to require trailing commas

https://gerrit.wikimedia.org/r/1068787

That's done now. Thanks!