coffeelint 0.2.5 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52e26570cb6aeb608b13718ee0643a3587799f5b
4
- data.tar.gz: 87ca1b9e93e502ab77443fd76ab7f8b227c098cd
3
+ metadata.gz: 344ed179d709d31cb9cfc849b08bfee88b8aec30
4
+ data.tar.gz: 505057ae769bedb0e2703c0190cb3bf248a68e3e
5
5
  SHA512:
6
- metadata.gz: 4bb4389a7e90c880e22ffb9a11f4e881a70225749c410a707d37c8e59d7e0c028c2386d979659804eaa4d612054c93bc817cba2f382ac42640f085a9ce6c5e26
7
- data.tar.gz: 0dda5a52009fe77364cc10812362b249dd48368410d3796700e2d0c521a44ecfb53bd17419d66a4b836e9fe8bdccd5b82edd4b1fedb6199f6328254e6c55c40e
6
+ metadata.gz: 2d810eeab5acfc59ff90273a0c084dac875a059fc05bba4caf09a3e84b727649d766b7c344f1092d6a92a45c879314c4a5bd7dc2a60b189e97aed0590da755a5
7
+ data.tar.gz: c7f271a95c8c5dfc6c9b85b77bdab7f4f3c973380877415adab41fb7bee057add6fe00bc60bee59119987149a332fb9f8b2d6615d3563e6e8a03983dc8ddc831
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Coffeelint [![Build Status](https://travis-ci.org/zmbush/coffeelint-ruby.svg?branch=master)](https://travis-ci.org/zmbush/coffeelint-ruby) [![Gem Version](https://badge.fury.io/rb/coffeelint.png)](http://badge.fury.io/rb/coffeelint)
2
2
 
3
- Using coffeelint version: v1.1.0-21-g5dc0408-20-gc896693
3
+ Using coffeelint version: v1.2.0-6-g20613f6
4
4
 
5
5
  Coffeelint is a set of simple ruby bindings for [coffeelint](https://github.com/clutchski/coffeelint).
6
6
 
data/Rakefile CHANGED
@@ -8,6 +8,10 @@ task :console do
8
8
  sh "irb -rubygems -I lib -r coffeelint.rb"
9
9
  end
10
10
 
11
+ task :cmd do
12
+ sh "ruby -I lib -- bin/coffeelint.rb"
13
+ end
14
+
11
15
  task :prepare_coffeelint do
12
16
  sh "git submodule init"
13
17
  sh "git submodule update"
@@ -1,79 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'coffeelint'
4
- require 'coffeelint/version'
5
- require 'optparse'
6
4
 
7
- options = {
8
- :recursive => false,
9
- :noconfig => false,
10
- :stdin => false,
11
- :quiet => false,
12
- }
13
-
14
- linter_options = {}
15
-
16
- opt_parser = OptionParser.new do |opts|
17
- opts.banner = "Usage: coffeelint.rb [options] source [...]"
18
-
19
- =begin
20
- -f, --file Specify a custom configuration file.
21
- --noconfig Ignores the environment variable COFFEELINT_CONFIG. [boolean]
22
- -h, --help Print help information.
23
- -v, --version Print current version number.
24
- -r Recursively lint .coffee files in subdirectories. [boolean]
25
- --csv Use the csv reporter. [boolean]
26
- --jslint Use the JSLint XML reporter. [boolean]
27
- --nocolor Don't colorize the output [boolean]
28
- -s, --stdin Lint the source from stdin [boolean]
29
- -q, --quiet Only print errors. [boolean]
30
- =end
31
-
32
-
33
- opts.on "-f FILE", "--file FILE", "Specify a custom configuration file." do |f|
34
- linter_options[:config_file] = f
35
- end
36
-
37
- =begin
38
- opts.on "--noconfig", "Ignores the environment variabel COFFEELINT_CONFIG." do |f|
39
- options[:noconfig] = true
40
- end
41
- =end
42
-
43
- opts.on_tail "-h", "--help", "Print help information." do
44
- puts opts
45
- exit
46
- end
47
-
48
- opts.on_tail "-v", "--version", "Print current version number." do
49
- puts Coffeelint::VERSION
50
- exit
51
- end
52
-
53
- opts.on '-r', "Recursively lint .coffee files in subdirectories." do
54
- options[:recursive] = true
55
- end
56
-
57
- =begin
58
- opts.on '-s', '--stdin', "Lint the source from stdin" do
59
- options[:stdin] = true
60
- end
61
-
62
- opts.on '-q', '--quiet', 'Only print errors.' do
63
- options[:quiet] = true
64
- end
65
- =end
66
-
67
- end
68
-
69
- opt_parser.parse!
70
-
71
- if ARGV.length > 0
72
- ARGV.each do |file|
73
- if options[:recursive]
74
- Coffeelint.run_test_suite(file, linter_options)
75
- else
76
- Coffeelint.run_test(file, linter_options)
77
- end
78
- end
79
- end
5
+ Coffeelint::Cmd.main
@@ -14,6 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.licenses = ["MIT"]
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
17
+ gem.files -= ['bin/coffeelint']
17
18
  gem.files << 'coffeelint/lib/coffeelint.js'
18
19
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -2,7 +2,7 @@
2
2
  module.exports={
3
3
  "name": "coffeelint",
4
4
  "description": "Lint your CoffeeScript",
5
- "version": "1.1.0",
5
+ "version": "1.2.0",
6
6
  "homepage": "http://www.coffeelint.org",
7
7
  "keywords": [
8
8
  "lint",
@@ -87,15 +87,7 @@ ASTApi = (function() {
87
87
  ASTApi.prototype.getNodeName = function(node) {
88
88
  var children, name, _ref;
89
89
  name = node != null ? (_ref = node.constructor) != null ? _ref.name : void 0 : void 0;
90
- if (name === (function() {
91
- var _results;
92
- _results = [];
93
- for (name in node_children) {
94
- if (!__hasProp.call(node_children, name)) continue;
95
- _results.push(name);
96
- }
97
- return _results;
98
- })()) {
90
+ if (node_children[name]) {
99
91
  return name;
100
92
  } else {
101
93
  for (name in node_children) {
@@ -1,4 +1,5 @@
1
1
  require "coffeelint/version"
2
+ require 'coffeelint/cmd'
2
3
  require 'execjs'
3
4
  require 'coffee-script'
4
5
  require 'json'
@@ -22,6 +23,10 @@ module Coffeelint
22
23
  pretty_output ? Coffeelint.colorize(str, 32) : str
23
24
  end
24
25
 
26
+ def self.yellow(str, pretty_output = true)
27
+ pretty_output ? Coffeelint.colorize(str, 33) : str
28
+ end
29
+
25
30
  def self.context
26
31
  coffeescriptSource = File.read(CoffeeScript::Source.path)
27
32
  bootstrap = <<-EOF
@@ -57,19 +62,38 @@ module Coffeelint
57
62
 
58
63
  def self.display_test_results(name, errors, pretty_output = true)
59
64
  good = pretty_output ? "\u2713" : 'Passed'
65
+ warn = pretty_output ? "\u26A1" : 'Warn'
60
66
  bad = pretty_output ? "\u2717" : 'Failed'
61
67
 
62
68
  if errors.length == 0
63
69
  puts " #{good} " + Coffeelint.green(name, pretty_output)
64
70
  return true
65
71
  else
66
- puts " #{bad} " + Coffeelint.red(name, pretty_output)
72
+ failed = false
73
+ if errors.any? {|e| e["level"] == "error"}
74
+ failed = true
75
+ puts " #{bad} " + Coffeelint.red(name, pretty_output)
76
+ else
77
+ puts " #{warn} " + Coffeelint.yellow(name, pretty_output)
78
+ end
79
+
67
80
  errors.each do |error|
68
- print " #{bad} "
69
- print Coffeelint.red(error["lineNumber"], pretty_output)
70
- puts ": #{error["message"]}, #{error["context"]}."
81
+ disp = "##{error["lineNumber"]}"
82
+ if error["lineNumberEnd"]
83
+ disp += "-#{error["lineNumberEnd"]}"
84
+ end
85
+
86
+ print " "
87
+ if error["level"] == "warn"
88
+ print warn + " "
89
+ print Coffeelint.yellow(disp, pretty_output)
90
+ else
91
+ print bad + " "
92
+ print Coffeelint.red(disp, pretty_output)
93
+ end
94
+ puts ": #{error["message"]}. #{error["context"]}."
71
95
  end
72
- return false
96
+ return failed
73
97
  end
74
98
  end
75
99
 
@@ -0,0 +1,94 @@
1
+ require 'coffeelint/version'
2
+
3
+ require 'optparse'
4
+
5
+ module Coffeelint
6
+ module Cmd
7
+ def self.parse_options(name = 'coffeelint.rb')
8
+ options = {
9
+ :recursive => false,
10
+ :noconfig => false,
11
+ :stdin => false,
12
+ :quiet => false,
13
+ }
14
+
15
+ linter_options = {}
16
+
17
+ opt_parser = OptionParser.new do |opts|
18
+ opts.banner = "Usage: coffeelint.rb [options] source [...]"
19
+
20
+ =begin
21
+ -f, --file Specify a custom configuration file.
22
+ --noconfig Ignores the environment variable COFFEELINT_CONFIG. [boolean]
23
+ -h, --help Print help information.
24
+ -v, --version Print current version number.
25
+ -r Recursively lint .coffee files in subdirectories. [boolean]
26
+ --csv Use the csv reporter. [boolean]
27
+ --jslint Use the JSLint XML reporter. [boolean]
28
+ --nocolor Don't colorize the output [boolean]
29
+ -s, --stdin Lint the source from stdin [boolean]
30
+ -q, --quiet Only print errors. [boolean]
31
+ =end
32
+
33
+
34
+ opts.on "-f FILE", "--file FILE", "Specify a custom configuration file." do |f|
35
+ linter_options[:config_file] = f
36
+ end
37
+
38
+ =begin
39
+ opts.on "--noconfig", "Ignores the environment variabel COFFEELINT_CONFIG." do |f|
40
+ options[:noconfig] = true
41
+ end
42
+ =end
43
+
44
+ opts.on_tail "-h", "--help", "Print help information." do
45
+ puts opts
46
+ exit
47
+ end
48
+
49
+ opts.on_tail "-v", "--version", "Print current version number." do
50
+ puts Coffeelint::VERSION
51
+ exit
52
+ end
53
+
54
+ opts.on '-r', "Recursively lint .coffee files in subdirectories." do
55
+ options[:recursive] = true
56
+ end
57
+
58
+ =begin
59
+ opts.on '-s', '--stdin', "Lint the source from stdin" do
60
+ options[:stdin] = true
61
+ end
62
+
63
+ opts.on '-q', '--quiet', 'Only print errors.' do
64
+ options[:quiet] = true
65
+ end
66
+ =end
67
+
68
+ end
69
+
70
+ opt_parser.parse!
71
+
72
+ return {
73
+ :options => options,
74
+ :linter_options => linter_options
75
+ }
76
+ end
77
+
78
+ def self.main
79
+ options = parse_options
80
+
81
+ if ARGV.length > 0
82
+ ARGV.each do |file|
83
+ if options[:options][:recursive]
84
+ Coffeelint.run_test_suite(file, options[:linter_options])
85
+ else
86
+ Coffeelint.run_test(file, options[:linter_options])
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+
@@ -1,3 +1,3 @@
1
1
  module Coffeelint
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coffeelint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Bush
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-script
@@ -98,6 +98,7 @@ files:
98
98
  - bin/coffeelint.rb
99
99
  - coffeelint.gemspec
100
100
  - lib/coffeelint.rb
101
+ - lib/coffeelint/cmd.rb
101
102
  - lib/coffeelint/railtie.rb
102
103
  - lib/coffeelint/version.rb
103
104
  - lib/tasks/coffeelint.rake