JSLint 'Unexpected '(space)' error?

Regis Zaleman picture Regis Zaleman · Dec 22, 2012 · Viewed 11.7k times · Source

I am playing with Adobe's Edge Code which has its own JSLint checking option. I am getting this error (view title) which I am not able to fix...anyone knows what this is? The error comes for each of the following 3 lines of code:

plugin.pics[data.images[i].index] = data.images[i];
dataLoadedEvent = $.Event('DualG:dataLoaded', [ plugin.pics.length ]);
privateLoadPic(index, container);

Answer

peterflynn picture peterflynn · Jan 30, 2013

I'd bet the problem is trailing whitespace at the end of each line. If you click on the error in the JSLint panel, does the cursor go to the end of the line? If so, that's probably it; just hit Shift+End, Delete to clean it up.

I get zero JSLint errors if I just paste in your exact code from above and wrap it up as a simple JSLint test, like this:

/*jslint indent: 4 */
/*global plugin, data, $, i, dataLoadedEvent: true, privateLoadPic, index, container */
(function () {
    "use strict";

    plugin.pics[data.images[i].index] = data.images[i];
    dataLoadedEvent = $.Event('DualG:dataLoaded', [ plugin.pics.length ]);
    privateLoadPic(index, container);

}());