-
Notifications
You must be signed in to change notification settings - Fork 7.3k
command line switch to syntax check javascript #9426
Comments
This is a job best left to linters, isn't it? (http://jshint.com/) |
@jasnell linters are really meant to do static analysis of code, ie. is this variable used? did you do assignment when you meant conditional checking? etc. I simply just want to know if Because of this, it's possible that By using the |
I'm just going to throw this out there, not necessarily because I think it's a particularly good idea, just maybe a shorter option.
It is shorter, but you will still have issues escaping the characters and maybe others that I haven't thought about or that might depend on what you use it for. |
@CGavrila ^ isn't that effectively the same as |
Ah, indeed, it will execute the code as well. My bad, just ignore. :) |
If you inserted |
@OrangeDog there is like 99% of me that hates that... but the 1% of me absolutely loves its ingenuity. Would you grant that a command line switch to do this is slightly nicer than an eval + return? 😛 |
"Slightly" is an understatement. |
i've created #9447 with an implementation |
For future readers, this is now implemented with the -c flag. |
I am just going to repeat what @ianmaddox just because it's true: For future readers, this is all now implemented with the -c flag, as in:
|
It would be nice to be able to pass a flag to
node
that would tell it to just syntax check, and not execute, the given script.With ruby you can run
ruby -c file.rb
and bashbash -n file.sh
which both result in just a syntax check without any code execution. Both work in a similar fashion where proper syntax will result in no output with an exit code of 0, whereas improper syntax will generate debug information on stderr and an exit code of non-0.We (job) currently use the following as a pre-commit git hook to syntax check json, ruby, bash, and javascript. Even though
vm
is a stability level of 3, it still could change in the future which could break this functionality. Having a single command line switch to do effectively what is done incheck_js
would be extremely convenient and useful.The text was updated successfully, but these errors were encountered: