jshint 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0
4
+
5
+ * Fixes [#18](https://github.com/damian/jshint/pull/18) - Ensure the default Rake task runs the test suite
6
+ * Fixes [#17](https://github.com/damian/jshint/pull/17) - Fail the Rake task if there are linting errors
7
+ * Fixes [#7](https://github.com/damian/jshint/pull/7) - Ensure JSHint can be used standalone
8
+
3
9
  ## 1.2.0
4
10
 
5
11
  * Fixes [#14](https://github.com/damian/jshint/issues/14) - Upgraded to JSHint v2.5.11 from v2.1.4
data/README.md CHANGED
@@ -72,6 +72,15 @@ exclude_paths: ['vendor/assets/javascripts']
72
72
  ...
73
73
  ````
74
74
 
75
+ ## Rake integration
76
+ To use jshint in your default Rake config, just add it to the list of default tasks. For example, this configuration will run jshint in development or test environments.
77
+ ````ruby
78
+ # your-rails-project/Rakefile
79
+ if %w(development test).include? Rails.env
80
+ task default: :jshint
81
+ endif
82
+ ````
83
+
75
84
  ## Changelog
76
85
 
77
86
  You can view the [changelog here](https://github.com/damian/jshint/blob/master/CHANGELOG.md).
@@ -83,4 +92,3 @@ You can view the [changelog here](https://github.com/damian/jshint/blob/master/C
83
92
  3. Commit your changes (`git commit -am 'Add some feature'`)
84
93
  4. Push to the branch (`git push origin my-new-feature`)
85
94
  5. Create new Pull Request
86
-
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ task :default => [:spec]
5
+
6
+ desc "Run the specs."
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.pattern = "spec/**/*_spec.rb"
9
+ end
data/bin/jshint ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
4
+
5
+ require 'jshint'
6
+ require 'jshint/reporters'
7
+ require 'jshint/cli'
8
+
9
+ reporter_name = ARGV[0] || :Default
10
+ result_file = ARGV[1]
11
+
12
+ Jshint::Cli::run(reporter_name, result_file)
data/lib/jshint/cli.rb ADDED
@@ -0,0 +1,24 @@
1
+ module Jshint
2
+ module Cli
3
+ def self.run(reporter_name = :Default, result_file = nil)
4
+ linter = Jshint::Lint.new
5
+ linter.lint
6
+ reporter = Jshint::Reporters.const_get(reporter_name).new(linter.errors)
7
+
8
+ printer = lambda do |stream|
9
+ stream.puts reporter.report
10
+ end
11
+
12
+ if result_file
13
+ Dir.mkdir(File.dirname(result_file))
14
+ File.open(result_file, 'w') do |stream|
15
+ printer.call(stream)
16
+ end
17
+ else
18
+ printer.call($stdout)
19
+ end
20
+
21
+ linter
22
+ end
23
+ end
24
+ end
@@ -1,30 +1,16 @@
1
1
  require 'jshint'
2
2
  require 'jshint/reporters'
3
+ require 'jshint/cli'
3
4
 
4
5
  namespace :jshint do
5
6
  desc "Runs JSHint, the JavaScript lint tool over this project's JavaScript assets"
6
7
  task :lint => :environment do |_, args|
7
8
  # Our own argument parsing, since rake jshint will push extra nil's.
8
- reporter_name = :Default
9
- file = nil
10
9
  reporter_name = args.extras[0] if args.extras.length >= 1
11
- file = args.extras[1] if args.extras.length >= 2
10
+ result_file = args.extras[1] if args.extras.length >= 2
12
11
 
13
- linter = Jshint::Lint.new
14
- linter.lint
15
- reporter = Jshint::Reporters.const_get(reporter_name).new(linter.errors)
16
-
17
- printer = lambda do |stream|
18
- stream.puts reporter.report
19
- end
20
- if file
21
- Dir.mkdir(File.dirname(file))
22
- File.open(file, 'w') do |stream|
23
- printer.call(stream)
24
- end
25
- else
26
- printer.call($stdout)
27
- end
12
+ linter = Jshint::Cli::run(reporter_name, result_file)
13
+ fail if linter.errors.any? { |_, errors| errors.any? }
28
14
  end
29
15
 
30
16
  desc "Copies the default JSHint options to your Rails application"
@@ -1,4 +1,4 @@
1
1
  module Jshint
2
2
  # Our gem version
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.0"
4
4
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jshint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Damian Nicholson
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-12-26 00:00:00.000000000 Z
12
+ date: 2015-01-15 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: therubyracer
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,20 +30,23 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: execjs
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: 1.4.0
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: 1.4.0
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: multi_json
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: bundler
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -69,34 +78,39 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: railties
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - '>='
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: 3.2.0
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - '>='
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: 3.2.0
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: rake
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - '>='
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - '>='
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: rspec
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ~>
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ~>
109
124
  - !ruby/object:Gem::Version
@@ -111,22 +126,25 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: yard
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
- - - '>='
131
+ - - ! '>='
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
- - - '>='
139
+ - - ! '>='
123
140
  - !ruby/object:Gem::Version
124
141
  version: '0'
125
142
  description: It achieves this by linting your code through a library called JSHint
126
143
  which catches most code smells, and ensures code consistency
127
144
  email:
128
145
  - damian.nicholson21@gmail.com
129
- executables: []
146
+ executables:
147
+ - jshint
130
148
  extensions: []
131
149
  extra_rdoc_files: []
132
150
  files:
@@ -138,9 +156,11 @@ files:
138
156
  - LICENSE.txt
139
157
  - README.md
140
158
  - Rakefile
159
+ - bin/jshint
141
160
  - config/jshint.yml
142
161
  - jshint.gemspec
143
162
  - lib/jshint.rb
163
+ - lib/jshint/cli.rb
144
164
  - lib/jshint/configuration.rb
145
165
  - lib/jshint/lint.rb
146
166
  - lib/jshint/railtie.rb
@@ -159,26 +179,33 @@ files:
159
179
  homepage: http://damiannicholson.com
160
180
  licenses:
161
181
  - MIT
162
- metadata: {}
163
182
  post_install_message:
164
183
  rdoc_options: []
165
184
  require_paths:
166
185
  - lib
167
186
  required_ruby_version: !ruby/object:Gem::Requirement
187
+ none: false
168
188
  requirements:
169
- - - '>='
189
+ - - ! '>='
170
190
  - !ruby/object:Gem::Version
171
191
  version: '0'
192
+ segments:
193
+ - 0
194
+ hash: 326365264524046677
172
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
+ none: false
173
197
  requirements:
174
- - - '>='
198
+ - - ! '>='
175
199
  - !ruby/object:Gem::Version
176
200
  version: '0'
201
+ segments:
202
+ - 0
203
+ hash: 326365264524046677
177
204
  requirements: []
178
205
  rubyforge_project:
179
- rubygems_version: 2.0.2
206
+ rubygems_version: 1.8.23
180
207
  signing_key:
181
- specification_version: 4
208
+ specification_version: 3
182
209
  summary: Ensures your JavaScript code adheres to best practices
183
210
  test_files:
184
211
  - spec/fixtures/jshint.yml
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 3ffe5bc5846c375d3644a14502fee44889955764
4
- data.tar.gz: 97d1e006301fa44d243bf5fbc657863c17961d2a
5
- SHA512:
6
- metadata.gz: 1b7ad5faa8772865d1ede15c1f6dd919265c8fb6904940d31deacbc6c44411c08a704724e04c420cddbb60dc07c3b96507ab6695b3712faf9375e364ab6fc7f4
7
- data.tar.gz: e035f16e72e40eec0a6e983b9d70f94d78d328096dd04df993655f2f772b67b588e0673f8198e81b03941c386ef39094699232a5127af014e03270a71a78f98c