From c13c5cc2be9e5ac6ea1355b47d84e818d8ca135f Mon Sep 17 00:00:00 2001 From: Lauri Rooden Date: Sat, 13 Feb 2021 20:45:49 +0200 Subject: [PATCH] [[FIX]] Don't warn when Function() is used without 'new'. (#3531) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ... --- src/jshint.js | 2 +- tests/unit/fixtures/newcap.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jshint.js b/src/jshint.js index 9ff280a82b..c868ff8e05 100644 --- a/src/jshint.js +++ b/src/jshint.js @@ -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) { diff --git a/tests/unit/fixtures/newcap.js b/tests/unit/fixtures/newcap.js index 852ac068a8..85988ebcff 100644 --- a/tests/unit/fixtures/newcap.js +++ b/tests/unit/fixtures/newcap.js @@ -22,6 +22,9 @@ Array(); Boolean(); Date(); Error(); +/*jshint -W061 */ +Function(); +/*jshint +W061 */ Number(); /*jshint -W010 */ Object();