質問

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 the 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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top