I've got a ton of JS spaghetti that is in dire need of a good scrubbing. I've already configured sublimetext2 via package Control to use sublime-jslint
, and I've passed the necessary command-line switches to jslint4java-2.0.1
so it knows how to do its magic. Problem is, these files contain some third party code pasted in. I cannot move this code outside of the file, because it is time-critical and needs to be loaded before anything else.
I looked into the jslint4java
documentation and could not find a way to make it ignore a specific section of a script. I've searched through the site, and the only things about ignoring code regions that I could find were for jslint web version.
So, my question is: are there any ways to make it ignore a specific region of a javascript file? I'd rather not ignore the warnings if I can somehow sandbox that portion so jslint doesn't shout at me.
Thanks in advance.
JSLint uses control comments as it is parsing to control its behavior. One method would be to disable all of the relevant ones before the third-party script. After the last line of the script, you would have to enable them again. Unfortunately, there is no control comment to disable linting as a whole.
A second option would be to put it into a separate file, which you explicitly state you do not want to do. However, it is sometimes possible to know whether this script is loaded depending on your situation.
This may not apply to you, but it may apply to someone else reading this question.
Here is an example function that checks if the necessary function/var is loaded (won't work if the function or var is defined elsewhere). It checks 10 times over a period of 5 seconds
This is an example using plain JavaScript to handle AJAX Once this script is loaded with AJAX, use the second parameter to the function in the example to call your dependent code.
This is the best help I have to offer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With