coffeelint 1.11.0 → 1.14.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.
- data/README.md +1 -1
- data/coffeelint/lib/coffeelint.js +278 -155
- data/lib/coffeelint.rb +29 -19
- data/lib/coffeelint/cmd.rb +4 -2
- data/lib/coffeelint/version.rb +1 -1
- data/spec/coffeelint_spec.rb +55 -0
- metadata +34 -22
- checksums.yaml +0 -7
data/lib/coffeelint.rb
CHANGED
@@ -43,37 +43,49 @@ module Coffeelint
|
|
43
43
|
ExecJS.compile(coffeescriptSource + bootstrap + coffeelintSource)
|
44
44
|
end
|
45
45
|
|
46
|
-
def self.lint(script, config = {})
|
46
|
+
def self.lint(script, config = {}, context = Coffeelint.context)
|
47
47
|
fname = config.fetch(:config_file, CoffeeLint::Config.locate)
|
48
48
|
config.merge!(CoffeeLint::Config.parse(fname)) unless fname.nil?
|
49
|
-
|
49
|
+
context.call('window.coffeelint.lint', script, config)
|
50
50
|
end
|
51
51
|
|
52
|
-
def self.lint_file(filename, config = {})
|
53
|
-
Coffeelint.lint(File.read(filename), config)
|
52
|
+
def self.lint_file(filename, config = {}, context = Coffeelint.context)
|
53
|
+
Coffeelint.lint(File.read(filename), config, context)
|
54
54
|
end
|
55
55
|
|
56
|
-
def self.lint_dir(directory, config = {})
|
56
|
+
def self.lint_dir(directory, config = {}, context = Coffeelint.context)
|
57
57
|
retval = {}
|
58
|
-
|
59
|
-
|
58
|
+
filtered_path = filter(directory)
|
59
|
+
|
60
|
+
Dir.glob(filtered_path) do |name|
|
61
|
+
retval[name] = Coffeelint.lint_file(name, config, context)
|
60
62
|
yield name, retval[name] if block_given?
|
61
63
|
end
|
62
64
|
retval
|
63
65
|
end
|
64
66
|
|
67
|
+
def self.filter(directory)
|
68
|
+
Dir.glob("#{directory}/**/*.coffee") - Dir.glob("#{directory}/**/{#{ignored_paths}}")
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.ignored_paths
|
72
|
+
if File.exist?(".coffeelintignore")
|
73
|
+
File.read(".coffeelintignore").lines.map(&:chomp).join(",")
|
74
|
+
else
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
65
79
|
def self.display_test_results(name, errors, pretty_output = true)
|
66
80
|
good = pretty_output ? "\u2713" : 'Passed'
|
67
81
|
warn = pretty_output ? "\u26A1" : 'Warn'
|
68
82
|
bad = pretty_output ? "\u2717" : 'Failed'
|
69
83
|
|
84
|
+
failure_count = 0
|
70
85
|
if errors.length == 0
|
71
86
|
puts " #{good} " + Coffeelint.green(name, pretty_output)
|
72
|
-
return true
|
73
87
|
else
|
74
|
-
no_failures = true
|
75
88
|
if errors.any? {|e| e["level"] == "error"}
|
76
|
-
no_failures = false
|
77
89
|
puts " #{bad} " + Coffeelint.red(name, pretty_output)
|
78
90
|
else
|
79
91
|
puts " #{warn} " + Coffeelint.yellow(name, pretty_output)
|
@@ -90,28 +102,26 @@ module Coffeelint
|
|
90
102
|
print warn + " "
|
91
103
|
print Coffeelint.yellow(disp, pretty_output)
|
92
104
|
else
|
105
|
+
failure_count += 1
|
93
106
|
print bad + " "
|
94
107
|
print Coffeelint.red(disp, pretty_output)
|
95
108
|
end
|
96
109
|
puts ": #{error["message"]}. #{error["context"]}."
|
97
110
|
end
|
98
|
-
return no_failures
|
99
111
|
end
|
112
|
+
return failure_count
|
100
113
|
end
|
101
114
|
|
102
115
|
def self.run_test(file, config = {})
|
103
116
|
pretty_output = config.has_key?(:pretty_output) ? config.delete(:pretty_output) : true
|
104
|
-
|
105
|
-
Coffeelint.display_test_results(file,
|
117
|
+
errors = Coffeelint.lint_file(file, config)
|
118
|
+
Coffeelint.display_test_results(file, errors, pretty_output)
|
106
119
|
end
|
107
120
|
|
108
121
|
def self.run_test_suite(directory, config = {})
|
109
122
|
pretty_output = config.has_key?(:pretty_output) ? config.delete(:pretty_output) : true
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
result = Coffeelint.display_test_results(name, errors, pretty_output)
|
114
|
-
end
|
115
|
-
errors_count
|
123
|
+
Coffeelint.lint_dir(directory, config).map do |name, errors|
|
124
|
+
Coffeelint.display_test_results(name, errors, pretty_output)
|
125
|
+
end.inject(0, :+)
|
116
126
|
end
|
117
127
|
end
|
data/lib/coffeelint/cmd.rb
CHANGED
@@ -79,13 +79,15 @@ module Coffeelint
|
|
79
79
|
options = parse_options
|
80
80
|
|
81
81
|
if ARGV.length > 0
|
82
|
+
errors_count = 0
|
82
83
|
ARGV.each do |file|
|
83
84
|
if options[:options][:recursive]
|
84
|
-
Coffeelint.run_test_suite(file, options[:linter_options])
|
85
|
+
errors_count += Coffeelint.run_test_suite(file, options[:linter_options])
|
85
86
|
else
|
86
|
-
Coffeelint.run_test(file, options[:linter_options])
|
87
|
+
errors_count += Coffeelint.run_test(file, options[:linter_options])
|
87
88
|
end
|
88
89
|
end
|
90
|
+
exit errors_count
|
89
91
|
end
|
90
92
|
end
|
91
93
|
end
|
data/lib/coffeelint/version.rb
CHANGED
data/spec/coffeelint_spec.rb
CHANGED
@@ -40,4 +40,59 @@ describe Coffeelint do
|
|
40
40
|
expect(results.length).to eq 1
|
41
41
|
expect(results[0]['name']).to eq 'cyclomatic_complexity'
|
42
42
|
end
|
43
|
+
|
44
|
+
describe 'linting files' do
|
45
|
+
before do
|
46
|
+
FileUtils.mkdir_p('/tmp/coffeelint')
|
47
|
+
File.open('/tmp/coffeelint/file1.coffee', 'w') { |f| f.write("a;\na;") }
|
48
|
+
File.open('/tmp/coffeelint/file2.coffee', 'w') { |f| f.write("a;") }
|
49
|
+
end
|
50
|
+
|
51
|
+
after(:all) { FileUtils.rm_r('/tmp/coffeelint') }
|
52
|
+
|
53
|
+
it "should return error count from run_test" do
|
54
|
+
expect(Coffeelint.run_test('/tmp/coffeelint/file1.coffee')).to eq 2
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return error count from run_test_suite" do
|
58
|
+
expect(Coffeelint.run_test_suite("/tmp/coffeelint")).to eq 3
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'files to lint' do
|
63
|
+
before(:all) do
|
64
|
+
FileUtils.mkdir_p('/tmp/coffeelint/subdirectory')
|
65
|
+
FileUtils.touch('/tmp/coffeelint/file1.coffee')
|
66
|
+
FileUtils.touch('/tmp/coffeelint/file2.coffee')
|
67
|
+
FileUtils.touch('/tmp/coffeelint/subdirectory/file3.coffee')
|
68
|
+
end
|
69
|
+
|
70
|
+
after(:all) { FileUtils.rm_r('/tmp/coffeelint') }
|
71
|
+
|
72
|
+
before { allow(Coffeelint).to receive(:lint_file) }
|
73
|
+
|
74
|
+
it 'lints all .coffee files in the directory, searching recursively' do
|
75
|
+
results = Coffeelint.lint_dir('/tmp/coffeelint')
|
76
|
+
expect(results).to include(
|
77
|
+
'/tmp/coffeelint/file1.coffee',
|
78
|
+
'/tmp/coffeelint/file2.coffee',
|
79
|
+
'/tmp/coffeelint/subdirectory/file3.coffee'
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'with a .coffeelintignore file' do
|
84
|
+
before { File.open('.coffeelintignore', 'w') { |f| f.write("file1.coffee\n*file3.coffee") } }
|
85
|
+
after { FileUtils.rm('.coffeelintignore') }
|
86
|
+
|
87
|
+
it "does not lint ignored paths" do
|
88
|
+
results = Coffeelint.lint_dir('/tmp/coffeelint')
|
89
|
+
|
90
|
+
expect(results).to include('/tmp/coffeelint/file2.coffee')
|
91
|
+
expect(results).not_to include(
|
92
|
+
'/tmp/coffeelint/file1.coffee',
|
93
|
+
'/tmp/coffeelint/subdirectory/file3.coffee'
|
94
|
+
)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
43
98
|
end
|
metadata
CHANGED
@@ -1,83 +1,94 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coffeelint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Zachary Bush
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2015-
|
12
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: coffee-script
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
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
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: json
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '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: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: execjs
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
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
|
54
61
|
version: '0'
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: rspec
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- -
|
67
|
+
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: 3.1.0
|
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
|
68
77
|
version: 3.1.0
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rake
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
|
-
- -
|
83
|
+
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: '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: '0'
|
83
94
|
description: Ruby bindings for coffeelint
|
@@ -88,17 +99,16 @@ executables:
|
|
88
99
|
extensions: []
|
89
100
|
extra_rdoc_files: []
|
90
101
|
files:
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
102
|
+
- .gitignore
|
103
|
+
- .gitmodules
|
104
|
+
- .rspec
|
105
|
+
- .travis.yml
|
95
106
|
- Gemfile
|
96
107
|
- LICENSE.txt
|
97
108
|
- README.md
|
98
109
|
- Rakefile
|
99
110
|
- bin/coffeelint.rb
|
100
111
|
- coffeelint.gemspec
|
101
|
-
- coffeelint/lib/coffeelint.js
|
102
112
|
- lib/coffeelint.rb
|
103
113
|
- lib/coffeelint/cmd.rb
|
104
114
|
- lib/coffeelint/config.rb
|
@@ -109,29 +119,31 @@ files:
|
|
109
119
|
- spec/coffeelint_spec.rb
|
110
120
|
- spec/config_spec.rb
|
111
121
|
- spec/spec_helper.rb
|
122
|
+
- coffeelint/lib/coffeelint.js
|
112
123
|
homepage: https://github.com/zipcodeman/coffeelint-ruby
|
113
124
|
licenses:
|
114
125
|
- MIT
|
115
|
-
metadata: {}
|
116
126
|
post_install_message:
|
117
127
|
rdoc_options: []
|
118
128
|
require_paths:
|
119
129
|
- lib
|
120
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
121
132
|
requirements:
|
122
|
-
- -
|
133
|
+
- - ! '>='
|
123
134
|
- !ruby/object:Gem::Version
|
124
135
|
version: '0'
|
125
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
126
138
|
requirements:
|
127
|
-
- -
|
139
|
+
- - ! '>='
|
128
140
|
- !ruby/object:Gem::Version
|
129
141
|
version: '0'
|
130
142
|
requirements: []
|
131
143
|
rubyforge_project:
|
132
|
-
rubygems_version:
|
144
|
+
rubygems_version: 1.8.23
|
133
145
|
signing_key:
|
134
|
-
specification_version:
|
146
|
+
specification_version: 3
|
135
147
|
summary: Ruby bindings for coffeelint along with railtie to add rake task to rails
|
136
148
|
test_files:
|
137
149
|
- spec/assets/.coffeelint.json
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 4e482db9f7267c3b2e3b6a6a39d445a23ed6d2cc
|
4
|
-
data.tar.gz: 16fc6cb55ddc9d88776df33a882d2e1cf374d91c
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 440d9e0c1106684bfbd074359e06b0b2a88ef2c30be6e9c58bf0dd3c8e9ad6d7a668d64f78ee0aa543a08572a6f8722a2a3be3e19408ee3df688b588a7fe402b
|
7
|
-
data.tar.gz: a15b9a7d6e6af6646b715996d1c98781a5c7820d4bdcc99be5dcfc672d3447ec44d8da5a8ded34bbeeaa4f3e4f21a2f7136c506c7cba070bc5c48cfbf8c5b2fb
|