jshint 1.3.1 → 1.4.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef128351316e9344e5e64b1ab2de445e0460aa7a
4
+ data.tar.gz: c3afc2a26142ec10fd332fd4138774712b54e135
5
+ SHA512:
6
+ metadata.gz: fce5df5a5335091ce83ae353b9d70f9070071288ecb09f2e4ca882d99f6836fae27455a77d083164072cde81b47822eec4d461f7bbe81ddf85aa39f4c7644a9c
7
+ data.tar.gz: 00657ab0cf8e142147e8be016c215fa60af1879f8520dbf72bb25a26f4da600b2018f2b34f0fad0a141e849c924e9a9053fa5cff93de6e9275001159496d9a2c
data/README.md CHANGED
@@ -8,7 +8,7 @@ Making it easy to lint your JavaScript assets in any Rails 3.1+ application.
8
8
 
9
9
  ## Installation
10
10
 
11
- Add this line to your application's Gemfile:
11
+ Add this line to your Rails application's Gemfile:
12
12
 
13
13
  ```ruby
14
14
  group :development, :test do
@@ -36,7 +36,7 @@ To start using JSHint simply run the Rake task:
36
36
  bundle exec rake jshint
37
37
  ```
38
38
 
39
- This Rake task runs JSHint across all the JavaScript assets within the following three folders to ensure that they're lint free. Using that data it builds a report which is shown in STDOUT.
39
+ This Rake task runs JSHint across any JavaScript files contained within the following three folders in your Rails application to ensure that they're lint free. Using that data it builds a report which is shown in STDOUT.
40
40
 
41
41
  ```bash
42
42
  your-rails-project/app/assets/javascripts
@@ -46,7 +46,7 @@ your-rails-project/lib/assets/javascripts
46
46
 
47
47
  ## Configuration
48
48
 
49
- JSHint has some configuration options. You can read the default configuration created by JSHint in your applications config folder.
49
+ JSHint has some configuration options. You can read the default configuration created by JSHint in `config/jshint.yml` within your application.
50
50
 
51
51
  ```yaml
52
52
  # your-rails-project/config/jshint.yml
@@ -62,6 +62,24 @@ options:
62
62
  ```
63
63
  For more configuration options see the [JSHint documentation](http://jshint.com/docs/options/).
64
64
 
65
+ ### Custom configuration
66
+
67
+ You can specify an other path to your configuration file via:
68
+
69
+ ```ruby
70
+ bundle exec rake jshint:lint['path/to/your/config.yml']
71
+ ```
72
+
73
+ ### Including folders to be Linted
74
+
75
+ To add folders outside of the standard Rails asseet paths, you can define an array of `include_paths` within your configuration file.
76
+
77
+ ````yaml
78
+ files: ['**/*.js']
79
+ include_paths: ['spec/javascripts']
80
+ ...
81
+ ````
82
+
65
83
  ### Excluding folders from being Linted
66
84
 
67
85
  To exclude one of the above folders from being linted, you can define an array of `exclude_paths` within your configuration file.
@@ -1,7 +1,7 @@
1
1
  module Jshint
2
2
  module Cli
3
- def self.run(reporter_name = :Default, result_file = nil)
4
- linter = Jshint::Lint.new
3
+ def self.run(reporter_name = :Default, result_file = nil, config_path = nil)
4
+ linter = Jshint::Lint.new(config_path)
5
5
  linter.lint
6
6
  reporter = Jshint::Reporters.const_get(reporter_name).new(linter.errors)
7
7
 
@@ -68,8 +68,12 @@ module Jshint
68
68
  options.fetch("exclude_paths", [])
69
69
  end
70
70
 
71
+ def included_search_paths
72
+ options.fetch("include_paths", [])
73
+ end
74
+
71
75
  def search_paths
72
- default_search_paths - excluded_search_paths
76
+ (default_search_paths + included_search_paths) - excluded_search_paths
73
77
  end
74
78
 
75
79
  def default_search_paths
@@ -4,12 +4,13 @@ require 'jshint/cli'
4
4
 
5
5
  namespace :jshint do
6
6
  desc "Runs JSHint, the JavaScript lint tool over this project's JavaScript assets"
7
- task :lint => :environment do |_, args|
7
+ task :lint, [:config_path] => :environment do |_, args|
8
8
  # Our own argument parsing, since rake jshint will push extra nil's.
9
9
  reporter_name = args.extras[0] || :Default
10
10
  result_file = args.extras[1]
11
+ config_path = args[:config_path] || nil
11
12
 
12
- linter = Jshint::Cli::run(reporter_name, result_file)
13
+ linter = Jshint::Cli::run(reporter_name, result_file, config_path)
13
14
  fail if linter.errors.any? { |_, errors| errors.any? }
14
15
  end
15
16
 
@@ -1,4 +1,4 @@
1
1
  module Jshint
2
2
  # Our gem version
3
- VERSION = "1.3.1"
3
+ VERSION = "1.4.0"
4
4
  end
@@ -41,16 +41,27 @@ describe Jshint::Configuration do
41
41
  expect(subject.excluded_search_paths).to eq([])
42
42
  end
43
43
 
44
- it "should set the exclusion paths to those in the config" do
45
- subject.options["exclude_paths"] << 'vendor/assets/javascripts'
46
- expect(subject.excluded_search_paths).to eq(["vendor/assets/javascripts"])
44
+ describe "include search paths" do
45
+ it "should set the exclusion paths to those in the config" do
46
+ subject.options["include_paths"] ||= []
47
+ subject.options["include_paths"] << 'spec/javascripts'
48
+ expect(subject.included_search_paths).to eq(["spec/javascripts"])
49
+ expect(subject.search_paths).to include("spec/javascripts")
50
+ end
47
51
  end
48
52
 
49
- it "should be the default search paths minus the exclude paths" do
50
- expect(subject.search_paths).to eq(subject.default_search_paths)
51
- subject.options["exclude_paths"] << 'vendor/assets/javascripts'
52
- expect(subject.search_paths).
53
- to eq(['app/assets/javascripts', 'lib/assets/javascripts'])
53
+ describe "exclude search paths" do
54
+ it "should set the exclusion paths to those in the config" do
55
+ subject.options["exclude_paths"] << 'vendor/assets/javascripts'
56
+ expect(subject.excluded_search_paths).to eq(["vendor/assets/javascripts"])
57
+ end
58
+
59
+ it "should be the default search paths minus the exclude paths" do
60
+ expect(subject.search_paths).to eq(subject.default_search_paths)
61
+ subject.options["exclude_paths"] << 'vendor/assets/javascripts'
62
+ expect(subject.search_paths).
63
+ to eq(['app/assets/javascripts', 'lib/assets/javascripts'])
64
+ end
54
65
  end
55
66
  end
56
67
  end
metadata CHANGED
@@ -1,142 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jshint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
5
- prerelease:
4
+ version: 1.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Damian Nicholson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: therubyracer
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.12.1
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.12.1
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: execjs
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 1.4.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 1.4.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: multi_json
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: '1.0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: '1.0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: bundler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '1.3'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '1.3'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: railties
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: 3.2.0
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: 3.2.0
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rspec
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ~>
101
+ - - "~>"
116
102
  - !ruby/object:Gem::Version
117
103
  version: 3.1.0
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ~>
108
+ - - "~>"
124
109
  - !ruby/object:Gem::Version
125
110
  version: 3.1.0
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: yard
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  description: It achieves this by linting your code through a library called JSHint
@@ -148,9 +131,9 @@ executables:
148
131
  extensions: []
149
132
  extra_rdoc_files: []
150
133
  files:
151
- - .gitignore
152
- - .rspec
153
- - .travis.yml
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".travis.yml"
154
137
  - CHANGELOG.md
155
138
  - Gemfile
156
139
  - LICENSE.txt
@@ -179,33 +162,26 @@ files:
179
162
  homepage: http://damiannicholson.com
180
163
  licenses:
181
164
  - MIT
165
+ metadata: {}
182
166
  post_install_message:
183
167
  rdoc_options: []
184
168
  require_paths:
185
169
  - lib
186
170
  required_ruby_version: !ruby/object:Gem::Requirement
187
- none: false
188
171
  requirements:
189
- - - ! '>='
172
+ - - ">="
190
173
  - !ruby/object:Gem::Version
191
174
  version: '0'
192
- segments:
193
- - 0
194
- hash: 3701102366372032400
195
175
  required_rubygems_version: !ruby/object:Gem::Requirement
196
- none: false
197
176
  requirements:
198
- - - ! '>='
177
+ - - ">="
199
178
  - !ruby/object:Gem::Version
200
179
  version: '0'
201
- segments:
202
- - 0
203
- hash: 3701102366372032400
204
180
  requirements: []
205
181
  rubyforge_project:
206
- rubygems_version: 1.8.23
182
+ rubygems_version: 2.4.5
207
183
  signing_key:
208
- specification_version: 3
184
+ specification_version: 4
209
185
  summary: Ensures your JavaScript code adheres to best practices
210
186
  test_files:
211
187
  - spec/fixtures/jshint.yml