eslintrb 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/Gemfile +0 -1
- data/README.md +21 -22
- data/eslintrb.gemspec +4 -4
- data/lib/eslintrb/eslinttask.rb +6 -6
- data/lib/eslintrb/lint.rb +12 -4
- data/lib/eslintrb/reporter/default.rb +1 -1
- data/lib/eslintrb/version.rb +1 -1
- data/spec/eslintrb_spec.rb +2 -2
- data/spec/fixtures/.eslintrc +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5809b14dc2b24fb0b80431519d9b10c3982aa50
|
4
|
+
data.tar.gz: 2855acfb8114de558d639f60a7d5210027d7a86a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbe83ba1523ded6f7dc44e0ae1b4f28338e0a2894ae82367cb11f04a2294f09816641433c9bdf8d46f1170fbdce3a94910c2bb316e7ab5714b1c9720e4aeef81
|
7
|
+
data.tar.gz: 816ecff047f90034d9ad85bdd7c2a0446e369e583367ad18cbd8b1665381d549915a5a0b678f97e7a23278386f19272c94a3dd8c1cbcf0ee00847fa875603e9d
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,10 +18,10 @@ Ensure that your environment has a JavaScript interpreter supported by [ExecJS](
|
|
18
18
|
```ruby
|
19
19
|
require 'eslintrb'
|
20
20
|
|
21
|
-
|
21
|
+
Eslintrb.lint(File.read("source.js"), :defaults)
|
22
22
|
# => array of warnings
|
23
23
|
|
24
|
-
|
24
|
+
Eslintrb.report(File.read("source.js"), :defaults)
|
25
25
|
# => string
|
26
26
|
```
|
27
27
|
|
@@ -29,7 +29,7 @@ Or you can use it with rake
|
|
29
29
|
|
30
30
|
```ruby
|
31
31
|
require "eslintrb/eslinttask"
|
32
|
-
|
32
|
+
Eslintrb::EslintTask.new :eslint do |t|
|
33
33
|
t.pattern = 'javascript/**/*.js'
|
34
34
|
t.options = :defaults
|
35
35
|
end
|
@@ -38,33 +38,32 @@ end
|
|
38
38
|
When initializing `eslintrb`, you can pass options
|
39
39
|
|
40
40
|
```ruby
|
41
|
-
|
41
|
+
Eslintrb::Lint.new('no-undef' => true).lint(source)
|
42
42
|
# Or
|
43
|
-
|
43
|
+
Eslintrb.lint(source, 'no-undef' => true)
|
44
44
|
```
|
45
45
|
|
46
|
-
[List of all available options](http://
|
46
|
+
[List of all available options](http://eslint.org/docs/rules/)
|
47
47
|
|
48
48
|
If you pass `:defaults` as option, it is the same as if you pass following
|
49
49
|
|
50
50
|
```
|
51
51
|
{
|
52
|
-
:
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
:
|
65
|
-
|
66
|
-
|
67
|
-
:browser => true
|
52
|
+
rules: {
|
53
|
+
'no-bitwise' => 2,
|
54
|
+
'curly' => 2,
|
55
|
+
'eqeqeq' => 2,
|
56
|
+
'guard-for-in' => 2,
|
57
|
+
'no-use-before-define' => 2,
|
58
|
+
'no-caller' => 2,
|
59
|
+
'no-new-func' => 2,
|
60
|
+
'no-plusplus' => 2,
|
61
|
+
'no-undef' => 2,
|
62
|
+
'strict' => 2
|
63
|
+
},
|
64
|
+
env: {
|
65
|
+
'browser' => true
|
66
|
+
}
|
68
67
|
}
|
69
68
|
```
|
70
69
|
|
data/eslintrb.gemspec
CHANGED
@@ -5,11 +5,11 @@ require "eslintrb/version"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "eslintrb"
|
7
7
|
s.version = Eslintrb::VERSION
|
8
|
-
s.authors = ["
|
9
|
-
s.email = ["
|
8
|
+
s.authors = ["ocke", "stereobooster"]
|
9
|
+
s.email = ["ocke@exploder.nl", "stereobooster@gmail.com"]
|
10
10
|
s.homepage = "https://github.com/ocke/eslintrb"
|
11
|
-
s.summary = %q{Ruby wrapper for
|
12
|
-
s.description = %q{Ruby wrapper for
|
11
|
+
s.summary = %q{Ruby wrapper for ESLint}
|
12
|
+
s.description = %q{Ruby wrapper for ESLint. The main difference from eslint gem it does not depend on Java. Instead, it uses ExecJS}
|
13
13
|
s.license = "MIT"
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
data/lib/eslintrb/eslinttask.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Define a task library for running
|
1
|
+
# Define a task library for running ESLint contexts.
|
2
2
|
|
3
3
|
require 'rake'
|
4
4
|
require 'rake/tasklib'
|
@@ -8,7 +8,7 @@ require 'eslintrb'
|
|
8
8
|
module Eslintrb
|
9
9
|
|
10
10
|
class EslintTask < ::Rake::TaskLib
|
11
|
-
# Name of
|
11
|
+
# Name of ESLint task. (default is :eslint)
|
12
12
|
attr_accessor :name
|
13
13
|
|
14
14
|
# Glob pattern to match JavaScript files. (default is './**/*.js')
|
@@ -19,7 +19,7 @@ module Eslintrb
|
|
19
19
|
|
20
20
|
attr_accessor :globals
|
21
21
|
|
22
|
-
# Whether or not to fail Rake when an error occurs (typically when
|
22
|
+
# Whether or not to fail Rake when an error occurs (typically when ESLint check fail).
|
23
23
|
# Defaults to true.
|
24
24
|
attr_accessor :fail_on_error
|
25
25
|
|
@@ -34,7 +34,7 @@ module Eslintrb
|
|
34
34
|
attr_accessor :exclude_js_files
|
35
35
|
|
36
36
|
# Defines a new task, using the name +name+.
|
37
|
-
def initialize(name=:
|
37
|
+
def initialize(name=:eslint)
|
38
38
|
@name = name
|
39
39
|
@pattern = nil
|
40
40
|
@js_files = nil
|
@@ -53,13 +53,13 @@ module Eslintrb
|
|
53
53
|
|
54
54
|
actual_name = Hash === name ? name.keys.first : name
|
55
55
|
unless ::Rake.application.last_comment
|
56
|
-
desc "Run
|
56
|
+
desc "Run ESLint"
|
57
57
|
end
|
58
58
|
task name do
|
59
59
|
unless js_file_list.empty?
|
60
60
|
result = Eslintrb::report(js_file_list, @options, @globals, STDERR)
|
61
61
|
if result.size > 0
|
62
|
-
abort("
|
62
|
+
abort("ESLint check failed") if fail_on_error
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/eslintrb/lint.rb
CHANGED
@@ -12,10 +12,18 @@ module Eslintrb
|
|
12
12
|
DEFAULTS = {
|
13
13
|
rules: {
|
14
14
|
'no-bitwise' => 2,
|
15
|
+
'curly' => 2,
|
16
|
+
'eqeqeq' => 2,
|
17
|
+
'guard-for-in' => 2,
|
18
|
+
'no-use-before-define' => 2,
|
19
|
+
'no-caller' => 2,
|
20
|
+
'no-new-func' => 2,
|
21
|
+
'no-plusplus' => 2,
|
15
22
|
'no-undef' => 2,
|
16
|
-
|
17
|
-
|
18
|
-
|
23
|
+
'strict' => 2
|
24
|
+
},
|
25
|
+
env: {
|
26
|
+
'browser' => true
|
19
27
|
}
|
20
28
|
}
|
21
29
|
|
@@ -25,7 +33,7 @@ module Eslintrb
|
|
25
33
|
|
26
34
|
if options == :defaults then
|
27
35
|
@options = DEFAULTS.dup
|
28
|
-
elsif options == :
|
36
|
+
elsif options == :eslintrc then
|
29
37
|
raise '`.eslintrc` is not exist on current working directory.' unless File.exist?('./.eslintrc')
|
30
38
|
@options = MultiJson.load(File.read('./.eslintrc'))
|
31
39
|
elsif options.instance_of? Hash then
|
@@ -14,7 +14,7 @@ module Eslintrb
|
|
14
14
|
result += indent + 'fatal error'
|
15
15
|
else
|
16
16
|
result += indent + 'line ' + error["line"].to_s + ', col ' +
|
17
|
-
error["
|
17
|
+
error["column"].to_s + ', ' + error["message"].to_s + "\n"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/eslintrb/version.rb
CHANGED
data/spec/eslintrb_spec.rb
CHANGED
@@ -35,7 +35,7 @@ describe "Eslintrb" do
|
|
35
35
|
basedir = File.join(File.dirname(__FILE__), "fixtures")
|
36
36
|
source = "var hoge;"
|
37
37
|
Dir.chdir basedir do
|
38
|
-
expect(Eslintrb.lint(source, :
|
38
|
+
expect(Eslintrb.lint(source, :eslintrc).length).to eq 1
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -43,7 +43,7 @@ describe "Eslintrb" do
|
|
43
43
|
basedir = File.join(File.dirname(__FILE__), "fixtures")
|
44
44
|
source = "foo();"
|
45
45
|
Dir.chdir basedir do
|
46
|
-
expect(Eslintrb.lint(source, :
|
46
|
+
expect(Eslintrb.lint(source, :eslintrc).length).to eq 0
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
data/spec/fixtures/.eslintrc
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eslintrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- stereobooster
|
8
7
|
- ocke
|
8
|
+
- stereobooster
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-12-
|
12
|
+
date: 2015-12-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -81,11 +81,11 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
-
description: Ruby wrapper for
|
84
|
+
description: Ruby wrapper for ESLint. The main difference from eslint gem it does
|
85
85
|
not depend on Java. Instead, it uses ExecJS
|
86
86
|
email:
|
87
|
-
- stereobooster@gmail.com
|
88
87
|
- ocke@exploder.nl
|
88
|
+
- stereobooster@gmail.com
|
89
89
|
executables: []
|
90
90
|
extensions: []
|
91
91
|
extra_rdoc_files: []
|
@@ -129,7 +129,7 @@ rubyforge_project:
|
|
129
129
|
rubygems_version: 2.4.5.1
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
|
-
summary: Ruby wrapper for
|
132
|
+
summary: Ruby wrapper for ESLint
|
133
133
|
test_files:
|
134
134
|
- spec/eslintrb_spec.rb
|
135
135
|
- spec/fixtures/.eslintrc
|