From 491fc2acf46f8fdb30be978917fb0c7c68923a52 Mon Sep 17 00:00:00 2001 From: KareemWilson Date: Mon, 13 Feb 2023 11:24:54 +0200 Subject: [PATCH] Add Linters --- .github/workflows/linters.yml | 44 +++++++++++++++++++++++++ .rubocop.yml | 60 +++++++++++++++++++++++++++++++++++ .stylelintrc.json | 32 +++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 .github/workflows/linters.yml create mode 100644 .rubocop.yml create mode 100644 .stylelintrc.json diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 0000000..82607d6 --- /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-18.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-ruby@v1 + with: + ruby-version: 3.0.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-18.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-18.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/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..8f14e4c --- /dev/null +++ b/.rubocop.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 diff --git a/.stylelintrc.json b/.stylelintrc.json new file mode 100644 index 0000000..7a1e94b --- /dev/null +++ b/.stylelintrc.json @@ -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"] +}