Skip to content

Commit

Permalink
Add linters config
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulhamiid committed Oct 25, 2022
1 parent 352c0f0 commit c79ea9e
Show file tree
Hide file tree
Showing 63 changed files with 591 additions and 317 deletions.
22 changes: 22 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"env": {
"browser": true,
"es6": true,
"jest": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": ["airbnb-base"],
"rules": {
"no-shadow": "off",
"no-param-reassign": "off",
"eol-last": "off"
},
"ignorePatterns": [
"dist/",
"build/"
]
}
44 changes: 44 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Linters

on: pull_request

env:
FORCE_COLOR: 1

jobs:
rubocop:
name: Rubocop
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: 3.1.x
- name: Setup Rubocop
run: |
gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/
[ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.rubocop.yml
- name: Rubocop Report
run: rubocop --color
stylelint:
name: Stylelint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Setup Stylelint
run: |
npm install --save-dev [email protected] [email protected] [email protected] [email protected]
[ -f .stylelintrc.json ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.stylelintrc.json
- name: Stylelint Report
run: npx stylelint "**/*.{css,scss}"
nodechecker:
name: node_modules checker
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Check node_modules existence
run: |
if [ -d "node_modules/" ]; then echo -e "\e[1;31mThe node_modules/ folder was pushed to the repo. Please remove it from the GitHub repository and try again."; echo -e "\e[1;32mYou can set up a .gitignore file with this folder included on it to prevent this from happening in the future." && exit 1; fi
41 changes: 22 additions & 19 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.1.2"
ruby '3.1.2'

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.4"
gem 'rails', '~> 7.0.4'

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

# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"
gem 'pg', '~> 1.1'

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

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

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

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

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
gem 'jbuilder'

# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"
Expand All @@ -37,10 +39,10 @@ gem "jbuilder"
# gem "bcrypt", "~> 3.1.7"

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

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
gem 'bootsnap', require: false

# Use Sass to process CSS
# gem "sassc-rails"
Expand All @@ -50,12 +52,12 @@ gem "bootsnap", require: false

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

group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
gem 'web-console'

gem 'letter_opener'
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
Expand All @@ -67,12 +69,13 @@ end

group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
gem 'capybara'
gem 'selenium-webdriver'
gem 'webdrivers'
end

gem 'devise'
gem 'bootstrap', '~> 5.2.2'
gem 'bootstrap_form', '~> 5.1'
gem 'devise'
gem 'jquery-rails'
gem "bootstrap_form", "~> 5.1"
gem 'rubocop', '>= 1.0', '< 2.0'
21 changes: 21 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
autoprefixer-rails (10.4.7.0)
execjs (~> 2)
bcrypt (3.1.18)
Expand Down Expand Up @@ -123,6 +124,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.6.2)
launchy (2.5.0)
addressable (~> 2.7)
letter_opener (1.8.1)
Expand Down Expand Up @@ -150,6 +152,9 @@ GEM
nokogiri (1.13.9-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
pg (1.4.4)
popper_js (2.11.6)
public_suffix (5.0.0)
Expand Down Expand Up @@ -185,6 +190,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.6.0)
reline (0.3.1)
Expand All @@ -193,6 +199,19 @@ GEM
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
rubocop (1.37.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.23.0)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
Expand Down Expand Up @@ -225,6 +244,7 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.3.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0)
Expand Down Expand Up @@ -261,6 +281,7 @@ DEPENDENCIES
pg (~> 1.1)
puma (~> 5.0)
rails (~> 7.0.4)
rubocop (>= 1.0, < 2.0)
selenium-webdriver
sprockets-rails
stimulus-rails
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative "config/application"
require_relative 'config/application'

Rails.application.load_tasks
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: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class ApplicationController < ActionController::Base
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
end
end
end
29 changes: 14 additions & 15 deletions app/controllers/entities_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class EntitiesController < ApplicationController
before_action :set_entity, only: %i[ show destroy ]
before_action :set_entity, only: %i[show destroy]

# GET /entities or /entities.json
def index
Expand All @@ -8,8 +8,7 @@ def index
end

# GET /entities/1 or /entities/1.json
def show
end
def show; end

# GET /entities/new
def new
Expand All @@ -19,8 +18,7 @@ def new
end

# GET /entities/1/edit
def edit
end
def edit; end

# POST /entities or /entities.json
def create
Expand All @@ -31,7 +29,7 @@ def create

respond_to do |format|
if @entity.save
format.html { redirect_to group_path(@entity.group_id), notice: "Transaction was successfully created." }
format.html { redirect_to group_path(@entity.group_id), notice: 'Transaction was successfully created.' }
format.json { render :show, status: :created, location: @entity }
else
format.html { render :new, status: :unprocessable_entity }
Expand All @@ -45,19 +43,20 @@ def destroy
@entity.destroy

respond_to do |format|
format.html { redirect_to entities_url, notice: "Transaction was successfully destroyed." }
format.html { redirect_to entities_url, notice: 'Transaction was successfully destroyed.' }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_entity
@entity = Entity.find(params[:id])
end

# Only allow a list of trusted parameters through.
def entity_params
params.require(:entity).permit(:name, :amount)
end
# Use callbacks to share common setup or constraints between actions.
def set_entity
@entity = Entity.find(params[:id])
end

# Only allow a list of trusted parameters through.
def entity_params
params.require(:entity).permit(:name, :amount)
end
end
29 changes: 14 additions & 15 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
class GroupsController < ApplicationController
before_action :set_group, only: %i[ show destroy ]
before_action :set_group, only: %i[show destroy]

# GET /groups or /groups.json
def index
@groups = current_user.groups.all
end

# GET /groups/1 or /groups/1.json
def show
end
def show; end

# GET /groups/new
def new
@group = current_user.groups.new
end

# GET /groups/1/edit
def edit
end
def edit; end

# POST /groups or /groups.json
def create
Expand All @@ -26,7 +24,7 @@ def create

respond_to do |format|
if @group.save
format.html { redirect_to group_url(@group), notice: "Category was successfully created." }
format.html { redirect_to group_url(@group), notice: 'Category was successfully created.' }
format.json { render :show, status: :created, location: @group }
else
format.html { render :new, status: :unprocessable_entity }
Expand All @@ -40,19 +38,20 @@ def destroy
@group.destroy

respond_to do |format|
format.html { redirect_to groups_url, notice: "Category was successfully destroyed." }
format.html { redirect_to groups_url, notice: 'Category was successfully destroyed.' }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_group
@group = Group.find(params[:id])
end

# Only allow a list of trusted parameters through.
def group_params
params.require(:group).permit(:name, :icon)
end
# Use callbacks to share common setup or constraints between actions.
def set_group
@group = Group.find(params[:id])
end

# Only allow a list of trusted parameters through.
def group_params
params.require(:group).permit(:name, :icon)
end
end
Loading

0 comments on commit c79ea9e

Please sign in to comment.