Skip to content

Commit 7feaf74

Browse files
authored
Update Linters (#491)
* Update ESLint and Prettier config, Run prettier * Update rubocop and lint files * Fix Naming/MemoizedInstanceVariableName * Fix Style/TrivialAccessors * Update ESLint and Babel, add prettier * Fix PropType.object * Add rubocop-rails gem and its rule to .rubocop.yml * Run auto fix for ESLint * Fix ESLint Unable to resolve path to module - import/no-unresolved * Fix ESLint Missing file extension - import/extensions * Fix ESLint Ignore "undefined" for global variable added through webpack - no-undef * Fix ESLint - react/forbid-prop-types * Fix ESLint Component definition is missing display name - react/display-name --- ESLint understand the return of functions as new components, so ignoring this rule for this cases seems reasonable * Fix ESLint - react/no-unstable-nested-components * Run auto fix for Prettier * Fix test.js Webpack config
1 parent c91332f commit 7feaf74

File tree

109 files changed

+1434
-1243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1434
-1243
lines changed

.eslintignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
node_modules
2-
1+
node_modules/
2+
tmp/
3+
public/
34
client/app/libs/i18n/translations.js
45
client/app/libs/i18n/default.js
6+
postcss.config.js

.eslintrc

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
extends:
2+
- eslint-config-shakacode
3+
- plugin:react/recommended
4+
- plugin:prettier/recommended
5+
- plugin:jsx-a11y/recommended
6+
- prettier
7+
8+
plugins:
9+
- react
10+
- jsx-a11y
11+
- jest
12+
- prettier
13+
14+
globals:
15+
__DEBUG_SERVER_ERRORS__: true
16+
__SERVER_ERRORS__: true
17+
18+
env:
19+
browser: true
20+
node: true
21+
jest: true
22+
23+
rules:
24+
no-shadow: 0
25+
no-console: 0
26+
function-paren-newline: 0
27+
object-curly-newline: 0
28+
no-restricted-syntax: ["error", "SequenceExpression"]
29+
# https://stackoverflow.com/a/59268871/5241481
30+
import/extensions: 0
31+
32+
# https://github.com/benmosher/eslint-plugin-import/issues/340
33+
import/no-extraneous-dependencies: 0
34+
35+
prettier/prettier: "error"
36+
37+
# currently deprecated https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/no-onchange.md
38+
jsx-a11y/no-onchange: 0
39+
40+
settings:
41+
import/core-modules:
42+
- react-redux
43+
import/resolver:
44+
node:
45+
extensions: [".js"]
46+
webpack:
47+
config: 'config/webpack/development.js'

.eslintrc.yml

-32
This file was deleted.

.prettierignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
package.json
3+
tmp/
4+
public/
5+
coverage/
6+
spec/support/
7+
client/app/libs/i18n/translations.js
8+
client/app/libs/i18n/default.js

.prettierrc.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
printWidth: 110
2+
tabWidth: 2
3+
useTabs: false
4+
semi: true
5+
singleQuote: true
6+
trailingComma: all
7+
bracketSpacing: true
8+
9+
overrides:
10+
- files: "*.@(css|scss)"
11+
options:
12+
parser: css
13+
singleQuote: false
14+
printWidth: 120
15+
- files: "*.@(json)"
16+
options:
17+
parser: json
18+
printWidth: 100

.rubocop.yml

+82-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# This is the configuration used to check the rubocop source code.
22
# Check out: https://github.com/bbatsov/rubocop
33

4+
require:
5+
- rubocop-performance
6+
- rubocop-rspec
7+
- rubocop-rails
8+
49
AllCops:
10+
NewCops: enable
511
DisplayCopNames: true
612
TargetRubyVersion: 2.7
713
Include:
814
- '**/Rakefile'
915
- '**/config.ru'
10-
- '**/Gemfile'
16+
- 'Gemfile'
17+
- '**/*.rb'
18+
- '**/*.rake'
1119
Exclude:
1220
- 'vendor/**/*'
1321
- 'spec/fixtures/**/*'
@@ -17,19 +25,84 @@ AllCops:
1725
- 'db/seeds.rb'
1826
- 'bin/**/*'
1927
- 'Procfile.*'
20-
- !ruby/regexp /old_and_unused\.rb$/
2128

22-
Metrics/LineLength:
29+
Layout/LineLength:
2330
Max: 120
2431

25-
Metrics/MethodLength:
26-
Max: 25
27-
28-
Metrics/BlockLength:
29-
Max: 105
30-
3132
Style/StringLiterals:
3233
EnforcedStyle: double_quotes
3334

3435
Style/Documentation:
3536
Enabled: false
37+
38+
Style/HashEachMethods:
39+
Enabled: true
40+
41+
Style/HashTransformKeys:
42+
Enabled: true
43+
44+
Style/HashTransformValues:
45+
Enabled: true
46+
47+
Lint/AssignmentInCondition:
48+
Exclude:
49+
- 'bin/spring'
50+
51+
Lint/SuppressedException:
52+
Exclude:
53+
- 'bin/rails'
54+
- 'bin/rake'
55+
56+
Metrics/AbcSize:
57+
Max: 28
58+
59+
Metrics/CyclomaticComplexity:
60+
Max: 7
61+
62+
Metrics/PerceivedComplexity:
63+
Max: 10
64+
65+
Metrics/ClassLength:
66+
Max: 150
67+
68+
Metrics/BlockLength:
69+
Exclude:
70+
- 'lib/tasks/linters.rake'
71+
- 'spec/rails_helper.rb'
72+
- 'spec/system/add_new_comment_spec.rb'
73+
- 'spec/system/shared/examples.rb'
74+
75+
Metrics/ParameterLists:
76+
Max: 5
77+
CountKeywordArgs: false
78+
79+
Metrics/MethodLength:
80+
Max: 41
81+
82+
Metrics/ModuleLength:
83+
Max: 180
84+
85+
Naming/RescuedExceptionsVariableName:
86+
Enabled: false
87+
88+
RSpec/DescribeClass:
89+
Enabled: false
90+
91+
RSpec/ExampleLength:
92+
Enabled: false
93+
94+
RSpec/MessageSpies:
95+
Enabled: false
96+
97+
RSpec/NestedGroups:
98+
Max: 4
99+
100+
RSpec/MessageChain:
101+
Enabled: false
102+
103+
RSpec/MultipleExpectations:
104+
Enabled: false
105+
106+
RSpec/MultipleMemoizedHelpers:
107+
Max: 12
108+

Gemfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ group :development, :test do
7171

7272
################################################################################
7373
# Linters and Security
74-
gem "rubocop", require: false
75-
gem "ruby-lint", require: false
74+
gem "rubocop", "1.24.1", require: false
75+
gem "rubocop-rspec", "~> 2.7"
76+
gem 'rubocop-rails'
77+
gem "rubocop-performance", "~> 1.13"
7678
# Critical that require: false be set! https://github.com/brigade/scss-lint/issues/278
7779
gem "brakeman", require: false
7880
gem "bundler-audit", require: false

Gemfile.lock

+21-14
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ GEM
162162
mini_portile2 (~> 2.6.1)
163163
racc (~> 1.4)
164164
parallel (1.21.0)
165-
parser (2.7.2.0)
165+
parser (3.1.1.0)
166166
ast (~> 2.4.1)
167167
pg (1.2.3)
168168
pry (0.14.1)
@@ -259,20 +259,26 @@ GEM
259259
rspec-mocks (~> 3.10)
260260
rspec-support (~> 3.10)
261261
rspec-support (3.10.3)
262-
rubocop (1.7.0)
262+
rubocop (1.24.1)
263263
parallel (~> 1.10)
264-
parser (>= 2.7.1.5)
264+
parser (>= 3.0.0.0)
265265
rainbow (>= 2.2.2, < 4.0)
266266
regexp_parser (>= 1.8, < 3.0)
267267
rexml
268-
rubocop-ast (>= 1.2.0, < 2.0)
268+
rubocop-ast (>= 1.15.1, < 2.0)
269269
ruby-progressbar (~> 1.7)
270-
unicode-display_width (>= 1.4.0, < 2.0)
271-
rubocop-ast (1.4.1)
272-
parser (>= 2.7.1.5)
273-
ruby-lint (2.3.1)
274-
parser (~> 2.2)
275-
slop (~> 3.4, >= 3.4.7)
270+
unicode-display_width (>= 1.4.0, < 3.0)
271+
rubocop-ast (1.16.0)
272+
parser (>= 3.1.1.0)
273+
rubocop-performance (1.13.2)
274+
rubocop (>= 1.7.0, < 2.0)
275+
rubocop-ast (>= 0.4.0)
276+
rubocop-rails (2.13.2)
277+
activesupport (>= 4.2.0)
278+
rack (>= 1.1)
279+
rubocop (>= 1.7.0, < 2.0)
280+
rubocop-rspec (2.8.0)
281+
rubocop (~> 1.19)
276282
ruby-progressbar (1.11.0)
277283
rubyzip (1.3.0)
278284
sass (3.7.4)
@@ -309,7 +315,6 @@ GEM
309315
json (>= 1.8, < 3)
310316
simplecov-html (~> 0.10.0)
311317
simplecov-html (0.10.2)
312-
slop (3.6.0)
313318
spring (4.0.0)
314319
spring-commands-rspec (1.0.4)
315320
spring (>= 0.9.1)
@@ -331,7 +336,7 @@ GEM
331336
concurrent-ruby (~> 1.0)
332337
uglifier (4.2.0)
333338
execjs (>= 0.3.0, < 3)
334-
unicode-display_width (1.8.0)
339+
unicode-display_width (2.1.0)
335340
web-console (4.2.0)
336341
actionview (>= 6.0.0)
337342
activemodel (>= 6.0.0)
@@ -391,8 +396,10 @@ DEPENDENCIES
391396
react_on_rails (= 12.5.2)
392397
redis (= 3.3.3)
393398
rspec-rails
394-
rubocop
395-
ruby-lint
399+
rubocop (= 1.24.1)
400+
rubocop-performance (~> 1.13)
401+
rubocop-rails
402+
rubocop-rspec (~> 2.7)
396403
sass-rails
397404
scss_lint
398405
sdoc

app/assets/config/manifest.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
// eslint-disable-next-line no-empty,no-lone-blocks
2+
{
3+
}

app/channels/application_cable/channel.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationCable
24
class Channel < ActionCable::Channel::Base
35
end

app/channels/application_cable/connection.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationCable
24
class Connection < ActionCable::Connection::Base
35
end

app/channels/comments_channel.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class CommentsChannel < ApplicationCable::Channel
24
def subscribed
35
stream_from "comments"

app/controllers/application_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationController < ActionController::Base
24
# Prevent CSRF attacks by raising an exception.
35
# For APIs, you may want to use :null_session instead.

app/controllers/comments_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class CommentsController < ApplicationController
24
before_action :set_comment, only: %i[show edit update destroy]
35

app/controllers/pages_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class PagesController < ApplicationController
24
include ReactOnRails::Controller
35
before_action :set_comments

app/helpers/application_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationHelper
24
end

app/helpers/pages_helper.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# frozen_string_literal: true
2+
13
module PagesHelper
24
def git_commit_sha
35
GitCommitSha.current_sha
46
end
57

68
def git_commit_sha_short
79
full_sha = git_commit_sha
8-
full_sha[-7..-1]
10+
full_sha[-7..]
911
end
1012
end

app/jobs/application_job.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationJob < ActiveJob::Base
24
end

app/jobs/comment_relay_job.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class CommentRelayJob < ApplicationJob
24
def perform(comment)
35
ActionCable.server.broadcast "comments", comment unless comment.destroyed?

app/models/comment.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class Comment < ActiveRecord::Base
24
validates :author, :text, presence: true
35
after_commit { CommentRelayJob.perform_later(self) }

0 commit comments

Comments
 (0)