jscs-dev / node-jscs

:arrow_heading_up: JavaScript Code Style checker (unmaintained)
https://jscs-dev.github.io
MIT License
4.96k stars 513 forks source link

requireTrailingComma should be made optional when closing bracket/brace is on same line #2024

Closed fenduru closed 8 years ago

fenduru commented 8 years ago

Using angular's DI syntax, it is common to end up with code that looks like:

module.directive('foo', ['someDependency', function(someDependency) {
  // logic here
},]);

While requireTrailingComma is useful in most other scenarios, I don't think it makes sense when the comma is immediately followed by the corresponding bracket/brace. I feel that the benefit of requireTrailingComma is avoiding 2-line diffs when adding one item to an object/array, however in this case that benefit is not realized because you would already have to move the closing bracket/brace to the next line.

I think this case is very similar to the case handled by the ignoreSingleLine option.

Thanks :)

markelog commented 8 years ago

Feel free to implement allExcept option, like, for example, in http://jscs.info/rule/disallowSpacesInsideParenthesizedExpression

Also, check out - https://github.com/olov/ng-annotate

markelog commented 8 years ago

At this point only major and CST related bugs will be fixed.