jslintrb 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +15 -4
  2. data/lib/jslintrb/jslintrb.js +36 -13
  3. metadata +2 -2
data/README.rdoc CHANGED
@@ -8,10 +8,21 @@ Ruby gem to interpret the JSLint javascript.
8
8
 
9
9
  jslintrb <javascript files to be checked>
10
10
 
11
- You can provide a .jslinrbrc file in the directory from which the
12
- command is run to set jslint options. The file is JSON-formated. See
13
- the jslint documentation (http://jslint.com) for allowed options.
11
+ You can provide .jslinrbrc files in the directory from which the
12
+ command is run, the directory in which any file is found, and in any
13
+ parent of that directory, to set jslint options. They are processed
14
+ default first, then current directory, then ancestor directories, then
15
+ the immediate parent. For example, I have a .jslintrbrc file in my
16
+ top-level project directory that sets options for my project, then one
17
+ in my spec directory (like a test directory) which adds the globals
18
+ that exist for the tests but not for the core application code.
19
+
20
+ The file is JSON-formatted. See the
21
+ jslint documentation (http://www.jslint.com/lint.html) for allowed
22
+ options.
14
23
 
15
24
  == Copyright
16
25
 
17
- Copyright (c) 2010 Steven Parkes. See LICENSE for details.
26
+ jslintrb copyright (c) 2010 Steven Parkes. See LICENSE for details.
27
+ jslint copyright (c) 2002 Douglas Crockford. See lib/jslintrb/fulljslint.js for details.
28
+ json2 is in the public domain. See lib/jslintrb/json2.js for details.
@@ -8,7 +8,7 @@
8
8
 
9
9
  (function () {
10
10
 
11
- var options = {
11
+ var default_options = {
12
12
  bitwise : true, // if bitwise operators should not be allowed
13
13
  eqeqeq : true, // if === should be required
14
14
  forin : true, // if for in statements must filter
@@ -23,24 +23,47 @@
23
23
  white : true // if strict whitespace rules apply
24
24
  };
25
25
 
26
- var opts;
27
- try {
28
- opts = Ruby.IO.read(".jslintrbrc");
29
- } catch (ex) {}
30
-
31
- if (opts) {
32
- opts = JSON.parse(opts);
33
- for (var o in opts) {
34
- options[o] = opts[o];
35
- }
36
- }
37
-
38
26
  var errors = 0;
39
27
 
40
28
  var files = Ruby.send("eval", "ENV['JSLINT_FILES']");
41
29
  files = files.split(":");
42
30
  for (var i = 0; i < files.length; i++) {
43
31
  var file = files[i];
32
+
33
+ var batches = [];
34
+ batches.push( default_options );
35
+
36
+ var dirs = file.split("/");
37
+
38
+ var list = [ ".jslintrbrc" ];
39
+ var d;
40
+ for(var d=1; d < dirs.length; d++){
41
+ list.push(dirs.slice(0,d).join("/")+"/.jslintrbrc");
42
+ }
43
+
44
+ var rc;
45
+ for(d=0; d<list.length; d++){
46
+ var opts;
47
+ try {
48
+ opts = Ruby.IO.read(list[d]);
49
+ } catch (ex) {
50
+ opts = undefined;
51
+ }
52
+
53
+ if (opts) {
54
+ opts = JSON.parse(opts);
55
+ batches.push(opts);
56
+ }
57
+ }
58
+ var options = {};
59
+ var b;
60
+ for (b=0; b<batches.length; b++) {
61
+ var key;
62
+ for(key in batches[b]) {
63
+ options[key] = batches[b][key];
64
+ }
65
+ }
66
+
44
67
  var contents = Ruby.IO.read(file);
45
68
  var success = JSLINT(contents, options);
46
69
  if (success) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jslintrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Parkes
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-21 00:00:00 -08:00
12
+ date: 2010-01-22 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency