jshint functions with dots in the name-Collection of common programming errors

I’m running jshint on a javascript file, and some of the functions have dots in their names (as a way of namespacing). In particular, I’m using the d3 library, and I have a lot of code that looks like

d3.select("something")

Do I just need to turn off jshint’s checking of using undefined variables? Or is there a way to suppress just certain variable names from being checked. I’m using grunt to build the project.

  1. Wrong.

    You are calling the select method on the d3 variable.
    You’re getting a warning because JSHint doesn’t know about the d3 variable.

    You need to tell it that the d3 global has been defined elsewhere, like this:

    /*global d3:false */
    

    The :false will tell it to complain if you ever overwrite the global.

Originally posted 2013-11-09 21:08:38.