0

I am wondering, why does code like this do not issue a warning with jsLint or jsHint

var obj={};
obj.missingFunction();

I understand that it may assume that the function will be eventually defined. But it complains for so many other things, that i thought it would be natural. I am doing some heavy refactoring, and moving functions out of the global scope to some properties of objects, and it would be great if there was a way to detect errors early in this case

vlast3k
  • 78
  • 5
  • JSHint/JSLint are static code analyzers so I don't think it is possible with those tools, try some IDE. – elclanrs Oct 12 '13 at 04:14
  • I am using Titanium which detects few other errors, but this isn't detected also there – vlast3k Oct 12 '13 at 04:15
  • Why do you think you need it? It doesn't even seem worth doing (or very hard to do right), JavaScript is very dynamic, you could have a line that prints a method before it exists. What should the linter do if you monkey patch that method later on? – elclanrs Oct 12 '13 at 04:21
  • 1
    Try VS or WebStorm IDEs, they may help you out, but they're not free. – elclanrs Oct 12 '13 at 04:24
  • I don't know... but then - does it mean that the only way to validate it is by executing it and testing it? (I am coming from Java, and therefore am a bit confused :) ) – vlast3k Oct 12 '13 at 04:27
  • "_does it mean that the only way to validate it is by executing it and testing it?_"? -- Yes, basically. Unit testing helps you automate these tasks but you debug your code interactively, setting breakpoints during execution, and tracking down the call stack trace, with Chrome devtools or Firebug or similar; that's the nature of a scripting language. Static analysis tools are limited. – elclanrs Oct 12 '13 at 04:31
  • Wow, i have installed WebStorm and it finds all those problems indeed :) Thanks! – vlast3k Oct 12 '13 at 04:47

1 Answers1

0

Thanks to the feedback from elclanrs, i have now installed WebStorm IDE and it does the job perfectly, which is fine for me

vlast3k
  • 78
  • 5