From c64f759fb6934f2f4c0c37aa0a5319edfc91111e Mon Sep 17 00:00:00 2001 From: abdulhamiid Date: Fri, 23 Sep 2022 10:20:31 +0100 Subject: [PATCH] Add linters config --- .github/workflows/linters.yml | 44 +++++++++++++++++++++++++ .gitignore | 3 ++ .robocop.yml | 60 +++++++++++++++++++++++++++++++++++ .stylelintrc | 32 +++++++++++++++++++ Gemfile | 2 ++ Gemfile.lock | 21 ++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 .github/workflows/linters.yml create mode 100644 .robocop.yml create mode 100644 .stylelintrc diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 00000000..44e2e29e --- /dev/null +++ b/.github/workflows/linters.yml @@ -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 stylelint@13.x stylelint-scss@3.x stylelint-config-standard@21.x stylelint-csstree-validator@1.x + [ -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 diff --git a/.gitignore b/.gitignore index e16dc71d..7ca905f7 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,9 @@ !/tmp/storage/ !/tmp/storage/.keep +# ignore node_modules +node_modules/ + /public/assets # Ignore master key for decrypting credentials and more. diff --git a/.robocop.yml b/.robocop.yml new file mode 100644 index 00000000..d8187c3d --- /dev/null +++ b/.robocop.yml @@ -0,0 +1,60 @@ +AllCops: + NewCops: enable + Exclude: + - "db/**/*" + - "bin/*" + - "config/**/*" + - "Guardfile" + - "Rakefile" + - "node_modules/**/*" + + DisplayCopNames: true + +Layout/LineLength: + Max: 120 +Metrics/MethodLength: + Include: + - "app/controllers/*" + - "app/models/*" + Max: 20 +Metrics/AbcSize: + Include: + - "app/controllers/*" + - "app/models/*" + Max: 50 +Metrics/ClassLength: + Max: 150 +Metrics/BlockLength: + IgnoredMethods: ['describe'] + Max: 30 + +Style/Documentation: + Enabled: false +Style/ClassAndModuleChildren: + Enabled: false +Style/EachForSimpleLoop: + Enabled: false +Style/AndOr: + Enabled: false +Style/DefWithParentheses: + Enabled: false +Style/FrozenStringLiteralComment: + EnforcedStyle: never + +Layout/HashAlignment: + EnforcedColonStyle: key +Layout/ExtraSpacing: + AllowForAlignment: false +Layout/MultilineMethodCallIndentation: + Enabled: true + EnforcedStyle: indented +Lint/RaiseException: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Style/HashEachMethods: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: + Enabled: false \ No newline at end of file diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 00000000..5fa8628c --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,32 @@ +{ + "extends": ["stylelint-config-standard"], + "plugins": ["stylelint-scss", "stylelint-csstree-validator"], + "rules": { + "at-rule-no-unknown": [ + true, + { + "ignoreAtRules": [ + "tailwind", + "apply", + "variants", + "responsive", + "screen" + ] + } + ], + "scss/at-rule-no-unknown": [ + true, + { + "ignoreAtRules": [ + "tailwind", + "apply", + "variants", + "responsive", + "screen" + ] + } + ], + "csstree/validator": true + }, + "ignoreFiles": ["build/**", "dist/**", "**/reset*.css", "**/bootstrap*.css"] +} \ No newline at end of file diff --git a/Gemfile b/Gemfile index 98401ae1..86e9c50b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } +gem 'rubocop', '>= 1.0', '< 2.0' + ruby "3.1.2" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" diff --git a/Gemfile.lock b/Gemfile.lock index d2901c7a..91378081 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,7 @@ GEM tzinfo (~> 2.0) addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) bindex (0.8.1) bootsnap (1.13.0) msgpack (~> 1.2) @@ -102,6 +103,7 @@ GEM jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) + json (2.6.2) loofah (2.19.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -130,6 +132,9 @@ GEM nio4r (2.5.8) nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) + parallel (1.22.1) + parser (3.1.2.1) + ast (~> 2.4.1) pg (1.4.3) public_suffix (5.0.0) puma (5.6.5) @@ -164,11 +169,25 @@ GEM rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) + rainbow (3.1.1) rake (13.0.6) regexp_parser (2.5.0) reline (0.3.1) io-console (~> 0.5) rexml (3.2.5) + rubocop (1.36.0) + 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.20.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.21.0) + parser (>= 3.1.1.0) + ruby-progressbar (1.11.0) rubyzip (2.3.2) selenium-webdriver (4.4.0) childprocess (>= 0.5, < 5.0) @@ -193,6 +212,7 @@ GEM railties (>= 6.0.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) + unicode-display_width (2.3.0) web-console (4.2.0) actionview (>= 6.0.0) activemodel (>= 6.0.0) @@ -222,6 +242,7 @@ DEPENDENCIES pg (~> 1.1) puma (~> 5.0) rails (~> 7.0.4) + rubocop (>= 1.0, < 2.0) selenium-webdriver sprockets-rails stimulus-rails