Skip to content

Commit 0e76ba9

Browse files
committed
Add linters
1 parent c31a3c2 commit 0e76ba9

File tree

14 files changed

+5187
-179
lines changed

14 files changed

+5187
-179
lines changed

.github/workflows/linters.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Linters
2+
3+
on: pull_request
4+
5+
env:
6+
FORCE_COLOR: 1
7+
8+
jobs:
9+
rubocop:
10+
name: Rubocop
11+
runs-on: ubuntu-18.04
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-ruby@v1
15+
with:
16+
ruby-version: 3.0.x
17+
- name: Setup Rubocop
18+
run: |
19+
gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/
20+
[ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.rubocop.yml
21+
- name: Rubocop Report
22+
run: rubocop --color
23+
stylelint:
24+
name: Stylelint
25+
runs-on: ubuntu-18.04
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: actions/setup-node@v1
29+
with:
30+
node-version: "12.x"
31+
- name: Setup Stylelint
32+
run: |
33+
34+
[ -f .stylelintrc.json ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.stylelintrc.json
35+
- name: Stylelint Report
36+
run: npx stylelint "**/*.{css,scss}"

.rubocop.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
AllCops:
2+
NewCops: enable
3+
Exclude:
4+
- "db/**/*"
5+
- "bin/*"
6+
- "config/**/*"
7+
- "Guardfile"
8+
- "Rakefile"
9+
- "node_modules/**/*"
10+
11+
DisplayCopNames: true
12+
13+
Layout/LineLength:
14+
Max: 120
15+
Metrics/MethodLength:
16+
Include:
17+
- "app/controllers/*"
18+
- "app/models/*"
19+
Max: 20
20+
Metrics/AbcSize:
21+
Include:
22+
- "app/controllers/*"
23+
- "app/models/*"
24+
Max: 50
25+
Metrics/ClassLength:
26+
Max: 150
27+
Metrics/BlockLength:
28+
IgnoredMethods: ['describe']
29+
Max: 30
30+
31+
Style/Documentation:
32+
Enabled: false
33+
Style/ClassAndModuleChildren:
34+
Enabled: false
35+
Style/EachForSimpleLoop:
36+
Enabled: false
37+
Style/AndOr:
38+
Enabled: false
39+
Style/DefWithParentheses:
40+
Enabled: false
41+
Style/FrozenStringLiteralComment:
42+
EnforcedStyle: never
43+
44+
Layout/HashAlignment:
45+
EnforcedColonStyle: key
46+
Layout/ExtraSpacing:
47+
AllowForAlignment: false
48+
Layout/MultilineMethodCallIndentation:
49+
Enabled: true
50+
EnforcedStyle: indented
51+
Lint/RaiseException:
52+
Enabled: false
53+
Lint/StructNewOverride:
54+
Enabled: false
55+
Style/HashEachMethods:
56+
Enabled: false
57+
Style/HashTransformKeys:
58+
Enabled: false
59+
Style/HashTransformValues:
60+
Enabled: false

.stylelintrc.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"extends": ["stylelint-config-standard"],
3+
"plugins": ["stylelint-scss", "stylelint-csstree-validator"],
4+
"rules": {
5+
"at-rule-no-unknown": [
6+
true,
7+
{
8+
"ignoreAtRules": [
9+
"tailwind",
10+
"apply",
11+
"variants",
12+
"responsive",
13+
"screen"
14+
]
15+
}
16+
],
17+
"scss/at-rule-no-unknown": [
18+
true,
19+
{
20+
"ignoreAtRules": [
21+
"tailwind",
22+
"apply",
23+
"variants",
24+
"responsive",
25+
"screen"
26+
]
27+
}
28+
],
29+
"csstree/validator": true
30+
},
31+
"ignoreFiles": ["build/**", "dist/**", "**/reset*.css", "**/bootstrap*.css"]
32+
}

Gemfile

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,42 @@
1-
source "https://rubygems.org"
1+
source 'https://rubygems.org'
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
ruby "3.0.3"
4+
ruby '3.0.3'
55

66
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
7-
gem "rails", "~> 7.0.2", ">= 7.0.2.4"
7+
gem 'rails', '~> 7.0.2', '>= 7.0.2.4'
88

99
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
10-
gem "sprockets-rails"
10+
gem 'sprockets-rails'
1111

1212
# Use postgresql as the database for Active Record
13-
gem "pg", "~> 1.1"
13+
gem 'pg', '~> 1.1'
1414

1515
# Use the Puma web server [https://github.com/puma/puma]
16-
gem "puma", "~> 5.0"
16+
gem 'puma', '~> 5.0'
1717

1818
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
19-
gem "importmap-rails"
19+
gem 'importmap-rails'
2020

2121
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
22-
gem "turbo-rails"
22+
gem 'turbo-rails'
2323

2424
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
25-
gem "stimulus-rails"
25+
gem 'stimulus-rails'
2626

2727
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
28-
gem "jbuilder"
28+
gem 'jbuilder'
2929

3030
# Add webpacker and react-rails gems
31-
gem 'webpacker'
3231
gem 'react-rails'
32+
gem 'webpacker'
3333

3434
# Add rdoc gem, because rails c doesn't run
3535
gem 'rdoc'
3636

37+
# Add rubocop
38+
gem 'rubocop', '>= 1.0', '< 2.0'
39+
3740
# Use Redis adapter to run Action Cable in production
3841
# gem "redis", "~> 4.0"
3942

@@ -44,10 +47,10 @@ gem 'rdoc'
4447
# gem "bcrypt", "~> 3.1.7"
4548

4649
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
47-
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
50+
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
4851

4952
# Reduces boot times through caching; required in config/boot.rb
50-
gem "bootsnap", require: false
53+
gem 'bootsnap', require: false
5154

5255
# Use Sass to process CSS
5356
# gem "sassc-rails"
@@ -57,17 +60,16 @@ gem "bootsnap", require: false
5760

5861
group :development, :test do
5962
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
60-
gem "debug", platforms: %i[ mri mingw x64_mingw ]
63+
gem 'debug', platforms: %i[mri mingw x64_mingw]
6164
end
6265

6366
group :development do
6467
# Use console on exceptions pages [https://github.com/rails/web-console]
65-
gem "web-console"
68+
gem 'web-console'
6669

6770
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
6871
# gem "rack-mini-profiler"
6972

7073
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
7174
# gem "spring"
7275
end
73-

Gemfile.lock

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ GEM
6666
i18n (>= 1.6, < 2)
6767
minitest (>= 5.1)
6868
tzinfo (~> 2.0)
69+
ast (2.4.2)
6970
babel-source (5.8.35)
7071
babel-transpiler (0.7.0)
7172
babel-source (>= 4.0, < 6)
@@ -123,6 +124,9 @@ GEM
123124
nio4r (2.5.8)
124125
nokogiri (1.13.4-x86_64-linux)
125126
racc (~> 1.4)
127+
parallel (1.22.1)
128+
parser (3.1.2.0)
129+
ast (~> 2.4.1)
126130
pg (1.3.5)
127131
psych (4.0.3)
128132
stringio
@@ -160,6 +164,7 @@ GEM
160164
rake (>= 12.2)
161165
thor (~> 1.0)
162166
zeitwerk (~> 2.5)
167+
rainbow (3.1.1)
163168
rake (13.0.6)
164169
rdoc (6.4.0)
165170
psych (>= 4.0.0)
@@ -169,8 +174,22 @@ GEM
169174
execjs
170175
railties (>= 3.2)
171176
tilt
177+
regexp_parser (2.3.1)
172178
reline (0.3.1)
173179
io-console (~> 0.5)
180+
rexml (3.2.5)
181+
rubocop (1.28.2)
182+
parallel (~> 1.10)
183+
parser (>= 3.1.0.0)
184+
rainbow (>= 2.2.2, < 4.0)
185+
regexp_parser (>= 1.8, < 3.0)
186+
rexml
187+
rubocop-ast (>= 1.17.0, < 2.0)
188+
ruby-progressbar (~> 1.7)
189+
unicode-display_width (>= 1.4.0, < 3.0)
190+
rubocop-ast (1.17.0)
191+
parser (>= 3.1.1.0)
192+
ruby-progressbar (1.11.0)
174193
semantic_range (3.0.0)
175194
sprockets (4.0.3)
176195
concurrent-ruby (~> 1.0)
@@ -191,6 +210,7 @@ GEM
191210
railties (>= 6.0.0)
192211
tzinfo (2.0.4)
193212
concurrent-ruby (~> 1.0)
213+
unicode-display_width (2.1.0)
194214
web-console (4.2.0)
195215
actionview (>= 6.0.0)
196216
activemodel (>= 6.0.0)
@@ -219,6 +239,7 @@ DEPENDENCIES
219239
rails (~> 7.0.2, >= 7.0.2.4)
220240
rdoc
221241
react-rails
242+
rubocop (>= 1.0, < 2.0)
222243
sprockets-rails
223244
stimulus-rails
224245
turbo-rails

app/assets/stylesheets/application.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ body {
44

55
.container,
66
.greetings {
7-
display:flex;
8-
flex-direction:column;
7+
display: flex;
8+
flex-direction: column;
99
align-items: center;
1010
}
1111

@@ -21,8 +21,10 @@ body {
2121
cursor: pointer;
2222
font-size: 1.5rem;
2323
margin-top: 2rem;
24+
box-shadow: 4px 4px 6px #b8b8b8;
2425
}
2526

2627
.link:hover {
2728
background-color: #268bc5;
29+
box-shadow: 2px 2px 3px #868686;
2830
}

app/controllers/static_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
class StaticController < ApplicationController
2-
def index
3-
end
2+
def index; end
43
end

app/javascript/components/Greeting.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const Greeting =() => {
1313
<div className="greetings">
1414
<h1>Rails React Demo App</h1>
1515
<h2 className="text">{ greeting }</h2>
16-
<button onClick={() => dispatch(fetchGreetingApi())} className="link">Get another greeting</button>
17-
<a href="/" className="link">Home</a>
16+
<a onClick={() => dispatch(fetchGreetingApi())} className="link">Get another greeting</a>
17+
<a onClick={() => {window.location.href="/"}} className="link">Home</a>
1818
</div>
1919
);
2020
}

app/javascript/components/Home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Home extends React.Component {
66
<React.Fragment>
77
<div className='container'>
88
<h1>Rails React Demo App</h1>
9-
<a href="/hello" className="link">Greetings</a>
9+
<a onClick={() => {window.location.href="/hello"}} className="link">Greetings</a>
1010
</div>
1111
</React.Fragment>
1212
);

app/mailers/application_mailer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class ApplicationMailer < ActionMailer::Base
2-
default from: "[email protected]"
3-
layout "mailer"
2+
default from: '[email protected]'
3+
layout 'mailer'
44
end

config.ru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is used by Rack-based servers to start the application.
22

3-
require_relative "config/environment"
3+
require_relative 'config/environment'
44

55
run Rails.application
66
Rails.application.load_server

0 commit comments

Comments
 (0)