jslint 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +12 -12
- data/VERSION +1 -1
- data/bin/jslint +30 -19
- data/jslint.gemspec +3 -2
- data/jslint/node.js +71 -0
- metadata +5 -4
data/README.md
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
|
1
|
+
# jslint
|
2
2
|
|
3
|
-
|
3
|
+
Simple gem to handle jslint.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
* Fork the project.
|
8
|
-
* Make your feature addition or bug fix.
|
9
|
-
* Add tests for it. This is important so I don't break it in a
|
10
|
-
future version unintentionally.
|
11
|
-
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
-
* Send me a pull request. Bonus points for topic branches.
|
5
|
+
In a rails project:
|
14
6
|
|
15
|
-
|
7
|
+
$ rails g jslint:update_config
|
8
|
+
$ vim config/jslint.yml
|
9
|
+
$ bundle exec jslint path/to/javascript/file.js
|
10
|
+
|
11
|
+
As a standalone script:
|
12
|
+
|
13
|
+
$ jslint --indent=2 --predef='[\"Ajax\"]' ... path/to/javascript/file.js
|
14
|
+
|
15
|
+
# Copyright
|
16
16
|
|
17
17
|
Copyright (c) 2010 Geraud. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/bin/jslint
CHANGED
@@ -1,33 +1,44 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
3
|
require 'json'
|
4
|
-
require 'jslint'
|
4
|
+
require File.expand_path('../../lib/jslint', __FILE__)
|
5
5
|
|
6
6
|
config_file = File.expand_path('config/jslint.yml')
|
7
|
-
|
7
|
+
if File.exist? config_file
|
8
|
+
config = YAML.load_file(config_file)['jslint']
|
8
9
|
|
9
|
-
options = config['options'] || {}
|
10
|
-
predefined = config['predefined']
|
11
|
-
options['predef'] = predefined.map { |defs| defs.split(',') }.flatten.map(&:strip) unless predefined.empty?
|
10
|
+
options = config['options'] || {}
|
11
|
+
predefined = config['predefined']
|
12
|
+
options['predef'] = predefined.map { |defs| defs.split(',') }.flatten.map(&:strip) unless predefined.empty?
|
12
13
|
|
13
|
-
options = config['options'].map do |option, value|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
options = config['options'].map do |option, value|
|
15
|
+
option = option.strip
|
16
|
+
case value
|
17
|
+
when true
|
18
|
+
"--#{option}"
|
19
|
+
when false
|
20
|
+
"--no-#{option}"
|
21
|
+
else
|
22
|
+
"--#{option}='#{value.to_json}'"
|
23
|
+
end
|
22
24
|
end
|
25
|
+
else
|
26
|
+
file_name = ARGV.pop
|
27
|
+
options = ARGV.dup
|
28
|
+
ARGV.clear
|
29
|
+
ARGV.push(file_name)
|
23
30
|
end
|
24
31
|
|
25
32
|
command = []
|
26
|
-
|
27
|
-
command << ['-
|
28
|
-
command << ['-f', Jslint::Scripts[:
|
29
|
-
command << Jslint::Scripts[:
|
33
|
+
if `which node`.empty?
|
34
|
+
command << ['java', '-jar', Jslint::RhinoJar]
|
35
|
+
command << ['-f', Jslint::Scripts[:fulljslint]]
|
36
|
+
command << ['-f', Jslint::Scripts[:json2]]
|
37
|
+
command << Jslint::Scripts[:rhino]
|
38
|
+
else
|
39
|
+
command << ['node']
|
40
|
+
command << Jslint::Scripts[:node]
|
41
|
+
end
|
30
42
|
command << [ options, ARGV.first]
|
31
43
|
command = command.flatten.join(' ')
|
32
|
-
# $stderr.puts command
|
33
44
|
exec command
|
data/jslint.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jslint}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Geraud Boyer"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-07}
|
13
13
|
s.default_executable = %q{jslint}
|
14
14
|
s.description = %q{longer description of your gem}
|
15
15
|
s.email = %q{geraud@gmail.com}
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"jslint/fulljslint.js",
|
32
32
|
"jslint/intercept.js",
|
33
33
|
"jslint/json2.js",
|
34
|
+
"jslint/node.js",
|
34
35
|
"jslint/rhino.js",
|
35
36
|
"jslint/widget.js",
|
36
37
|
"lib/generators/jslint/update_config/templates/jslint.yml",
|
data/jslint/node.js
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
/*
|
2
|
+
(c) 2010 Geraud Boyer
|
3
|
+
Adapted from rhino.js from Douglas Crockford (www.JSLint.com)
|
4
|
+
*/
|
5
|
+
// This is the node companion to fulljslint.js.
|
6
|
+
|
7
|
+
/*global JSLINT */
|
8
|
+
/*jslint rhino: false, strict: false */
|
9
|
+
/*global require,sys,__filename,process */
|
10
|
+
|
11
|
+
(function (args) {
|
12
|
+
var sys = require('sys'),
|
13
|
+
fs = require('fs'),
|
14
|
+
path = require('path'),
|
15
|
+
JSLINT = fs.readFileSync(path.join(path.dirname(__filename), 'fulljslint.js')).toString('UTF8'),
|
16
|
+
options = {
|
17
|
+
rhino: true, passfail: false, bitwise: true,
|
18
|
+
eqeqeq: true, immed: true, newcap: true,
|
19
|
+
nomen: true, onevar: true, plusplus: true,
|
20
|
+
regexp: true, undef: true, white: true
|
21
|
+
},
|
22
|
+
filename, input;
|
23
|
+
|
24
|
+
if (args.length === 0) {
|
25
|
+
sys.puts('Usage: jslint.js [options] file.js');
|
26
|
+
process.exit(1);
|
27
|
+
}
|
28
|
+
eval(JSLINT);
|
29
|
+
|
30
|
+
args.forEach(function (arg, index) {
|
31
|
+
sys.debug("Arg(" + index + "): " + arg);
|
32
|
+
if (arg.match(/^--no(\w+)$/)) {
|
33
|
+
sys.debug("a=false");
|
34
|
+
options[RegExp.$1] = false;
|
35
|
+
}
|
36
|
+
else if (arg.match(/^--(\w+)=(\S.*)$/)) {
|
37
|
+
sys.debug("a=b");
|
38
|
+
sys.debug("value: " + RegExp.$2);
|
39
|
+
options[RegExp.$1] = JSON.parse(RegExp.$2);
|
40
|
+
}
|
41
|
+
else if (arg.match(/^--(\w+)$/)) {
|
42
|
+
sys.debug("a=true");
|
43
|
+
options[RegExp.$1] = true;
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
filename = arg;
|
47
|
+
input = fs.readFileSync(filename);
|
48
|
+
if (!input) {
|
49
|
+
sys.puts("jslint: Couldn't open file '" + filename + "'.");
|
50
|
+
process.exit(1);
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
input = input.toString('UTF8');
|
54
|
+
}
|
55
|
+
}
|
56
|
+
});
|
57
|
+
if (!JSLINT(input, options)) {
|
58
|
+
JSLINT.errors.forEach(function (error) {
|
59
|
+
if (error) {
|
60
|
+
sys.puts('Lint at line ' + error.line + ' character ' + error.character + ': ' + error.reason);
|
61
|
+
sys.puts((error.evidence || '').replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
|
62
|
+
sys.puts('');
|
63
|
+
}
|
64
|
+
});
|
65
|
+
process.exit(2);
|
66
|
+
}
|
67
|
+
else {
|
68
|
+
sys.puts("jslint: No problems found in " + args[0]);
|
69
|
+
process.exit(0);
|
70
|
+
}
|
71
|
+
}(process.ARGV.slice(2)));
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jslint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Geraud Boyer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-07 00:00:00 -07:00
|
19
19
|
default_executable: jslint
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- jslint/fulljslint.js
|
71
71
|
- jslint/intercept.js
|
72
72
|
- jslint/json2.js
|
73
|
+
- jslint/node.js
|
73
74
|
- jslint/rhino.js
|
74
75
|
- jslint/widget.js
|
75
76
|
- lib/generators/jslint/update_config/templates/jslint.yml
|