[pve-devel] [PATCH jslint] improve jslint
Dominik Csapak
d.csapak at proxmox.com
Thu Jan 4 12:59:04 CET 2018
include 'Proxmox' into global variables (from widget toolkit)
and check all files and show the errors together at the end
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
rhino.js | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/rhino.js b/rhino.js
index d1892dc..1996bda 100644
--- a/rhino.js
+++ b/rhino.js
@@ -1,12 +1,14 @@
(function (a) {
- var e, i, input, filename, defaults;
+ var e, i, j, input, filename, defaults;
+ var error = 0;
+ var errorstring = '';
if (!a[0]) {
print("Usage: jslint.js file.js ...");
quit(1);
}
defaults = {
- predef: ['Ext', 'PVE', 'PMG', 'PVE_vnc_console_event', 'FormData', 'gettext'],
+ predef: ['Ext', 'PVE', 'PMG', 'PVE_vnc_console_event', 'FormData', 'gettext', 'Proxmox'],
devel: true,
'continue': true, /// Allow continue statement
bitwise: true, // Allow bitwise operators
@@ -26,27 +28,36 @@
for (i = 0; i < a.length; ++i) {
filename = a[i];
+ input = undefined;
input = readFile( filename );
if (!input) {
print("jslint: Couldn't open file '" + filename + "'.");
- quit(1);
+ if (error < 1) {
+ error = 1;
+ continue;
+ }
}
if (!JSLINT(input, defaults)) {
- for (i = 0; i < JSLINT.errors.length; i += 1) {
- e = JSLINT.errors[i];
+ for (j = 0; j < JSLINT.errors.length; j += 1) {
+ e = JSLINT.errors[j];
if (e) {
- print('[' + filename + '] Lint at line ' + e.line + ' character ' +
+ errorstring += ('[' + filename + '] Lint at line ' + e.line + ' character ' +
e.character + ': ' + e.reason);
- print((e.evidence || '').
+ errorstring += "\n";
+ errorstring += ((e.evidence || '').
replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
- print('');
+ errorstring += "\n\n";
}
}
- quit(2);
+ if (error < 2) {
+ error = 2;
+ continue;
+ }
} else {
print("jslint: " + filename + " OK");
}
}
- quit();
+ print(errorstring);
+ quit(error);
}(arguments));
--
2.11.0
More information about the pve-devel
mailing list