Basically requireCapitalizedConstructors works by requiring constructors after the new keyword to be capitalized, where as newcap works by requiring the new keyword before capitalized function calls.
Here is a test case to show the difference:
.jscsrc
{
"requireCapitalizedConstructors": true
}
.jshintrc
{
"newcap": true
}
test.js
function Test() {
return null;
}
function test() {
return null;
}
var testUpper = Test();
var testLower = new test();
jscs output:
$ jscs .
Constructor functions should be capitalized at ./test.js :
7 |
8 |var testUpper = Test();
9 |var testLower = new test();
----------------------------^
10 |
1 code style error found.
jshint output:
$ jshint .
test.js: line 8, col 17, Missing 'new' prefix when invoking a constructor.
1 error
Personally, I would like to have both in jscs. Is there an option I'm missing to enforce this, or could one be added?
Basically
requireCapitalizedConstructors
works by requiring constructors after thenew
keyword to be capitalized, where asnewcap
works by requiring thenew
keyword before capitalized function calls.Here is a test case to show the difference:
.jscsrc
.jshintrc
test.js
jscs output:
jshint output:
Personally, I would like to have both in jscs. Is there an option I'm missing to enforce this, or could one be added?