Skip to content

Commit

Permalink
[[FIX]] Don't warn when Function() is used without 'new'. (#3531)
Browse files Browse the repository at this point in the history
https://262.ecma-international.org/#sec-function-constructor
...
the function call Function(…) is equivalent to the object creation
expression new Function(…) with the same arguments
...
  • Loading branch information
lauriro committed Feb 13, 2021
1 parent ee6aa68 commit c13c5cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/jshint.js
Expand Up @@ -3047,7 +3047,7 @@ var JSHINT = (function() {
if (left.type === "(identifier)") {
var newcapRe = /^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/;
var newcapIgnore = [
"Array", "Boolean", "Date", "Error", "Number",
"Array", "Boolean", "Date", "Error", "Function", "Number",
"Object", "RegExp", "String", "Symbol"
];
if (newcapRe.test(left.value) && newcapIgnore.indexOf(left.value) === -1) {
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/fixtures/newcap.js
Expand Up @@ -22,6 +22,9 @@ Array();
Boolean();
Date();
Error();
/*jshint -W061 */
Function();
/*jshint +W061 */
Number();
/*jshint -W010 */
Object();
Expand Down

0 comments on commit c13c5cc

Please sign in to comment.