Reputation: 464
For testing purposes, obviously not for production. What is the best way to do this?
Googling I found this tutorial, and of course the project on github.
For starters which files do I need to run:
// removed
and is there an API reference. I see there is a large comment block in jslint.js that seems to server this purpose but was wondering if there is something easier to read.
Because the client has no file access, I was planning on ajaxing the code in to get its contents.
Please never the mind, on why I want to do this on the client.
Upvotes: 1
Views: 943
Reputation: 22905
Have you looked at http://jshint.com/ ? Source is available here: https://github.com/jshint/jshint/
The browser bundle is available here: http://jshint.com/get/jshint-2.1.10.js and the docs describe how to call it (http://jshint.com/docs/)
Upvotes: 2
Reputation: 165971
If you include the JSLint script you will have access to a single global variable, JSLINT
. You can invoke it with a string and an optional map of options:
var valid = JSLINT(code, options);
The result will be true
or false
, depending on whether the code passed the check based on the provided options.
After this call you can inspect the JSLINT.errors
property for an array of warnings, if any.
This is precisely what I have done to build JSLint integration into the editor in the articles on http://jslinterrors.com.
Upvotes: 3