ng-table icon indicating copy to clipboard operation
ng-table copied to clipboard

jsHint error in ngTableParams; A constructor name should start with an uppercase letter

Open numediaweb opened this issue 12 years ago • 32 comments

If possible stick to coding best practices like the jsHint suggests.

numediaweb avatar Feb 12 '14 22:02 numediaweb

+1. Makes me have to start my grunt server with --force

guldner avatar Feb 14 '14 10:02 guldner

A quick fix is to include it in an ignor block like;

/* jshint ignore:start */
 $scope.tableParams = new ngTableParams({
        page: 1, // show first page
        count: 5 // count per page
    }, {
        counts: [], // hide page counts control
        total: 1 // value less than count hide pagination
    });

/* jshint ignore:end */

numediaweb avatar Feb 14 '14 11:02 numediaweb

we have this /* jshint ignore:start */ scattered throughout our js files that use nb-table. +1 for following JSHint best practice. much obliged!

robmcguinness avatar Mar 06 '14 12:03 robmcguinness

+1, also getting JSHint problems with the parameters being _ rather than camelcase.

line 19 col 0 Identifier 'total_items' is not in camel case.

intellix avatar Mar 06 '14 20:03 intellix

+1 Please.

jiggliemon avatar Apr 15 '14 21:04 jiggliemon

+1 @numediaweb: maybe you should use:

/* jshint -W055 */ // XXX: ngTableParams.
$scope.tableParams = new ngTableParams({
    page: 1, // show first page
    count: 5 // count per page
    ...
/* jshint +W055 */

http://jslinterrors.com/a-constructor-name-should-start-with-an-uppercase-letter

ghost avatar May 14 '14 20:05 ghost

Hi! any news on that issue? I would really like to get rid off those `/* jshint ignore:start */`` notations :/

andronat avatar May 15 '14 00:05 andronat

Why not just change the name of the variable when it's injected and jshint won't complain: ['ngTableParams', function(NgTableParams) {}]

gnarf avatar May 20 '14 21:05 gnarf

@gnarf nice suggestion! it works like charm, thanks!

andronat avatar May 20 '14 21:05 andronat

Also, a pretty simple patch to ngTableParams could make it work with or without new...

if (!(this instanceof ngTableParams)) return new ngTableParams(baseParameters, baseSettings);

gnarf avatar May 20 '14 21:05 gnarf

+1

noducks avatar Jul 02 '14 12:07 noducks

/*jshint newcap:false*/

at the top of the page gets rid of the errors too.

noducks avatar Jul 02 '14 12:07 noducks

I don't think that bypassed JsHint is a good solution. JsHint is a set of good manners and this should be respected for best code quality. NgTable is not an exception and it should be consider to rename variables to fit JsHint for maintainability and code clarity.

ctjhoa-linagora avatar Jul 17 '14 10:07 ctjhoa-linagora

+1, please make sure the codebase is JSHint compliant

Patrik-Lundqvist avatar Aug 01 '14 08:08 Patrik-Lundqvist

+1 @ctjhoa-linagora is correct.

faceleg avatar Aug 05 '14 07:08 faceleg

+1

sebastianhenneberg avatar Aug 13 '14 08:08 sebastianhenneberg

+1

RonB avatar Aug 14 '14 10:08 RonB

+1

balthazar avatar Aug 15 '14 13:08 balthazar

For me, the best way to get rid of this is to create a simple factory like :

.factory('NgTableParams', function (ngTableParams) {
    return ngTableParams;
})

This allow you to directly inject NgTableParams in your controllers without worrying about JSHint useless comments or change the name of the injected variable everywhere you have to inject it.

balthazar avatar Aug 15 '14 13:08 balthazar

I am out of the office until 29-08-2014.

Ik ben momenteel niet aanwezig.

Voor dringende zaken kunt u contact opnemen met het secretariaat, 053-574 16 86.

Met vriendelijke groet, Ronald Brinkerink

Note: This is an automated response to your message "Re: [ng-table] jsHint error in ngTableParams; A constructor name should start with an uppercase letter (#203)" sent on 15-8-2014 15:41:44.

This is the only notification you will receive while this person is away.

RonB avatar Aug 15 '14 14:08 RonB