Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules

node_modules/
tmp/
public/
client/app/libs/i18n/translations.js
client/app/libs/i18n/default.js
postcss.config.js
47 changes: 47 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
extends:
- eslint-config-shakacode
- plugin:react/recommended
- plugin:prettier/recommended
- plugin:jsx-a11y/recommended
- prettier

plugins:
- react
- jsx-a11y
- jest
- prettier

globals:
__DEBUG_SERVER_ERRORS__: true
__SERVER_ERRORS__: true

env:
browser: true
node: true
jest: true

rules:
no-shadow: 0
no-console: 0
function-paren-newline: 0
object-curly-newline: 0
no-restricted-syntax: ["error", "SequenceExpression"]
# https://stackoverflow.com/a/59268871/5241481
import/extensions: 0

# https://github.com/benmosher/eslint-plugin-import/issues/340
import/no-extraneous-dependencies: 0

prettier/prettier: "error"

# currently deprecated https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/no-onchange.md
jsx-a11y/no-onchange: 0

settings:
import/core-modules:
- react-redux
import/resolver:
node:
extensions: [".js"]
webpack:
config: 'config/webpack/development.js'
32 changes: 0 additions & 32 deletions .eslintrc.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
package.json
tmp/
public/
coverage/
spec/support/
client/app/libs/i18n/translations.js
client/app/libs/i18n/default.js
18 changes: 18 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
printWidth: 110
tabWidth: 2
useTabs: false
semi: true
singleQuote: true
trailingComma: all
bracketSpacing: true

overrides:
- files: "*.@(css|scss)"
options:
parser: css
singleQuote: false
printWidth: 120
- files: "*.@(json)"
options:
parser: json
printWidth: 100
91 changes: 82 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# This is the configuration used to check the rubocop source code.
# Check out: https://github.com/bbatsov/rubocop

require:
- rubocop-performance
- rubocop-rspec
- rubocop-rails

AllCops:
NewCops: enable
DisplayCopNames: true
TargetRubyVersion: 2.7
Include:
- '**/Rakefile'
- '**/config.ru'
- '**/Gemfile'
- 'Gemfile'
- '**/*.rb'
- '**/*.rake'
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
Expand All @@ -17,19 +25,84 @@ AllCops:
- 'db/seeds.rb'
- 'bin/**/*'
- 'Procfile.*'
- !ruby/regexp /old_and_unused\.rb$/

Metrics/LineLength:
Layout/LineLength:
Max: 120

Metrics/MethodLength:
Max: 25

Metrics/BlockLength:
Max: 105

Style/StringLiterals:
EnforcedStyle: double_quotes

Style/Documentation:
Enabled: false

Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

Lint/AssignmentInCondition:
Exclude:
- 'bin/spring'

Lint/SuppressedException:
Exclude:
- 'bin/rails'
- 'bin/rake'

Metrics/AbcSize:
Max: 28

Metrics/CyclomaticComplexity:
Max: 7

Metrics/PerceivedComplexity:
Max: 10

Metrics/ClassLength:
Max: 150

Metrics/BlockLength:
Exclude:
- 'lib/tasks/linters.rake'
- 'spec/rails_helper.rb'
- 'spec/system/add_new_comment_spec.rb'
- 'spec/system/shared/examples.rb'

Metrics/ParameterLists:
Max: 5
CountKeywordArgs: false

Metrics/MethodLength:
Max: 41

Metrics/ModuleLength:
Max: 180

Naming/RescuedExceptionsVariableName:
Enabled: false

RSpec/DescribeClass:
Enabled: false

RSpec/ExampleLength:
Enabled: false

RSpec/MessageSpies:
Enabled: false

RSpec/NestedGroups:
Max: 4

RSpec/MessageChain:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/MultipleMemoizedHelpers:
Max: 12

6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ group :development, :test do

################################################################################
# Linters and Security
gem "rubocop", require: false
gem "ruby-lint", require: false
gem "rubocop", "1.24.1", require: false
gem "rubocop-rspec", "~> 2.7"
gem 'rubocop-rails'
gem "rubocop-performance", "~> 1.13"
# Critical that require: false be set! https://github.com/brigade/scss-lint/issues/278
gem "brakeman", require: false
gem "bundler-audit", require: false
Expand Down
35 changes: 21 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ GEM
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
parallel (1.21.0)
parser (2.7.2.0)
parser (3.1.1.0)
ast (~> 2.4.1)
pg (1.2.3)
pry (0.14.1)
Expand Down Expand Up @@ -259,20 +259,26 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.3)
rubocop (1.7.0)
rubocop (1.24.1)
parallel (~> 1.10)
parser (>= 2.7.1.5)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.2.0, < 2.0)
rubocop-ast (>= 1.15.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.4.1)
parser (>= 2.7.1.5)
ruby-lint (2.3.1)
parser (~> 2.2)
slop (~> 3.4, >= 3.4.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
rubocop-performance (1.13.2)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.13.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.8.0)
rubocop (~> 1.19)
ruby-progressbar (1.11.0)
rubyzip (1.3.0)
sass (3.7.4)
Expand Down Expand Up @@ -309,7 +315,6 @@ GEM
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
slop (3.6.0)
spring (4.0.0)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
Expand All @@ -331,7 +336,7 @@ GEM
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.8.0)
unicode-display_width (2.1.0)
web-console (4.2.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand Down Expand Up @@ -391,8 +396,10 @@ DEPENDENCIES
react_on_rails (= 12.5.2)
redis (= 3.3.3)
rspec-rails
rubocop
ruby-lint
rubocop (= 1.24.1)
rubocop-performance (~> 1.13)
rubocop-rails
rubocop-rspec (~> 2.7)
sass-rails
scss_lint
sdoc
Expand Down
4 changes: 3 additions & 1 deletion app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
// eslint-disable-next-line no-empty,no-lone-blocks
{
}
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/comments_channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CommentsChannel < ApplicationCable::Channel
def subscribed
stream_from "comments"
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CommentsController < ApplicationController
before_action :set_comment, only: %i[show edit update destroy]

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class PagesController < ApplicationController
include ReactOnRails::Controller
before_action :set_comments
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ApplicationHelper
end
4 changes: 3 additions & 1 deletion app/helpers/pages_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true

module PagesHelper
def git_commit_sha
GitCommitSha.current_sha
end

def git_commit_sha_short
full_sha = git_commit_sha
full_sha[-7..-1]
full_sha[-7..]
end
end
2 changes: 2 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
end
2 changes: 2 additions & 0 deletions app/jobs/comment_relay_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CommentRelayJob < ApplicationJob
def perform(comment)
ActionCable.server.broadcast "comments", comment unless comment.destroyed?
Expand Down
2 changes: 2 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Comment < ActiveRecord::Base
validates :author, :text, presence: true
after_commit { CommentRelayJob.perform_later(self) }
Expand Down
Loading