]> git.proxmox.com Git - pve-jslint.git/blob - rhino.js
add 'Proxmox' to globals
[pve-jslint.git] / rhino.js
1 (function (a) {
2 var e, i, input, filename, defaults;
3 if (!a[0]) {
4 print("Usage: jslint.js file.js ...");
5 quit(1);
6 }
7
8 defaults = {
9 predef: ['Ext', 'PVE', 'PMG', 'PVE_vnc_console_event', 'FormData', 'gettext', 'Proxmox'],
10 devel: true,
11 'continue': true, /// Allow continue statement
12 bitwise: true, // Allow bitwise operators
13 browser: true, // Assume a browser
14 css: true, // Tolerate CSS workarounds
15 eqeq: true, // Allow `==` && `!=`
16 //immed: true, // Immediate invocations must be wrapped in parens.
17 //nomen: true, // Allow dangling `_` in identifiers
18 newcap: false, // Require initial caps for constructors
19 vars: true, // Allow multiple `var` statements.
20 plusplus: true, // Allow `++` and `--`
21 regexp: true, // Allow `.` and `[^...]` in regex
22 sloppy: true, // Don't require `use strict;`
23 undef: false, // Disallow undeclared variables
24 white: true // Don't apply strict whitespace rules
25 };
26
27 for (i = 0; i < a.length; ++i) {
28 filename = a[i];
29 input = readFile( filename );
30 if (!input) {
31 print("jslint: Couldn't open file '" + filename + "'.");
32 quit(1);
33 }
34
35 if (!JSLINT(input, defaults)) {
36 for (i = 0; i < JSLINT.errors.length; i += 1) {
37 e = JSLINT.errors[i];
38 if (e) {
39 print('[' + filename + '] Lint at line ' + e.line + ' character ' +
40 e.character + ': ' + e.reason);
41 print((e.evidence || '').
42 replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
43 print('');
44 }
45 }
46 quit(2);
47 } else {
48 print("jslint: " + filename + " OK");
49 }
50 }
51 quit();
52 }(arguments));