Could newcap change to ignore leading underscores? #802

solmsted opened this Issue Jan 4, 2013 · 4 comments


None yet
5 participants

solmsted commented Jan 4, 2013

Enabling newcap throws a lint error when a constructor begins with an underscore, even when nomen is disabled. This code reproduces the error:

(function () {
    'use strict';
    /*jshint newcap:true,nomen:false */

    var _Class = function (args) {
        this.args = args;

    _Class.prototype = {
        clone: function () {
            var other = new _Class(this.args);
            return other;
    Line 11: var other = new _Class(this.args);

    A constructor name should start with an uppercase letter.

I would like to be able to check that constructors start with an uppercase letter but ignoring any dangling underscores.

I brought this up in issue #761. I don't mean to be a jerk by bringing it up again but I feel like I did a poor job explaining it and it was dismissed before I could clarify.

I'd like to see an option for this too. I use AngularJS and I often use underscore wrapped variables as shorthand for dependency injection in unit tests, so it generates a lot of false positives. It would be nice if there were a way to add non-alphabetical characters to be considered "capital".

amrsh commented Dec 30, 2014

+1 re angularjs injection


jugglinmike commented Dec 30, 2014

The newcap option is slated for removal in JSHint 3.0, so I don't expect much change in its current behavior.

@lukeapage lukeapage added this to the v3.0.0 milestone Jun 15, 2015


lukeapage commented Jun 15, 2015

Added to jshint 3 so this can be closed when that is released

@jugglinmike jugglinmike modified the milestone: v3.0.0 Jun 25, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment