roger_jshint 0.0.2 → 0.1.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 -1
- data/.rubocop.yml +6 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/README.md +2 -1
- data/Rakefile +15 -0
- data/lib/roger_jshint/lint.rb +16 -20
- data/lib/roger_jshint.rb +3 -1
- data/roger_jshint.gemspec +5 -1
- data/test/jshintrc +89 -0
- data/test/lint_test.rb +38 -0
- data/test/test.js +2 -0
- metadata +59 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 831b789d136a29882a93611f9b681b2969c1e4b7
|
4
|
+
data.tar.gz: 18a9adf0b8b9f8a202235539116086b76fa7d88f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34f1c96665169c62f181330510cb51c4a28ab758ddde4f6d3aabefe0a5290cdae07330963a2d4cab5905f416f2c1363df1d7a10f6a37f89ecf64d0e5b586ce76
|
7
|
+
data.tar.gz: bdc7d1e2ede0c399d3f41fa495485fffa19e77e09f171889ce6db3c5661b385a8c2443cf9183c9d8628854dec6320baccfba51500efcfca560b105c4c22f58f6
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
roger_jshint
|
2
2
|
============
|
3
|
+
[](https://travis-ci.org/hkrutzer/roger_jshint)
|
3
4
|
|
4
5
|
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
|
|
@@ -22,4 +23,4 @@ Execute ```roger test jshint```.
|
|
22
23
|
|
23
24
|
## License
|
24
25
|
|
25
|
-
This project is released under the [MIT license](LICENSE).
|
26
|
+
This project is released under the [MIT license](LICENSE).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'rubocop/rake_task'
|
3
|
+
|
4
|
+
task :default => [:test, :rubocop]
|
5
|
+
|
6
|
+
desc 'Run rubocop'
|
7
|
+
task :rubocop do
|
8
|
+
RuboCop::RakeTask.new
|
9
|
+
end
|
10
|
+
|
11
|
+
Rake::TestTask.new do |t|
|
12
|
+
t.libs << 'test'
|
13
|
+
t.test_files = FileList['test/**/*_test.rb']
|
14
|
+
t.verbose = true
|
15
|
+
end
|
data/lib/roger_jshint/lint.rb
CHANGED
@@ -1,28 +1,29 @@
|
|
1
|
+
require 'shellwords'
|
1
2
|
require 'json'
|
2
3
|
require 'roger/test'
|
3
4
|
|
4
5
|
module RogerJsHint
|
5
6
|
# JS linter plugin for Roger
|
6
7
|
class Lint
|
7
|
-
JSHINT = 'jshint'
|
8
|
-
JSHINT_COMMAND = "#{JSHINT} --reporter=" +
|
9
|
-
File.expand_path('jsonreporter.js', File.dirname(__FILE__)) + ' '
|
10
|
-
|
11
8
|
# @param [Hash] options The options
|
12
9
|
# @option options [Array] :match Files to match
|
13
|
-
# @option options [Array[Regexp]] :skip
|
10
|
+
# @option options [Array[Regexp]] :skip Array of regular expressions to skip files
|
11
|
+
# @option options [Array] :jshint Jshint command
|
14
12
|
def initialize(options = {})
|
15
13
|
@options = {
|
16
14
|
:match => ['html/**/*.js'],
|
17
|
-
:skip => []
|
15
|
+
:skip => [],
|
16
|
+
:jshint => 'jshint'
|
18
17
|
}
|
19
18
|
@options.update(options) if options
|
19
|
+
|
20
|
+
@jshint_command = "#{@options[:jshint]} --reporter=" +
|
21
|
+
File.expand_path('jsonreporter.js', File.dirname(__FILE__)) + ' '
|
20
22
|
end
|
21
23
|
|
22
24
|
def detect_jshint
|
23
|
-
|
24
|
-
|
25
|
-
raise 'Could not find jshint. Install jshint using npm.'
|
25
|
+
detect = system(format('%s -v 2>/dev/null', Shellwords.escape(@options[:jshint])))
|
26
|
+
fail 'Could not find jshint. Install jshint using npm.' unless detect
|
26
27
|
end
|
27
28
|
|
28
29
|
def report(test, file_path, lints)
|
@@ -31,9 +32,7 @@ module RogerJsHint
|
|
31
32
|
test.log(self, "No erors in #{file_path}")
|
32
33
|
else
|
33
34
|
lints.each do |lint|
|
34
|
-
test.log(self,
|
35
|
-
"#{lint[0]}:#{lint[1]} " \
|
36
|
-
"#{lint[2]}: #{lint[3]}")
|
35
|
+
test.log(self, "#{lint[0]}:#{lint[1]} #{lint[2]}: #{lint[3]}")
|
37
36
|
end
|
38
37
|
success = false
|
39
38
|
end
|
@@ -42,7 +41,7 @@ module RogerJsHint
|
|
42
41
|
|
43
42
|
# @param [Hash] options The options
|
44
43
|
# @option options [Array] :match Files to match
|
45
|
-
# @option options [Array[Regexp]] :skip
|
44
|
+
# @option options [Array[Regexp]] :skip Array of regular expressions to skip files
|
46
45
|
def call(test, options)
|
47
46
|
options = {}.update(@options).update(options)
|
48
47
|
|
@@ -50,13 +49,10 @@ module RogerJsHint
|
|
50
49
|
test.log(self, 'JS-linting files')
|
51
50
|
|
52
51
|
test.get_files(options[:match], options[:skip]).each do |file_path|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
lint = JSON.parse output
|
58
|
-
report(test, file_path, lint)
|
59
|
-
end
|
52
|
+
execute = @jshint_command + ' ' + Shellwords.escape(file_path)
|
53
|
+
output = `#{execute}`
|
54
|
+
lint = JSON.parse output
|
55
|
+
report(test, file_path, lint)
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
data/lib/roger_jshint.rb
CHANGED
data/roger_jshint.gemspec
CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.authors = ['Hans Krutzer']
|
5
5
|
s.email = ['info@digitpaint.nl', 'hans@digitpaint.nl']
|
6
6
|
s.name = 'roger_jshint'
|
7
|
-
s.version = '0.0
|
7
|
+
s.version = '0.1.0'
|
8
8
|
s.homepage = 'https://github.com/hkrutzer/roger_scsslinter'
|
9
9
|
|
10
10
|
s.summary = 'Lint JavaScript files within Roger'
|
@@ -20,4 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ['lib']
|
21
21
|
|
22
22
|
s.add_dependency 'roger', '~> 0.13', '>= 0.13.0'
|
23
|
+
|
24
|
+
s.add_development_dependency 'rubocop', ['>= 0']
|
25
|
+
s.add_development_dependency 'rake', ['>= 0']
|
26
|
+
s.add_development_dependency 'test-unit', ['>= 0']
|
23
27
|
end
|
data/test/jshintrc
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
{
|
2
|
+
/*
|
3
|
+
* ENVIRONMENTS
|
4
|
+
* =================
|
5
|
+
*/
|
6
|
+
|
7
|
+
// Define globals exposed by modern browsers.
|
8
|
+
"browser": true,
|
9
|
+
|
10
|
+
// Define globals exposed by jQuery.
|
11
|
+
"jquery": true,
|
12
|
+
|
13
|
+
// Define globals exposed by Node.js.
|
14
|
+
"node": true,
|
15
|
+
|
16
|
+
// Placeholder for your own predefs
|
17
|
+
"predef": [],
|
18
|
+
|
19
|
+
/*
|
20
|
+
* ENFORCING OPTIONS
|
21
|
+
* =================
|
22
|
+
*/
|
23
|
+
|
24
|
+
// Force all variable names to use either camelCase style or UPPER_CASE
|
25
|
+
// with underscores.
|
26
|
+
"camelcase": true,
|
27
|
+
|
28
|
+
// Prohibit use of == and != in favor of === and !==.
|
29
|
+
"eqeqeq": true,
|
30
|
+
|
31
|
+
// Suppress warnings about == null comparisons.
|
32
|
+
"eqnull": true,
|
33
|
+
|
34
|
+
// Enforce tab width of 2 spaces.
|
35
|
+
"indent": 2,
|
36
|
+
|
37
|
+
// Prohibit use of a variable before it is defined.
|
38
|
+
"latedef": true,
|
39
|
+
|
40
|
+
// Require capitalized names for constructor functions.
|
41
|
+
"newcap": true,
|
42
|
+
|
43
|
+
// Enforce use of single quotation marks for strings.
|
44
|
+
"quotmark": "single",
|
45
|
+
|
46
|
+
// Prohibit trailing whitespace.
|
47
|
+
"trailing": true,
|
48
|
+
|
49
|
+
// Prohibit use of explicitly undeclared variables.
|
50
|
+
"undef": true,
|
51
|
+
|
52
|
+
// Warn when variables are defined but never used.
|
53
|
+
"unused": true,
|
54
|
+
|
55
|
+
// Enforce line length to 100 characters
|
56
|
+
"maxlen": 100,
|
57
|
+
|
58
|
+
// Enforce placing 'use strict' at the top function scope
|
59
|
+
"strict": true,
|
60
|
+
|
61
|
+
// Extra options by Digitpaint
|
62
|
+
|
63
|
+
// Always put curly braces around blocks in loops and conditionals
|
64
|
+
"curly": true,
|
65
|
+
|
66
|
+
// Prohibits the use of arguments.caller and arguments.callee
|
67
|
+
"noarg": true,
|
68
|
+
|
69
|
+
// Supress warnings about mixed tabs/spaces when used for alignment.
|
70
|
+
"smarttabs" : true,
|
71
|
+
|
72
|
+
// Prohibit use of constructors for side-effects.
|
73
|
+
"nonew": true,
|
74
|
+
|
75
|
+
// Allow the use of ++ and --
|
76
|
+
"plusplus" : false,
|
77
|
+
|
78
|
+
// Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
|
79
|
+
"subsub": false,
|
80
|
+
|
81
|
+
/*
|
82
|
+
* OPTIONAL OPTIONS
|
83
|
+
* =================
|
84
|
+
*/
|
85
|
+
|
86
|
+
// Do not allow bitwise operations
|
87
|
+
"bitwise": true
|
88
|
+
}
|
89
|
+
|
data/test/lint_test.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../lib/roger_jshint/lint.rb'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
# Fake tester to pass into the linter plugin
|
5
|
+
class TesterStub
|
6
|
+
attr_reader :messages
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@messages = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def log(_, message)
|
13
|
+
@messages.push(message)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_files(_, _)
|
17
|
+
['test/test.js']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Linting plugin unit test
|
22
|
+
class LintTest < Test::Unit::TestCase
|
23
|
+
def test_lint
|
24
|
+
faketester = TesterStub.new
|
25
|
+
|
26
|
+
linter = RogerJsHint::Lint.new
|
27
|
+
linter.call(faketester, {})
|
28
|
+
|
29
|
+
messages = faketester.messages
|
30
|
+
messages.shift
|
31
|
+
|
32
|
+
assert_equal(messages,
|
33
|
+
["test/test.js:0 0: Bad option: 'subsub'.",
|
34
|
+
"test/test.js:1 1: 'x' is not defined.",
|
35
|
+
"test/test.js:2 1: 'alert' is not defined.",
|
36
|
+
"test/test.js:2 7: 'x' is not defined."])
|
37
|
+
end
|
38
|
+
end
|
data/test/test.js
ADDED
metadata
CHANGED
@@ -1,35 +1,77 @@
|
|
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.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hans Krutzer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: roger
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.13'
|
20
|
-
- -
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
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
29
|
version: '0.13'
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.13.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rubocop
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: test-unit
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
33
75
|
description: |2
|
34
76
|
Lint JavaScript files from within Roger, using jshint.
|
35
77
|
Will use .jshintrc.
|
@@ -40,13 +82,20 @@ executables: []
|
|
40
82
|
extensions: []
|
41
83
|
extra_rdoc_files: []
|
42
84
|
files:
|
43
|
-
- .gitignore
|
85
|
+
- ".gitignore"
|
86
|
+
- ".rubocop.yml"
|
87
|
+
- ".travis.yml"
|
88
|
+
- Gemfile
|
44
89
|
- LICENSE
|
45
90
|
- README.md
|
91
|
+
- Rakefile
|
46
92
|
- lib/roger_jshint.rb
|
47
93
|
- lib/roger_jshint/jsonreporter.js
|
48
94
|
- lib/roger_jshint/lint.rb
|
49
95
|
- roger_jshint.gemspec
|
96
|
+
- test/jshintrc
|
97
|
+
- test/lint_test.rb
|
98
|
+
- test/test.js
|
50
99
|
homepage: https://github.com/hkrutzer/roger_scsslinter
|
51
100
|
licenses:
|
52
101
|
- MIT
|
@@ -57,17 +106,17 @@ require_paths:
|
|
57
106
|
- lib
|
58
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
108
|
requirements:
|
60
|
-
- -
|
109
|
+
- - ">="
|
61
110
|
- !ruby/object:Gem::Version
|
62
111
|
version: '0'
|
63
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
113
|
requirements:
|
65
|
-
- -
|
114
|
+
- - ">="
|
66
115
|
- !ruby/object:Gem::Version
|
67
116
|
version: '0'
|
68
117
|
requirements: []
|
69
118
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.2.2
|
71
120
|
signing_key:
|
72
121
|
specification_version: 4
|
73
122
|
summary: Lint JavaScript files within Roger
|