eslint-rails 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 522127e2bb834cbd61737940076956bae357a2f5
4
+ data.tar.gz: 11dfe715b25b8ce80305534ac3d55aabc0d9aa88
5
+ SHA512:
6
+ metadata.gz: 46f1202a57e3662a5c80245a5c6d8d511a0fd2959c17a822f1a96ae0c53c8f349fc1f10e6706c54624de08dd6292087a643be4e40568a48369b142812ea04f16
7
+ data.tar.gz: 1f29e688832ba7a5734ad0c03310c50469b709533dbec75f5c41fe54134f80d403e01a361efc523cac692ec99b91bf2bdcafb922266cd756fc7ebfc04a16cfcb
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in eslint-rails.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 AppFolio, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,59 @@
1
+ # eslint-rails
2
+
3
+ Run [ESLint][] against your Rails repo.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'eslint-rails'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### CLI
16
+
17
+ ![rake-eslint-rails-run][]
18
+
19
+ ```sh
20
+ rake eslint:run
21
+ ```
22
+
23
+ This will analyze `application.js`. Optionally, you can supply a filename to the
24
+ task. To analyze `woop.js`, you would run
25
+
26
+ ```sh
27
+ rake eslint:run[woop]
28
+ ```
29
+
30
+ ### Web interface
31
+
32
+ On non-production environments, visit these URLs on your application:
33
+
34
+ Path | Description
35
+ ---------------------------- | -------------------------------------------------
36
+ `/eslint` | Optionally supply a filename parameter to analyze a file other than `application.js`, e.g. `/eslint?filename=foo` to analyze foo.js.
37
+ `/eslint/source/application` | Optionally replace `application` with the name of another JavaScript file, e.g. `eslint/source/button_stuff` will show you `button_source.js`.
38
+
39
+ ![eslint-rails-web-source](https://cloud.githubusercontent.com/assets/324632/6671965/33d6819c-cbc6-11e4-9a64-30be84f20b96.png)
40
+
41
+ ![eslint-rails-web](https://cloud.githubusercontent.com/assets/324632/6671966/33d8cc86-cbc6-11e4-904d-3379907c429d.png)
42
+
43
+ # Authors
44
+
45
+ - Jon Kessler <[jon.kessler@appfolio.com][]>
46
+ - Justin Force <[justin.force@appfolio.com][]>
47
+
48
+ # License
49
+
50
+ [MIT License][].
51
+
52
+ [ESLint]: http://eslint.org/
53
+ [justin.force@appfolio.com]: mailto:justin.force@appfolio.com
54
+ [jon.kessler@appfolio.com]: mailto:jon.kessler@appfolio.com
55
+ [MIT License]: http://www.opensource.org/licenses/MIT)
56
+
57
+ [rake-eslint-rails-run]: https://cloud.githubusercontent.com/assets/324632/6671891/b5b92760-cbc5-11e4-8a3c-12c19ccfbb4d.png
58
+ [eslint-rails-web-source]: https://cloud.githubusercontent.com/assets/324632/6671965/33d6819c-cbc6-11e4-9a64-30be84f20b96.png
59
+ [eslint-rails-web]: https://cloud.githubusercontent.com/assets/324632/6671966/33d8cc86-cbc6-11e4-904d-3379907c429d.png
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,18 @@
1
+ class EslintController < ActionController::Base
2
+
3
+ before_filter :set_filename
4
+
5
+ def show
6
+ @warnings = ESLintRails::Runner.new(@filename).run
7
+ end
8
+
9
+ def source
10
+ @source = Rails.application.assets[@filename].to_s
11
+ end
12
+
13
+ private
14
+
15
+ def set_filename
16
+ @filename = params[:filename] || 'application'
17
+ end
18
+ end
@@ -0,0 +1,50 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
5
+ <style>
6
+ .container {
7
+ margin: 0 auto;
8
+ width: 980px;
9
+ }
10
+ </style>
11
+ </head>
12
+ <body>
13
+ <div class="container">
14
+ <h1>ESLint Report</h1>
15
+ <table class="table">
16
+ <thead>
17
+ <tr>
18
+ <th>Location</th>
19
+ <th>Severity</th>
20
+ <th>Rule</th>
21
+ <th>Message</th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <% @warnings.each do |warning| %>
26
+ <%
27
+ row_class = case warning.severity
28
+ when :low
29
+ 'success'
30
+ when :high
31
+ 'warning'
32
+ else
33
+ ''
34
+ end
35
+ %>
36
+ <tr class="<%= row_class %>">
37
+ <td><%= link_to(
38
+ "#{warning.line}:#{warning.column}",
39
+ eslint_source_path(@filename, anchor: warning.line)
40
+ ) %></td>
41
+ <td><%= warning.severity.to_s.capitalize %></td>
42
+ <td><%= link_to warning.rule_id, "http://eslint.org/docs/rules/#{warning.rule_id}.html" %></td>
43
+ <td><%= warning.message %></td>
44
+ </tr>
45
+ <% end %>
46
+ </tbody>
47
+ </table>
48
+ </div>
49
+ </body>
50
+ </html>
@@ -0,0 +1,80 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
5
+ <style>
6
+ .container {
7
+ display: flex;
8
+ }
9
+
10
+ .line-numbers {
11
+ padding-right: 0.5em;
12
+ }
13
+
14
+ .line-numbers > a {
15
+ color: #000;
16
+ display: block;
17
+ font-family: monospace;
18
+ text-align: right;
19
+ text-decoration: none;
20
+ }
21
+
22
+ .line-numbers > a.current {
23
+ color: orangered;
24
+ outline: none;
25
+ }
26
+
27
+ .line-numbers > a.current:after {
28
+ content: '';
29
+ position: absolute;
30
+ left: 0;
31
+ right: 100%;
32
+ width: 100vw;
33
+ height: 12px;
34
+ background: #ff9;
35
+ z-index: -1;
36
+ }
37
+
38
+ .the-code {
39
+ flex: 1;
40
+ margin: 0;
41
+ }
42
+
43
+ .hljs {
44
+ background: rgba(0,0,0,0.01);
45
+ padding: 0;
46
+ }
47
+ </style>
48
+ </head>
49
+ <body>
50
+ <div class="container">
51
+ <div class="line-numbers">
52
+ <% 1.upto(@source.lines.size) do |line_number| %>
53
+ <a id="<%= line_number %>" href="#<%= line_number %>" class="line-number"><%= line_number %></a>
54
+ <% end %>
55
+ </div>
56
+ <pre class="the-code hljs javascript"><code><%= @source %></code></pre>
57
+ </div>
58
+ <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js"></script>
59
+ <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/languages/javascript.min.js"></script>
60
+ <script>
61
+ (function() {
62
+ hljs.initHighlightingOnLoad();
63
+
64
+ function selectCurrentLine() {
65
+ var hash = location.hash
66
+ , currentLineNumber = hash.replace(/#/, '');
67
+ Array.prototype.slice.call(document.querySelectorAll('.line-number')).forEach(function(lineNumber) {
68
+ lineNumber.classList.remove('current');
69
+ });
70
+ document.getElementById(currentLineNumber).classList.add('current');
71
+ }
72
+
73
+ if (location.hash) {
74
+ selectCurrentLine();
75
+ }
76
+ window.addEventListener('hashchange', selectCurrentLine);
77
+ }())
78
+ </script>
79
+ </body>
80
+ </html>
@@ -0,0 +1,164 @@
1
+ {
2
+ "ecmaFeatures": {},
3
+ "parser": "espree",
4
+ "env": {
5
+ "browser": false,
6
+ "node": false,
7
+ "amd": false,
8
+ "mocha": false,
9
+ "jasmine": false
10
+ },
11
+
12
+ "rules": {
13
+ "no-alert": 2,
14
+ "no-array-constructor": 2,
15
+ "no-bitwise": 0,
16
+ "no-caller": 2,
17
+ "no-catch-shadow": 2,
18
+ "no-comma-dangle": 0,
19
+ "no-cond-assign": 2,
20
+ "no-console": 2,
21
+ "no-constant-condition": 2,
22
+ "no-control-regex": 2,
23
+ "no-debugger": 2,
24
+ "no-delete-var": 2,
25
+ "no-div-regex": 0,
26
+ "no-dupe-keys": 2,
27
+ "no-dupe-args": 2,
28
+ "no-else-return": 0,
29
+ "no-empty": 2,
30
+ "no-empty-class": 2,
31
+ "no-empty-label": 2,
32
+ "no-eq-null": 0,
33
+ "no-eval": 2,
34
+ "no-ex-assign": 2,
35
+ "no-extend-native": 2,
36
+ "no-extra-bind": 2,
37
+ "no-extra-boolean-cast": 2,
38
+ "no-extra-parens": 0,
39
+ "no-extra-semi": 2,
40
+ "no-extra-strict": 2,
41
+ "no-fallthrough": 2,
42
+ "no-floating-decimal": 0,
43
+ "no-func-assign": 2,
44
+ "no-implied-eval": 2,
45
+ "no-inline-comments": 0,
46
+ "no-inner-declarations": [2, "functions"],
47
+ "no-invalid-regexp": 2,
48
+ "no-irregular-whitespace": 2,
49
+ "no-iterator": 2,
50
+ "no-label-var": 2,
51
+ "no-labels": 2,
52
+ "no-lone-blocks": 2,
53
+ "no-lonely-if": 0,
54
+ "no-loop-func": 2,
55
+ "no-mixed-requires": [0, false],
56
+ "no-mixed-spaces-and-tabs": [2, false],
57
+ "no-multi-spaces": 2,
58
+ "no-multi-str": 2,
59
+ "no-multiple-empty-lines": [0, {"max": 2}],
60
+ "no-native-reassign": 2,
61
+ "no-negated-in-lhs": 2,
62
+ "no-nested-ternary": 0,
63
+ "no-new": 2,
64
+ "no-new-func": 2,
65
+ "no-new-object": 2,
66
+ "no-new-require": 0,
67
+ "no-new-wrappers": 2,
68
+ "no-obj-calls": 2,
69
+ "no-octal": 2,
70
+ "no-octal-escape": 2,
71
+ "no-path-concat": 0,
72
+ "no-plusplus": 0,
73
+ "no-process-env": 0,
74
+ "no-process-exit": 2,
75
+ "no-proto": 2,
76
+ "no-redeclare": 2,
77
+ "no-regex-spaces": 2,
78
+ "no-reserved-keys": 0,
79
+ "no-restricted-modules": 0,
80
+ "no-return-assign": 2,
81
+ "no-script-url": 2,
82
+ "no-self-compare": 0,
83
+ "no-sequences": 2,
84
+ "no-shadow": 2,
85
+ "no-shadow-restricted-names": 2,
86
+ "no-space-before-semi": 0,
87
+ "no-spaced-func": 2,
88
+ "no-sparse-arrays": 2,
89
+ "no-sync": 0,
90
+ "no-ternary": 0,
91
+ "no-trailing-spaces": 2,
92
+ "no-throw-literal": 0,
93
+ "no-undef": 1,
94
+ "no-undef-init": 2,
95
+ "no-undefined": 0,
96
+ "no-underscore-dangle": 2,
97
+ "no-unreachable": 2,
98
+ "no-unused-expressions": 2,
99
+ "no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
100
+ "no-use-before-define": 2,
101
+ "no-void": 0,
102
+ "no-var": 0,
103
+ "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
104
+ "no-with": 2,
105
+ "no-wrap-func": 2,
106
+
107
+ "block-scoped-var": 0,
108
+ "brace-style": [0, "1tbs"],
109
+ "camelcase": 2,
110
+ "comma-dangle": [2, "never"],
111
+ "comma-spacing": 2,
112
+ "comma-style": 0,
113
+ "complexity": [0, 11],
114
+ "consistent-return": 2,
115
+ "consistent-this": [0, "that"],
116
+ "curly": [2, "all"],
117
+ "default-case": 0,
118
+ "dot-notation": [2, { "allowKeywords": true }],
119
+ "eol-last": 2,
120
+ "eqeqeq": 2,
121
+ "func-names": 0,
122
+ "func-style": [0, "declaration"],
123
+ "generator-star": 0,
124
+ "global-strict": [2, "never"],
125
+ "guard-for-in": 0,
126
+ "handle-callback-err": 0,
127
+ "indent": 0,
128
+ "key-spacing": [2, { "beforeColon": false, "afterColon": true }],
129
+ "max-depth": [0, 4],
130
+ "max-len": [0, 80, 4],
131
+ "max-nested-callbacks": [0, 2],
132
+ "max-params": [0, 3],
133
+ "max-statements": [0, 10],
134
+ "new-cap": 2,
135
+ "new-parens": 2,
136
+ "one-var": 0,
137
+ "operator-assignment": [0, "always"],
138
+ "padded-blocks": 0,
139
+ "quote-props": 0,
140
+ "quotes": [1, "double"],
141
+ "radix": 0,
142
+ "semi": 2,
143
+ "semi-spacing": [2, {"before": false, "after": true}],
144
+ "sort-vars": 0,
145
+ "space-after-function-name": [0, "never"],
146
+ "space-after-keywords": [0, "always"],
147
+ "space-before-blocks": [0, "always"],
148
+ "space-before-function-parentheses": [0, "always"],
149
+ "space-in-brackets": [0, "never"],
150
+ "space-in-parens": [0, "never"],
151
+ "space-infix-ops": 2,
152
+ "space-return-throw-case": 2,
153
+ "space-unary-ops": [2, { "words": true, "nonwords": false }],
154
+ "spaced-line-comment": [0, "always"],
155
+ "strict": 2,
156
+ "use-isnan": 2,
157
+ "valid-jsdoc": 0,
158
+ "valid-typeof": 2,
159
+ "vars-on-top": 0,
160
+ "wrap-iife": 0,
161
+ "wrap-regex": 0,
162
+ "yoda": [2, "never"]
163
+ }
164
+ }
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ unless Rails.env.production?
3
+ match '/eslint' => 'eslint#show', via: :get
4
+ match '/eslint/source/:filename' => 'eslint#source', via: :get, as: :eslint_source
5
+ end
6
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eslint-rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'eslint-rails'
8
+ spec.version = ESLintRails::VERSION
9
+ spec.authors = ['Justin Force', 'Jon Kessler']
10
+ spec.email = ['justin.force@appfolio.com', 'jon.kessler@appfolio.com']
11
+ spec.summary = %q{A Rails wrapper for ESLint.}
12
+ spec.description = spec.summary
13
+ spec.homepage = 'https://github.com/appfolio/eslint-rails'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'railties', '>= 3.2'
22
+ spec.add_dependency 'therubyracer'
23
+ spec.add_dependency 'execjs'
24
+ spec.add_dependency 'colorize'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.7'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ end