On Nov 26, 2:37 am, Mingfai <
mingfai...@gmail.com> wrote:
> is it good to follow jslint exactly? which options we should enable? (e.g.
> Assume a Yahoo Widget) And do you know any way to run it other than
> copy-and-paste to the box? i have no experience about it but i agree there
> should be a coding convention to follow.
I follow strictly the advices of the JSLint, but I am a strong fan of
JSLint.
I have been using good parts options:
bitwise: true,
eqeqeq: true,
nomen: true,
onevar: true,
passfail: false,
plusplus: true,
regexp: true,
undef: true,
white: true
With the following snippet
/*global ActiveXObject, WScript, */
/*members Arguments, Close, Count, OpenTextFile, Quit, ReadAll,
StdErr,
WriteLine, bitwise, eqeqeq, errors, length, line, nomen, onevar,
passfail, plusplus, reason, regexp, undef, white
*/
(function () {
if (WScript.Arguments.Count() !== 1) {
WScript.StdErr.WriteLine("Usage: cscript fulljslint.js
{file.js}");
WScript.Quit(1);
}
var filename = WScript.Arguments(0);
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
var objTextFile = objFSO.OpenTextFile(filename);
var sReadAll = objTextFile.ReadAll();
objTextFile.Close();
// Customize the options to change the behaviour of the validation
// See allOptions about the options available
var options = { // good part options
bitwise: true,
eqeqeq: true,
nomen: true,
onevar: true,
passfail: false,
plusplus: true,
regexp: true,
undef: true,
white: true
};
if (!JSLINT(sReadAll, options)) {
var e = JSLINT.errors;
for (var i = 0; i < e.length; i = i + 1) {
// Customize the output to integrate JSlint in your editor
// See JSLINT.errors about object members
if (e[i] !== null) {
WScript.StdErr.WriteLine(filename +
':' + (e[i].line + 1) + ': ' + e[i].reason);
}
}
//~ WScript.StdErr.WriteLine(JSLINT.report(false, '\r\n'));
WScript.Quit(1);
}
})();
I integrated JSLint with SciTE and Eclipse.
Regards,
Alberto