Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't warn when Object is used as a function.

Like Boolean, Number, and String, Object can be called as a function,
which provides scripts with access to ECMAScript's internal ToObject
logic. If passed an object, return it. If passed a primitive, return
a new Number, Boolean, or String as appropriate (or new Object for
null/undefined). This is useful primarily when implementing shims for
new ECMAScript functionality that is specified to use the ToObject
internal method.

Closes GH-392.
  • Loading branch information...
commit 4f1005d04448bc34c4b6ad775156b3859ef0c6ba 1 parent cdc0700
@valueof valueof authored
Showing with 4 additions and 5 deletions.
  1. +2 −5 jshint.js
  2. +2 −0  tests/unit/options.js
View
7 jshint.js
@@ -3291,14 +3291,11 @@ loop: for (;;) {
if (left) {
if (left.type === "(identifier)") {
if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
- if (left.value !== "Number" && left.value !== "String" &&
- left.value !== "Boolean" &&
- left.value !== "Date") {
+ if ("Number String Boolean Date Object".indexOf(left.value) === -1) {
if (left.value === "Math") {
warning("Math is not a function.", left);
} else if (option.newcap) {
- warning(
-"Missing 'new' prefix when invoking a constructor.", left);
+ warning("Missing 'new' prefix when invoking a constructor.", left);
}
}
}
View
2  tests/unit/options.js
@@ -807,6 +807,8 @@ exports.strict = function () {
TestRun()
.addError(6, "Missing 'new' prefix when invoking a constructor.")
.test(src3, {});
+
+ TestRun().test("var obj = Object({ foo: 'bar' });", { strict: true });
};
/** Option `globalstrict` allows you to use global "use strict"; */
Please sign in to comment.
Something went wrong with that request. Please try again.