esvit / ng-table

Simple table with sorting and filtering on AngularJS
http://esvit.github.io/ng-table
BSD 3-Clause "New" or "Revised" License
2.77k stars 851 forks source link

Style issue: factory name incorrectly capitalized #504

Open draytond opened 9 years ago

draytond commented 9 years ago

This line violates javascript naming conventions, causing it to break builds that depend on JSCS or JSHINT:

$scope.tableParams = new ngTableParams(parameters, settings);

So when we create a new object, causes our build to fail with a JSCS error, saying that constructor functions are supposed to be capitalized. This should be an easy one to fix, and will help loads of people use this with JSCS or JSHINT.

tb commented 9 years ago

or use "newcap": false ... its quire common on github

draytond commented 9 years ago

It is just a style convention, however our project style conventions do require caps on our constructors. Others might not have the same rule, but for teams like ours, giving it a capital letter would make it easier to use in our projects. Might improve adoption.

tb commented 9 years ago
  1. You can rename injected services https://docs.angularjs.org/guide/di
  2. You can create factory that inherits from ngTableParams, thats something what I do to add extra code like loading data, custom filters etc
angular.module('app')
  .factory('MyNgTableParams', ['ngTableParams', (ngTableParams) ->
    class MyNgTableParams extends ngTableParams
  ])
draytond commented 9 years ago

Indeed, that's a fine workaround. We found our own work around as well. I only make the recommendation to make adoption for teams like mine more seamless, so such workarounds are not necessary. It's not a bug per se, more just something I think will improve ease of integration, and bring it more in-line with widely held conventions.