I have created one small chatting app using node.js and socket.io. It is working fine for me, but my editor's (Eclipse) plug-in JsHint showing me one error in my code as follows.
io.sockets.in(room).emit(msgtype, data);
Error:
Syntax error on token ".", Identifier expected after this token
above code is running very well for me, but editor showing me error. I don't understand what is the problem, I have google for same error, but still not getting any solution. If someone show me how to write code in node.js, that is very helpful to me.
thanks,
Are you sure the problem is coming from JSHint? I had the exact same issue in Eclipse, I also had installed the JSHint plugin so (wrongly) assumed JSHint was warning about this. I tried es5:true etc. and nothing worked. Then I realized that JSHint was not showing this error. When you look at "Problems" tab you may see something like "Javascript Problem" after the errors, in which case it is the JSDT validation (only available as es3) is running rather than JSHint, which is what nodeclipse will default to as far as I understand, if installed. I had big problems disabling it, trying to "suspend validation" in Window-Preferences and whatnot. Finally, I edited the .project file as well and removed all "jsdt" containing lines from there like i.e.
org.eclipse.wst.jsdt.core.jsNature
After starting eclipse again, the error was gone, and I activated JSHint by selecting the files it should process and voila, I got "JSHint Problem" in Problems tab and it correctly did not warn me about the valid use of sockets.in any longer.
Hope this helps anybody going through the same!
As noted above:
What version of JSHint are you using? Presumably the problem is that in is a reserved word and can only be used as a property identifier in that way in ES5. In recent versions of JSHint ES5 is assumed by default and that code should not issue a warning.