3

I am working with Eclipse and installed jshint for my application development with node.js, and now I am working on socket.io, where I have written following code.

io.sockets.in('room').emit('event_name', data);

here I am getting warrning from jshint as follows in Eclipse (Kepler).

Syntax error on token ".", Identifier expected after this token

How Do I solve this problem? Can someone tell me what the syntax error is here?

Manish Sapkal
  • 5,591
  • 8
  • 45
  • 74
  • 1
    Holy crap, [`io.sockets.in`](https://github.com/LearnBoost/socket.io/wiki/Rooms#emitting-to-a-room) is a real thing. It looks like a syntax error. I don't know why it's not a syntax error; apparently JSHint doesn't know either. I'm not sure you'll be able to silence this warning without somehow hiding this line from JSHint entirely; JSHint can't parse your file with this line in it. – user2357112 May 14 '14 at 09:23
  • 1
    [Apparently Javascript has separate Identifier and IdentifierName productions, and only Identifiers are required to not be reserved words.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Reserved_Words#Reserved_word_usage) It looks like JSHint isn't aware of this. – user2357112 May 14 '14 at 09:26
  • 1
    This is probably issue of the JSHint version... *IdentifierNames* are supported as defined in the specification (https://github.com/jshint/jshint/issues/309). – Pavel Horal May 14 '14 at 09:37
  • JSLint.com is happy with that line, if you put in a `var io, data;` declaration first. Looks like you've [asked this before](http://stackoverflow.com/questions/23337466/jshint-throwing-error-regarding-identifier-expected-after-token), btw, but added the JSLint tag. Kinda a blatant dupe. ;) Is JSLint an option? – ruffin May 14 '14 at 16:15
  • @ruffin, this is just an example, in my original code I have written/declared all needed variables as you mentioned. still I have got this error. I have asked this question 2nd time with Jshint tag, because I forgot that. Do you have any idea? – Manish Sapkal May 15 '14 at 03:00
  • I think since you're using JSHint (and using via a plugin on Eclipse), this isn't technically a JSLint question. That said, I'm suspicious if you gave the code in more context (ie, list more of the code), it'd be easier to find the problem. – ruffin May 15 '14 at 15:18

1 Answers1

0

According to the JSHint docs: http://www.jshint.com/docs/

ignoreThis(); // jshint ignore:line

That should work. There may also be some other configuration to ignore certain errors. Obviously you wouldn't want to ignore all syntax errors...

Jeff
  • 2,293
  • 4
  • 26
  • 43