Do not use String as a constructor - inline option

1,057 views
Skip to first unread message

Kayo

unread,
Apr 27, 2014, 7:21:28 AM4/27/14
to jsh...@googlegroups.com
Hi

Is there any option to turn off the following jshint warning?

Do not use String as a constructor.

I have some library code, which needs to detect an object type - it could be a string or integer or array.  I would like the library to work with string literals such as "foo" as well as with a string created with new String("foo")

To test all execution paths of the library, unit tests use data which looks something like the following:

var testData = {
    name_1: "foo"
    name_2: new String("foo")
}

This is where jshint warns against the use of new String("foo")

Is there any inline option to turn off this warning?

Anton Kovalyov

unread,
Apr 28, 2014, 2:42:55 PM4/28/14
to jsh...@googlegroups.com
No, but you can use /*jshint -W053 */
 
Anton
--
You received this message because you are subscribed to the Google Groups "JSHint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jshint+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
 

Kayo

unread,
Apr 28, 2014, 9:43:56 PM4/28/14
to jsh...@googlegroups.com
Great! After seeing your answer, I tried searching for a list of all such warning codes and then found about using --verbose to print the appropriate warning code.

Thank You!
Reply all
Reply to author
Forward
0 new messages