Skip to content

Commit 45e7697

Browse files
committed
Add configuration for full linting
* Including eslint, jscs, rubocop, ruby-lint, brakeman, bundler-audit
1 parent bd493a2 commit 45e7697

39 files changed

+606
-313
lines changed

Diff for: .rubocop.yml

+6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# This is the configuration used to check the rubocop source code.
2+
# Check out: https://github.com/bbatsov/rubocop
23

34
AllCops:
5+
Include:
6+
- '**/Rakefile'
7+
- '**/config.ru'
48
Exclude:
59
- 'vendor/**/*'
610
- 'spec/fixtures/**/*'
711
- 'node_modules/**/*'
12+
- 'db/**/*'
813
- 'db/schema.rb'
914
- 'db/seeds.rb'
1015
- 'client/node_modules/**/*'
1116
- 'bin/**/*'
17+
- !ruby/regexp /old_and_unused\.rb$/
1218

1319
Metrics/LineLength:
1420
Max: 120

Diff for: .scss-lint.yml

+205
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# See http://sass-guidelin.es/#zeros
2+
3+
scss_files:
4+
- 'app/assets/stylesheets/**/*.scss'
5+
- 'client/assets/stylesheets/**/*.scss'
6+
7+
linters:
8+
# BangFormat:
9+
# enabled: true
10+
# space_before_bang: true
11+
# space_after_bang: false
12+
#
13+
# BorderZero:
14+
# enabled: true
15+
# convention: zero # or `none`
16+
#
17+
ColorKeyword:
18+
enabled: false
19+
ColorVariable:
20+
enabled: false
21+
#
22+
# Comment:
23+
# enabled: true
24+
#
25+
# DebugStatement:
26+
# enabled: true
27+
#
28+
# DeclarationOrder:
29+
# enabled: true
30+
#
31+
# DuplicateProperty:
32+
# enabled: true
33+
#
34+
# ElsePlacement:
35+
# enabled: true
36+
# style: same_line # or 'new_line'
37+
#
38+
# EmptyLineBetweenBlocks:
39+
# enabled: true
40+
# ignore_single_line_blocks: true
41+
#
42+
# EmptyRule:
43+
# enabled: true
44+
#
45+
# FinalNewline:
46+
# enabled: true
47+
# present: true
48+
#
49+
HexLength:
50+
enabled: true
51+
style: long
52+
53+
HexNotation:
54+
enabled: true
55+
style: uppercase
56+
#
57+
# HexValidation:
58+
# enabled: true
59+
#
60+
IdSelector:
61+
enabled: true
62+
#
63+
# ImportantRule:
64+
# enabled: true
65+
#
66+
# ImportPath:
67+
# enabled: true
68+
# leading_underscore: false
69+
# filename_extension: false
70+
#
71+
# Indentation:
72+
# enabled: true
73+
# allow_non_nested_indentation: false
74+
# character: space # or 'tab'
75+
# width: 2
76+
#
77+
LeadingZero:
78+
enabled: true
79+
style: include_zero
80+
#
81+
# MergeableSelector:
82+
# enabled: true
83+
# force_nesting: true
84+
#
85+
# NameFormat:
86+
# enabled: true
87+
# allow_leading_underscore: true
88+
# convention: hyphenated_lowercase # or 'camel_case', or 'snake_case', or a regex pattern
89+
#
90+
# NestingDepth:
91+
# enabled: true
92+
# max_depth: 3
93+
#
94+
# PlaceholderInExtend:
95+
# enabled: true
96+
#
97+
# PropertyCount:
98+
# enabled: false
99+
# include_nested: false
100+
# max_properties: 10
101+
#
102+
# PropertyUnits:
103+
# enabled: true
104+
# global: [
105+
# 'ch', 'em', 'ex', 'rem', # Font-relative lengths
106+
# 'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q', # Absolute lengths
107+
# 'vh', 'vw', 'vmin', 'vmax', # Viewport-percentage lengths
108+
# 'deg', 'grad', 'rad', 'turn', # Angle
109+
# 'ms', 's', # Duration
110+
# 'Hz', 'kHz', # Frequency
111+
# 'dpi', 'dpcm', 'dppx', # Resolution
112+
# '%', # Other
113+
# ]
114+
# properties: {}
115+
#
116+
# PropertySortOrder:
117+
# enabled: true
118+
# ignore_unspecified: false
119+
# separate_groups: false
120+
#
121+
# PropertySpelling:
122+
# enabled: true
123+
# extra_properties: []
124+
#
125+
# QualifyingElement:
126+
# enabled: true
127+
# allow_element_with_attribute: false
128+
# allow_element_with_class: false
129+
# allow_element_with_id: false
130+
#
131+
# SelectorDepth:
132+
# enabled: true
133+
# max_depth: 3
134+
#
135+
# SelectorFormat:
136+
# enabled: true
137+
# convention: hyphenated_lowercase # or 'strict_BEM', or 'hyphenated_BEM', or 'snake_case', or 'camel_case', or a regex pattern
138+
#
139+
# Shorthand:
140+
# enabled: true
141+
# allowed_shorthands: [1, 2, 3]
142+
#
143+
# SingleLinePerProperty:
144+
# enabled: true
145+
# allow_single_line_rule_sets: true
146+
#
147+
# SingleLinePerSelector:
148+
# enabled: true
149+
#
150+
# SpaceAfterComma:
151+
# enabled: true
152+
#
153+
# SpaceAfterPropertyColon:
154+
# enabled: true
155+
# style: one_space # or 'no_space', or 'at_least_one_space', or 'aligned'
156+
#
157+
# SpaceAfterPropertyName:
158+
# enabled: true
159+
#
160+
# SpaceBeforeBrace:
161+
# enabled: true
162+
# style: space # or 'new_line'
163+
# allow_single_line_padding: false
164+
#
165+
# SpaceBetweenParens:
166+
# enabled: true
167+
# spaces: 0
168+
#
169+
# StringQuotes:
170+
# enabled: true
171+
# style: single_quotes # or double_quotes
172+
#
173+
# TrailingSemicolon:
174+
# enabled: true
175+
#
176+
# TrailingZero:
177+
# enabled: false
178+
#
179+
# UnnecessaryMantissa:
180+
# enabled: true
181+
#
182+
# UnnecessaryParentReference:
183+
# enabled: true
184+
#
185+
# UrlFormat:
186+
# enabled: true
187+
#
188+
# UrlQuotes:
189+
# enabled: true
190+
#
191+
# VariableForProperty:
192+
# enabled: false
193+
# properties: []
194+
#
195+
# VendorPrefix:
196+
# enabled: true
197+
# identifier_list: base
198+
# additional_identifiers: []
199+
# excluded_identifiers: []
200+
#
201+
# ZeroUnit:
202+
# enabled: true
203+
#
204+
# Compass::*:
205+
# enabled: false

Diff for: Gemfile

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ group :development, :test do
6262
gem "rubocop", require: false
6363

6464
gem "ruby-lint", require: false
65+
66+
gem "scss-lint", require: false
67+
68+
gem "brakeman", require: false
69+
70+
gem "bundler-audit", require: false
6571
end
6672

6773
gem "spring-commands-rspec", group: :development

Diff for: Gemfile.lock

+30
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,20 @@ GEM
4949
bootstrap-sass (3.3.4.1)
5050
autoprefixer-rails (>= 5.0.0.1)
5151
sass (>= 3.2.19)
52+
brakeman (3.0.3)
53+
erubis (~> 2.6)
54+
fastercsv (~> 1.5)
55+
haml (>= 3.0, < 5.0)
56+
highline (~> 1.6.20)
57+
multi_json (~> 1.2)
58+
ruby2ruby (~> 2.1.1)
59+
ruby_parser (~> 3.6.2)
60+
sass (~> 3.0)
61+
terminal-table (~> 1.4)
5262
builder (3.2.2)
63+
bundler-audit (0.3.1)
64+
bundler (~> 1.2)
65+
thor (~> 0.18)
5366
byebug (4.0.3)
5467
columnize (= 0.9.0)
5568
capybara (2.4.4)
@@ -82,10 +95,14 @@ GEM
8295
factory_girl_rails (4.5.0)
8396
factory_girl (~> 4.5.0)
8497
railties (>= 3.0.0)
98+
fastercsv (1.5.5)
8599
foreman (0.78.0)
86100
thor (~> 0.19.1)
87101
globalid (0.3.3)
88102
activesupport (>= 4.1.0)
103+
haml (4.0.6)
104+
tilt
105+
highline (1.6.21)
89106
hike (1.2.3)
90107
i18n (0.7.0)
91108
jbuilder (2.2.12)
@@ -177,16 +194,25 @@ GEM
177194
parser (~> 2.1, >= 2.1.1)
178195
slop (~> 3.4, >= 3.4.7)
179196
ruby-progressbar (1.7.5)
197+
ruby2ruby (2.1.4)
198+
ruby_parser (~> 3.1)
199+
sexp_processor (~> 4.0)
200+
ruby_parser (3.6.6)
201+
sexp_processor (~> 4.1)
180202
sass (3.4.13)
181203
sass-rails (5.0.1)
182204
railties (>= 4.0.0, < 5.0)
183205
sass (~> 3.1)
184206
sprockets (>= 2.8, < 4.0)
185207
sprockets-rails (>= 2.0, < 4.0)
186208
tilt (~> 1.1)
209+
scss-lint (0.37.0)
210+
rainbow (~> 2.0)
211+
sass (~> 3.4.1)
187212
sdoc (0.4.1)
188213
json (~> 1.7, >= 1.7.7)
189214
rdoc (~> 4.0)
215+
sexp_processor (4.5.1)
190216
slop (3.6.0)
191217
spring (1.3.3)
192218
spring-commands-rspec (1.0.4)
@@ -201,6 +227,7 @@ GEM
201227
activesupport (>= 3.0)
202228
sprockets (>= 2.8, < 4.0)
203229
sqlite3 (1.3.10)
230+
terminal-table (1.4.5)
204231
thor (0.19.1)
205232
thread_safe (0.3.5)
206233
tilt (1.4.1)
@@ -229,6 +256,8 @@ PLATFORMS
229256
DEPENDENCIES
230257
autoprefixer-rails
231258
bootstrap-sass (~> 3.3.1)
259+
brakeman
260+
bundler-audit
232261
byebug
233262
capybara
234263
capybara-screenshot
@@ -248,6 +277,7 @@ DEPENDENCIES
248277
rubocop
249278
ruby-lint
250279
sass-rails
280+
scss-lint
251281
sdoc
252282
spring
253283
spring-commands-rspec

Diff for: README.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ In no particular order:
3737
- Easily enable use of npm modules with a Rails application.
3838
- Easily enable retrofitting such a JS framework into an existing Rails app.
3939
- Enable the use of the JavaScript ES6 transpiler.
40+
- Example setting up Ruby and ES6 linting in a real project.
4041

4142
# Technologies involved
4243

@@ -216,18 +217,6 @@ To deploy the app on Heroku:
216217
git push heroku master
217218
```
218219

219-
# Update Node Modules
220-
```
221-
rm npm-shrinkwrap.json
222-
npm-check-updates -u
223-
npm install
224-
npm shrinkwrap
225-
```
226-
227-
Then confirm that the hot reload server and the rails server both work fine. You
228-
may have to delete `node_modules` and `npm-shrinkwrap.json` and then run `npm
229-
shrinkwrap`.
230-
231220
# Running Tests
232221
*Default rake task runs tests and linting*
233222

@@ -258,14 +247,26 @@ QMAKE=/usr/local/Cellar/qt5/5.4.0/bin/qmake bundle install
258247
Then run `rspec` and you should see the tests have passed.
259248

260249
# Linting and Code Inspection
261-
* Default rake task runs tests and linting (yes, repeating this!)
250+
## Running Lint and CI tasks
251+
* Default rake task runs tests and linting (yes, repeating this!) (see `ci.rake`)
262252
* See file [README.md](client/README.md) for how to run ESLint and JSCS
253+
* See scripts `scripts/lint` and `client/bin/lint`.
263254
* Create a custom scope like this for RubyMine, named "Inspection Scope"
264255

265256
file[react-rails-tutorial]:*/&&!file[react-rails-tutorial]:tmp//*&&!file[react-rails-tutorial]:log//*&&!file[react-rails-tutorial]:client/node_modules//*&&!file[react-rails-tutorial]:client/assets/fonts//*&&!file[react-rails-tutorial]:app/assets/fonts//*&&!file[react-rails-tutorial]:bin//*&&!file[react-rails-tutorial]:app/assets/javascripts//*
266257

267258
* Install the code style and inspection files in [client/jetbrains](client/jetbrains)
268259
* Use the installed inspection settings and new Inspection Scope for code inspection.
260+
* RubyMine configuration is optional. All linters run from the command line.
261+
262+
## Linters
263+
1. [Rubocop](https://github.com/bbatsov/rubocop)
264+
2. [Ruby-Lint](https://github.com/YorickPeterse/ruby-lint)
265+
3. [Eslint](http://eslint.org/)
266+
4. [JSCS](https://github.com/jscs-dev/node-jscs)
267+
5. [scss-lint](https://github.com/brigade/scss-lint)
268+
6. [brakeman](http://brakemanscanner.org/)
269+
7. [bundle-audit](https://github.com/rubysec/bundler-audit)
269270

270271
# Contributors
271272
* [Martin Breining](https://github.com/mbreining)

0 commit comments

Comments
 (0)