roger_jshint 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -1
- data/lib/roger_jshint.rb +3 -0
- data/lib/roger_jshint/jsonreporter.js +18 -0
- data/lib/roger_jshint/lint.rb +65 -0
- data/roger_jshint.gemspec +23 -0
- metadata +17 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 173aefd6d7edd876af67a041bbe007a505f26519
|
4
|
+
data.tar.gz: 87c805c257ed31095a847af6596c9ad6d1a78791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7505cad99b8b2c88085c7d3bb843af5dde840e87d80eea935409050facbf223bd672b67d183494f0ce9ced312b2b9d699bf83001d7b082174ff81ce69b71620f
|
7
|
+
data.tar.gz: 365153eb8ab08abca4e8d5d61295c4854139b7db992bac137e4f32d368abb1d18e522aaf71988818684a9e6bbcf6f58809fa8237293071ea9134e457acecd668
|
data/README.md
CHANGED
@@ -1,4 +1,25 @@
|
|
1
1
|
roger_jshint
|
2
2
|
============
|
3
3
|
|
4
|
-
Lint JavaScript files within Roger
|
4
|
+
Lint JavaScript files from within Roger. This plugin uses [jshint](https://github.com/jshint/jshint). If present, .jshintrc in your project will be used. If not, jshint will walk the directory tree upwards until a .jshintrc file is found. As a last resort, [jshint's default configuration](https://raw.githubusercontent.com/jshint/jshint/master/examples/.jshintrc) is used.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
* Install jshint using npm: ```npm install jshint -g```
|
8
|
+
|
9
|
+
* Add ```gem 'roger_jshint'``` to your Gemfile
|
10
|
+
|
11
|
+
* Add this to your Mockupfile:
|
12
|
+
```
|
13
|
+
mockup.test do |t|
|
14
|
+
t.use :jshint
|
15
|
+
end
|
16
|
+
```
|
17
|
+
|
18
|
+
* (Optional) put a .jshintrc in your project's root directory.
|
19
|
+
|
20
|
+
## Running
|
21
|
+
Execute ```roger test jshint```.
|
22
|
+
|
23
|
+
## License
|
24
|
+
|
25
|
+
This project is released under the [MIT license](LICENSE).
|
data/lib/roger_jshint.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
reporter: function (res) {
|
5
|
+
var errors = [];
|
6
|
+
|
7
|
+
res.forEach(function (r) {
|
8
|
+
var file = r.file;
|
9
|
+
var err = r.error;
|
10
|
+
|
11
|
+
errors.push([file, err.line, err.character, err.reason]);
|
12
|
+
});
|
13
|
+
|
14
|
+
if (errors) {
|
15
|
+
process.stdout.write(JSON.stringify(errors) + "\n");
|
16
|
+
}
|
17
|
+
}
|
18
|
+
};
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'roger/test'
|
3
|
+
|
4
|
+
module RogerJsHint
|
5
|
+
# JS linter plugin for Roger
|
6
|
+
class Lint
|
7
|
+
JSHINT = 'jshint'
|
8
|
+
JSHINT_COMMAND = "#{JSHINT} --reporter=" +
|
9
|
+
File.expand_path('jsonreporter.js', File.dirname(__FILE__)) + ' '
|
10
|
+
|
11
|
+
# @param [Hash] options The options
|
12
|
+
# @option options [Array] :match Files to match
|
13
|
+
# @option options [Array[Regexp]] :skip An array of file regular expressions to specifiy which files to skip.
|
14
|
+
def initialize(options = {})
|
15
|
+
@options = {
|
16
|
+
:match => ['html/**/*.js'],
|
17
|
+
:skip => []
|
18
|
+
}
|
19
|
+
@options.update(options) if options
|
20
|
+
end
|
21
|
+
|
22
|
+
def detect_jshint
|
23
|
+
`#{JSHINT} -v`
|
24
|
+
rescue Errno::ENOENT
|
25
|
+
raise 'Could not find jshint. Install jshint using npm.'
|
26
|
+
end
|
27
|
+
|
28
|
+
def report(test, file_path, lints)
|
29
|
+
success = true
|
30
|
+
if lints.empty?
|
31
|
+
test.log(self, "No erors in #{file_path}")
|
32
|
+
else
|
33
|
+
lints.each do |lint|
|
34
|
+
test.log(self,
|
35
|
+
"#{lint[0]}:#{lint[1]} " \
|
36
|
+
"#{lint[2]}: #{lint[3]}")
|
37
|
+
end
|
38
|
+
success = false
|
39
|
+
end
|
40
|
+
success
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param [Hash] options The options
|
44
|
+
# @option options [Array] :match Files to match
|
45
|
+
# @option options [Array[Regexp]] :skip An array of file regular expressions to specifiy which files to skip.
|
46
|
+
def call(test, options)
|
47
|
+
options = {}.update(@options).update(options)
|
48
|
+
|
49
|
+
detect_jshint
|
50
|
+
test.log(self, 'JS-linting files')
|
51
|
+
|
52
|
+
test.get_files(options[:match], options[:skip]).each do |file_path|
|
53
|
+
output = `#{JSHINT_COMMAND} #{file_path}`
|
54
|
+
if output.start_with? 'ERROR'
|
55
|
+
fail "Could not load file #{file_path}"
|
56
|
+
else
|
57
|
+
lint = JSON.parse output
|
58
|
+
report(test, file_path, lint)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Roger::Test.register :jshint, RogerJsHint::Lint
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.authors = ['Hans Krutzer']
|
5
|
+
s.email = ['info@digitpaint.nl', 'hans@digitpaint.nl']
|
6
|
+
s.name = 'roger_jshint'
|
7
|
+
s.version = '0.0.2'
|
8
|
+
s.homepage = 'https://github.com/hkrutzer/roger_scsslinter'
|
9
|
+
|
10
|
+
s.summary = 'Lint JavaScript files within Roger'
|
11
|
+
s.description = <<-EOF
|
12
|
+
Lint JavaScript files from within Roger, using jshint.
|
13
|
+
Will use .jshintrc.
|
14
|
+
EOF
|
15
|
+
s.licenses = ['MIT']
|
16
|
+
|
17
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.require_paths = ['lib']
|
21
|
+
|
22
|
+
s.add_dependency 'roger', '~> 0.13', '>= 0.13.0'
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roger_jshint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hans Krutzer
|
@@ -14,22 +14,22 @@ dependencies:
|
|
14
14
|
name: roger
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
20
|
-
- -
|
19
|
+
version: '0.13'
|
20
|
+
- - '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.13.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
30
|
-
- -
|
29
|
+
version: '0.13'
|
30
|
+
- - '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.13.0
|
33
33
|
description: |2
|
34
34
|
Lint JavaScript files from within Roger, using jshint.
|
35
35
|
Will use .jshintrc.
|
@@ -40,9 +40,13 @@ executables: []
|
|
40
40
|
extensions: []
|
41
41
|
extra_rdoc_files: []
|
42
42
|
files:
|
43
|
-
-
|
43
|
+
- .gitignore
|
44
44
|
- LICENSE
|
45
45
|
- README.md
|
46
|
+
- lib/roger_jshint.rb
|
47
|
+
- lib/roger_jshint/jsonreporter.js
|
48
|
+
- lib/roger_jshint/lint.rb
|
49
|
+
- roger_jshint.gemspec
|
46
50
|
homepage: https://github.com/hkrutzer/roger_scsslinter
|
47
51
|
licenses:
|
48
52
|
- MIT
|
@@ -53,17 +57,17 @@ require_paths:
|
|
53
57
|
- lib
|
54
58
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
59
|
requirements:
|
56
|
-
- -
|
60
|
+
- - '>='
|
57
61
|
- !ruby/object:Gem::Version
|
58
62
|
version: '0'
|
59
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
64
|
requirements:
|
61
|
-
- -
|
65
|
+
- - '>='
|
62
66
|
- !ruby/object:Gem::Version
|
63
67
|
version: '0'
|
64
68
|
requirements: []
|
65
69
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.
|
70
|
+
rubygems_version: 2.0.14
|
67
71
|
signing_key:
|
68
72
|
specification_version: 4
|
69
73
|
summary: Lint JavaScript files within Roger
|