开发者

Is JSHint a Node.js syntax validator?

I have come across JSHint but was hoping it would validate node.js syntax but it doesn't, for example if I do:

var server = http.createServerfunctionThatDoesNotExists(function(request, response) {....

The test passes even though there isn't a function called createServerfunctionThatDoesNotExists

What am I missing with JSHint and 开发者_StackOverflowthe node.js option?


I think it doesn't dig into CommonJS modules as they can contain virtually everything.

So even if you are require'ing http it could be your own module with any interface.

'Assume Node' means it tolerates global variables like module or exports


JSHint is basically JSLint and is more for syntax/style/JS-nonos rather than a deep-scan product that executes your JS. Fully vetting JS code (or any dynamic language, really, depending on your definition of dynamic) pretty much requires running it, since things like methods can be defined more or less anywhere, including at runtime.

JSHint does go a bit further and allow the definition of high-level constructs used by some JS libraries.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜