jshint 1.4.0 → 1.5.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +7 -1
- data/README.md +15 -4
- data/jshint.gemspec +4 -1
- data/lib/jshint/configuration.rb +16 -4
- data/lib/jshint/lint.rb +1 -30
- data/lib/jshint/version.rb +1 -1
- data/spec/lib/configuration_spec.rb +27 -9
- data/spec/lib/lint_spec.rb +1 -1
- metadata +50 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01efa9fdd22b78a92a186509d41e01f0fcad80fd
|
4
|
+
data.tar.gz: c2fb47f05d4fa59486e54c28fb3e790eb887b811
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9379e20591b3eb801cbdc11b18affc46de660f2c03b83b41117a1871b8d96281351fb0158932c0d089395c207c4fdcb27269deedd221a8f497ace3f6fc47d1bb
|
7
|
+
data.tar.gz: c18374536ae858bef9aebabb5144f9d3d4d2c5ee17ca76e1e9a54e542b9d5a17164cf3271136881f3ec5e60b511ba2f50ad9abfd86804e736441dc0354639e89
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -52,6 +52,7 @@ JSHint has some configuration options. You can read the default configuration cr
|
|
52
52
|
# your-rails-project/config/jshint.yml
|
53
53
|
files: ['**/*.js']
|
54
54
|
exclude_paths: []
|
55
|
+
exclude_files: []
|
55
56
|
options:
|
56
57
|
boss: true
|
57
58
|
browser: true
|
@@ -72,7 +73,7 @@ bundle exec rake jshint:lint['path/to/your/config.yml']
|
|
72
73
|
|
73
74
|
### Including folders to be Linted
|
74
75
|
|
75
|
-
To add folders outside of the standard Rails
|
76
|
+
To add folders outside of the standard Rails asset paths, you can define an array of `include_paths` within your configuration file.
|
76
77
|
|
77
78
|
````yaml
|
78
79
|
files: ['**/*.js']
|
@@ -82,11 +83,21 @@ include_paths: ['spec/javascripts']
|
|
82
83
|
|
83
84
|
### Excluding folders from being Linted
|
84
85
|
|
85
|
-
To exclude
|
86
|
+
To exclude a folder from being linted you can define an array of `exclude_paths` within your configuration file.
|
86
87
|
|
87
88
|
````yaml
|
88
89
|
files: ['**/*.js']
|
89
|
-
exclude_paths: ['vendor/assets/javascripts']
|
90
|
+
exclude_paths: ['vendor', 'app/assets/javascripts/tests/']
|
91
|
+
...
|
92
|
+
````
|
93
|
+
|
94
|
+
### Excluding files from being Linted
|
95
|
+
|
96
|
+
To exclude a file from being linted you can define an array of `exclude_files` within your configuration file.
|
97
|
+
|
98
|
+
````yaml
|
99
|
+
files: ['**/*.js']
|
100
|
+
exclude_files: ['**/*test.js']
|
90
101
|
...
|
91
102
|
````
|
92
103
|
|
@@ -96,7 +107,7 @@ To use jshint in your default Rake config, just add it to the list of default ta
|
|
96
107
|
# your-rails-project/Rakefile
|
97
108
|
if %w(development test).include? Rails.env
|
98
109
|
task default: :jshint
|
99
|
-
|
110
|
+
end
|
100
111
|
````
|
101
112
|
|
102
113
|
## Changelog
|
data/jshint.gemspec
CHANGED
@@ -23,8 +23,11 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency 'multi_json', '~> 1.0'
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
-
spec.add_development_dependency "railties", ">= 3.2.0"
|
26
|
+
spec.add_development_dependency "railties", ">= 3.2.0", "< 5.0.0"
|
27
27
|
spec.add_development_dependency "rake"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.1.0"
|
29
29
|
spec.add_development_dependency "yard"
|
30
|
+
spec.add_development_dependency "tins", "~> 1.6.0"
|
31
|
+
spec.add_development_dependency 'term-ansicolor', '~> 1.3.0'
|
32
|
+
spec.add_development_dependency 'json', "~> 1.8.3"
|
30
33
|
end
|
data/lib/jshint/configuration.rb
CHANGED
@@ -61,19 +61,23 @@ module Jshint
|
|
61
61
|
#
|
62
62
|
# @return [Array<String>] An Array of String files paths
|
63
63
|
def files
|
64
|
-
options
|
64
|
+
options.fetch("files", [])
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def exclude_files
|
68
|
+
options.fetch("exclude_files", [])
|
69
|
+
end
|
70
|
+
|
71
|
+
def exclude_paths
|
68
72
|
options.fetch("exclude_paths", [])
|
69
73
|
end
|
70
74
|
|
71
|
-
def
|
75
|
+
def include_paths
|
72
76
|
options.fetch("include_paths", [])
|
73
77
|
end
|
74
78
|
|
75
79
|
def search_paths
|
76
|
-
|
80
|
+
default_search_paths + include_paths
|
77
81
|
end
|
78
82
|
|
79
83
|
def default_search_paths
|
@@ -84,6 +88,10 @@ module Jshint
|
|
84
88
|
]
|
85
89
|
end
|
86
90
|
|
91
|
+
def javascript_files
|
92
|
+
get_files(search_paths, files) - get_files(exclude_paths, files) - get_files(search_paths, exclude_files)
|
93
|
+
end
|
94
|
+
|
87
95
|
private
|
88
96
|
|
89
97
|
def read_config_file
|
@@ -97,5 +105,9 @@ module Jshint
|
|
97
105
|
def default_config_path
|
98
106
|
File.join(defined?(Rails) ? Rails.root : Dir.pwd, 'config', 'jshint.yml')
|
99
107
|
end
|
108
|
+
|
109
|
+
def get_files paths, files
|
110
|
+
paths.map{ |path| files.map{ |file| Dir.glob(File.join(path, file)) }}.flatten
|
111
|
+
end
|
100
112
|
end
|
101
113
|
end
|
data/lib/jshint/lint.rb
CHANGED
@@ -25,7 +25,7 @@ module Jshint
|
|
25
25
|
#
|
26
26
|
# @return [void]
|
27
27
|
def lint
|
28
|
-
javascript_files.each do |file|
|
28
|
+
config.javascript_files.each do |file|
|
29
29
|
file_content = get_file_content_as_json(file)
|
30
30
|
code = %(
|
31
31
|
JSHINT(#{file_content}, #{jshint_options}, #{jshint_globals});
|
@@ -54,24 +54,6 @@ module Jshint
|
|
54
54
|
get_json(content)
|
55
55
|
end
|
56
56
|
|
57
|
-
def file_paths
|
58
|
-
paths = []
|
59
|
-
|
60
|
-
if files.is_a? Array
|
61
|
-
files.each do |file|
|
62
|
-
config.search_paths.each { |path| paths << File.join(path, file) }
|
63
|
-
end
|
64
|
-
else
|
65
|
-
config.search_paths.each { |path| paths << File.join(path, files) }
|
66
|
-
end
|
67
|
-
|
68
|
-
paths
|
69
|
-
end
|
70
|
-
|
71
|
-
def files
|
72
|
-
@files ||= config.files
|
73
|
-
end
|
74
|
-
|
75
57
|
def jshint_globals
|
76
58
|
@jshint_globals ||= get_json(config.global_variables)
|
77
59
|
end
|
@@ -91,16 +73,5 @@ module Jshint
|
|
91
73
|
def context
|
92
74
|
@context ||= ExecJS.compile("var window = {};\n" + jshint)
|
93
75
|
end
|
94
|
-
|
95
|
-
def javascript_files
|
96
|
-
js_asset_files = []
|
97
|
-
file_paths.each do |path|
|
98
|
-
Dir.glob(path) do |file|
|
99
|
-
js_asset_files << file
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
js_asset_files
|
104
|
-
end
|
105
76
|
end
|
106
77
|
end
|
data/lib/jshint/version.rb
CHANGED
@@ -38,14 +38,14 @@ describe Jshint::Configuration do
|
|
38
38
|
subject { described_class.new }
|
39
39
|
|
40
40
|
it "should default the exclusion paths to an empty array" do
|
41
|
-
expect(subject.
|
41
|
+
expect(subject.exclude_paths).to eq([])
|
42
42
|
end
|
43
43
|
|
44
44
|
describe "include search paths" do
|
45
45
|
it "should set the exclusion paths to those in the config" do
|
46
46
|
subject.options["include_paths"] ||= []
|
47
47
|
subject.options["include_paths"] << 'spec/javascripts'
|
48
|
-
expect(subject.
|
48
|
+
expect(subject.include_paths).to eq(["spec/javascripts"])
|
49
49
|
expect(subject.search_paths).to include("spec/javascripts")
|
50
50
|
end
|
51
51
|
end
|
@@ -53,15 +53,33 @@ describe Jshint::Configuration do
|
|
53
53
|
describe "exclude search paths" do
|
54
54
|
it "should set the exclusion paths to those in the config" do
|
55
55
|
subject.options["exclude_paths"] << 'vendor/assets/javascripts'
|
56
|
-
expect(subject.
|
56
|
+
expect(subject.exclude_paths).to eq(["vendor/assets/javascripts"])
|
57
57
|
end
|
58
|
+
end
|
59
|
+
end
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
context "javascript_files" do
|
62
|
+
it "knows what files to include by default" do
|
63
|
+
expect(subject.javascript_files).to eq(["vendor/assets/javascripts/jshint.js"])
|
64
|
+
end
|
65
|
+
it "knows what files to include when specifying include files and inlude paths" do
|
66
|
+
subject.options["include_paths"] = ["lib/jshint"]
|
67
|
+
subject.options["files"] = ["**/*.rake"]
|
68
|
+
expect(subject.javascript_files).to eq(["lib/jshint/tasks/jshint.rake"])
|
69
|
+
end
|
70
|
+
it "knows what files to exclude when specifying exclude files" do
|
71
|
+
subject.options["exclude_files"] = ["**/*jshi*"]
|
72
|
+
expect(subject.javascript_files).to eq([])
|
73
|
+
end
|
74
|
+
it "knows what files to exclude when specifying exclude paths" do
|
75
|
+
subject.options["exclude_paths"] = ["vendor"]
|
76
|
+
expect(subject.javascript_files).to eq([])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "get_files" do
|
81
|
+
it "gets all matching files in given search paths" do
|
82
|
+
expect(subject.send(:get_files, ["vendor"], ["**/*.js"])).to eq(["vendor/assets/javascripts/jshint.js"])
|
65
83
|
end
|
66
84
|
end
|
67
85
|
end
|
data/spec/lib/lint_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe Jshint::Lint do
|
|
29
29
|
|
30
30
|
describe "lint" do
|
31
31
|
before do
|
32
|
-
allow(
|
32
|
+
allow(configuration).to receive(:javascript_files).and_return(files)
|
33
33
|
allow(subject).to receive(:jshint_options).and_return(opts)
|
34
34
|
allow(subject).to receive(:jshint_globals).and_return(globals)
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jshint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Nicholson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: therubyracer
|
@@ -73,6 +73,9 @@ dependencies:
|
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 3.2.0
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 5.0.0
|
76
79
|
type: :development
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -80,6 +83,9 @@ dependencies:
|
|
80
83
|
- - ">="
|
81
84
|
- !ruby/object:Gem::Version
|
82
85
|
version: 3.2.0
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 5.0.0
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: rake
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +128,48 @@ dependencies:
|
|
122
128
|
- - ">="
|
123
129
|
- !ruby/object:Gem::Version
|
124
130
|
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: tins
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 1.6.0
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 1.6.0
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: term-ansicolor
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 1.3.0
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 1.3.0
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: json
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 1.8.3
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 1.8.3
|
125
173
|
description: It achieves this by linting your code through a library called JSHint
|
126
174
|
which catches most code smells, and ensures code consistency
|
127
175
|
email:
|