From e990f7608449d4c174539d1bfada06d6714a461d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Bol=C3=ADvar?= Date: Mon, 30 Oct 2023 15:48:41 +0100 Subject: [PATCH] Lint --- .erb-lint.yml | 30 +++++++++++++++++ .eslintrc.json | 3 ++ .github/workflows/lint.yml | 15 ++++++--- app/packs/src/decidim/decidim_application.js | 2 ++ .../stylesheets/catencomu/partials/_body.scss | 2 +- .../catencomu/partials/_cards.scss | 2 +- .../catencomu/partials/_footer.scss | 7 ++-- .../catencomu/partials/_links.scss | 32 ++++++++++++++++++- .../catencomu/partials/_login.scss | 9 +++--- .../catencomu/partials/_navbar.scss | 17 +++++----- .../catencomu/partials/_variables.scss | 4 +-- .../decidim/catcomu_managers/user_override.rb | 2 ++ .../catcomu_managers/admin/managers.js | 11 ++++--- .../catcomu_managers/admin/managers.scss | 2 ++ package.json | 12 +++++++ 15 files changed, 121 insertions(+), 29 deletions(-) create mode 100644 .erb-lint.yml create mode 100644 .eslintrc.json diff --git a/.erb-lint.yml b/.erb-lint.yml new file mode 100644 index 0000000..3321add --- /dev/null +++ b/.erb-lint.yml @@ -0,0 +1,30 @@ +--- + +linters: + ExtraNewline: + enabled: true + + FinalNewline: + enabled: true + + SpaceAroundErbTag: + enabled: true + + AllowedScriptType: + enabled: true + allowed_types: + - text/javascript + - text/template + + Rubocop: + enabled: true + + rubocop_config: + AllCops: + DisabledByDefault: true + + Style/StringLiterals: + EnforcedStyle: double_quotes + + Layout/SpaceInsideHashLiteralBraces: + Enabled: true diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..08de8c7 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "@decidim" +} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1145d1d..428049b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,13 +28,20 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} + - run: npm ci + name: Install JS deps + - run: bundle exec rubocop -P name: Lint Ruby files - run: bundle exec mdl *.md name: Lint Markdown files - - name: Lint and Rubocop - run: | - bundle exec rubocop -P - bundle exec erblint app/**/*.erb + - run: bundle exec erblint {decidim-module-catcomu_managers/,}app/{cells,views}/**/*.erb + name: Lint ERB files + + - run: npm run stylelint + name: Lint SCSS files + + - run: npm run lint + name: Lint JS files diff --git a/app/packs/src/decidim/decidim_application.js b/app/packs/src/decidim/decidim_application.js index e55acc6..f76cd04 100644 --- a/app/packs/src/decidim/decidim_application.js +++ b/app/packs/src/decidim/decidim_application.js @@ -3,4 +3,6 @@ // Load images require.context("../../images", true) + +// Load fonts require.context("../../fonts", true) diff --git a/app/packs/stylesheets/catencomu/partials/_body.scss b/app/packs/stylesheets/catencomu/partials/_body.scss index 010886a..f394c88 100644 --- a/app/packs/stylesheets/catencomu/partials/_body.scss +++ b/app/packs/stylesheets/catencomu/partials/_body.scss @@ -31,7 +31,7 @@ h4, h5, .h5, h6, -.h6{ +.h6 { font-family: 'Montserrat Bold', sans-serif; font-style: normal; font-weight: normal; diff --git a/app/packs/stylesheets/catencomu/partials/_cards.scss b/app/packs/stylesheets/catencomu/partials/_cards.scss index d17bb0e..1b4880f 100644 --- a/app/packs/stylesheets/catencomu/partials/_cards.scss +++ b/app/packs/stylesheets/catencomu/partials/_cards.scss @@ -6,4 +6,4 @@ &:hover { color: $card-link-hover; } -} \ No newline at end of file +} diff --git a/app/packs/stylesheets/catencomu/partials/_footer.scss b/app/packs/stylesheets/catencomu/partials/_footer.scss index 8a96682..73b7b87 100644 --- a/app/packs/stylesheets/catencomu/partials/_footer.scss +++ b/app/packs/stylesheets/catencomu/partials/_footer.scss @@ -3,18 +3,19 @@ .main-footer { @include gradient-background($catencomu-red, $catencomu-lilac); - + a { color: $link-color; } + .main-footer__badge { position: unset; } } -.mini-footer{ +.mini-footer { @include gradient-background($catencomu-red, $catencomu-lilac); - + a { color: $link-color; } diff --git a/app/packs/stylesheets/catencomu/partials/_links.scss b/app/packs/stylesheets/catencomu/partials/_links.scss index d64c313..415777e 100644 --- a/app/packs/stylesheets/catencomu/partials/_links.scss +++ b/app/packs/stylesheets/catencomu/partials/_links.scss @@ -4,47 +4,60 @@ .cookie-warning a { color: var(--secondary); } + .button.hollow.secondary:hover, .button.hollow.secondary:focus { color: var(--secondary); } + .floating-helper__text { color: var(--secondary); } + .floating-helper__icon { background-color: var(--secondary); } + .global-accountability .row.column .card--accountability .card__content ul a, .global-accountability .row.columns .card--accountability .card__content ul a, .global-accountability .row.column .card--accountability .badge-card__content ul a, .global-accountability .row.columns .card--accountability .badge-card__content ul a { color: var(--secondary); } + .topbar__dropmenu .is-dropdown-submenu li a { color: var(--secondary); } + .svg-icon-path { - color: var(--secondary) !important ; + color: var(--secondary) !important; } + html a { color: var(--secondary); } + .card__link, .card__link:hover { color: var(--secondary); } + .card__text a:hover { color: $body-font-color; } + .author-data .author__name { color: var(--secondary); } + .process_stats .process_stats-item .icon { color: var(--secondary); } + #profile-tabs.tabs .tabs-title a { color: var(--secondary); } + .floating-helper__icon-big { color: var(--secondary); } @@ -57,38 +70,49 @@ html a { color: $body-font-color; } } + .side-panel__tabs .tabs-title.is-active > [role="tab"], .side-panel__tabs .tabs-title.is-active > a { color: var(--secondary); } + .side-panel__tabs .tabs-title > [role="tab"]:hover, .side-panel__tabs .tabs-title > a:hover { color: var(--secondary); } + .opinion-toggle--meh:hover { background-color: var(--secondary); } + .opinion-toggle--meh:focus { background-color: var(--secondary); } + .opinion-toggle--meh.is-active { background-color: var(--secondary); } + .floating-helper__content-close { background-color: var(--secondary); } + .button.secondary { background-color: var(--secondary); } + .floating-helper__content { border-top: 5px solid var(--secondary); } + .pagination .current { background: var(--secondary); } + .dropdown.menu > li.is-dropdown-submenu-parent > a::after { border-color: var(--secondary) transparent transparent; } + .dropdown.menu .is-active > a { color: var(--secondary); } @@ -101,21 +125,27 @@ html a { a:focus { color: var(--secondary); } + a:hover { color: var(--secondary); } + .author__name:hover { color: var(--secondary); } + .author-data a:hover { color: var(--secondary); } + .author-data button:hover { color: var(--secondary); } + .button.secondary:hover { background-color: var(--secondary); } + .card--list__icon { fill: var(--secondary); } diff --git a/app/packs/stylesheets/catencomu/partials/_login.scss b/app/packs/stylesheets/catencomu/partials/_login.scss index e44a681..5a8bee2 100644 --- a/app/packs/stylesheets/catencomu/partials/_login.scss +++ b/app/packs/stylesheets/catencomu/partials/_login.scss @@ -1,7 +1,8 @@ .button--civicrm { .button--social__icon { margin: 0; - padding: 0.3em 0; + padding: .3em 0; + .icon { display: inline-block !important; border-radius: 4px; @@ -13,8 +14,8 @@ } } -.social-register{ - .button--social{ +.social-register { + .button--social { text-align: center; } -} \ No newline at end of file +} diff --git a/app/packs/stylesheets/catencomu/partials/_navbar.scss b/app/packs/stylesheets/catencomu/partials/_navbar.scss index 3f74488..127139f 100644 --- a/app/packs/stylesheets/catencomu/partials/_navbar.scss +++ b/app/packs/stylesheets/catencomu/partials/_navbar.scss @@ -4,16 +4,18 @@ .title-bar { @include gradient-background($catencomu-red, $catencomu-lilac); - padding: 1.5rem 0.5rem; + + padding: 1.5rem .5rem; } .navbar { @include gradient-background($catencomu-red, $catencomu-lilac); + font-family: 'Montserrat Bold', sans-serif; .main-nav__link { a { - color: transparentize($navbar-bg, 0.3); + color: transparentize($navbar-bg, .3); } &--active a { @@ -22,21 +24,20 @@ } } - -.topbar_{ - &_search{ +.topbar_ { + &_search { input, - input:focus{ + input:focus { background-color: $navbar-bg; color: $navbar-fg-hover; } input::placeholder, - textarea::placeholder{ + textarea::placeholder { color: $navbar-fg-hover; } - svg{ + svg { color: $navbar-fg-hover; } } diff --git a/app/packs/stylesheets/catencomu/partials/_variables.scss b/app/packs/stylesheets/catencomu/partials/_variables.scss index 67d6e3b..4d97b69 100644 --- a/app/packs/stylesheets/catencomu/partials/_variables.scss +++ b/app/packs/stylesheets/catencomu/partials/_variables.scss @@ -21,7 +21,7 @@ $success: #6eeb83; $success-rgb:110,235,131; $warning: #f46036; $warning-rgb: 244,96,54; -$alert: #EE3138; +$alert: #ee3138; $alert-rgb: 239,45,86; $title-bar-bg: #080707; @@ -45,7 +45,7 @@ $google: #dd4b39; $color-addition: #e6ffed; $color-removal: #ffeef0; -:root{ +:root { --primary: #{$primary}; --primary-rgb: #{$primary-rgb}; --secondary: #{$secondary}; diff --git a/decidim-module-catcomu_managers/app/models/decidim/catcomu_managers/user_override.rb b/decidim-module-catcomu_managers/app/models/decidim/catcomu_managers/user_override.rb index 3726b96..366e75c 100644 --- a/decidim-module-catcomu_managers/app/models/decidim/catcomu_managers/user_override.rb +++ b/decidim-module-catcomu_managers/app/models/decidim/catcomu_managers/user_override.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Decidim module CatcomuManagers module UserOverride diff --git a/decidim-module-catcomu_managers/app/packs/src/decidim/catcomu_managers/admin/managers.js b/decidim-module-catcomu_managers/app/packs/src/decidim/catcomu_managers/admin/managers.js index a9934c2..2b9d665 100644 --- a/decidim-module-catcomu_managers/app/packs/src/decidim/catcomu_managers/admin/managers.js +++ b/decidim-module-catcomu_managers/app/packs/src/decidim/catcomu_managers/admin/managers.js @@ -1,11 +1,12 @@ $(() => { - $(".civicrm-sync-group-edit").on("click", (e) => { - e.preventDefault(); - $(e.delegateTarget).prev().attr("disabled", false); + $(".civicrm-sync-group-edit").on("click", (event) => { + event.preventDefault(); + $(event.delegateTarget).prev().attr("disabled", false); }); - $(".civicrm-sync-group-select").on("change", (e) => { - let $select = $(e.delegateTarget); + $(".civicrm-sync-group-select").on("change", (event) => { + let $select = $(event.delegateTarget); + /* eslint-disable camelcase */ $.ajax({ url: "/admin/managers/scoped_admins", data: { diff --git a/decidim-module-catcomu_managers/app/packs/stylesheets/decidim/catcomu_managers/admin/managers.scss b/decidim-module-catcomu_managers/app/packs/stylesheets/decidim/catcomu_managers/admin/managers.scss index 6412fa9..a77a1c9 100644 --- a/decidim-module-catcomu_managers/app/packs/stylesheets/decidim/catcomu_managers/admin/managers.scss +++ b/decidim-module-catcomu_managers/app/packs/stylesheets/decidim/catcomu_managers/admin/managers.scss @@ -1,10 +1,12 @@ .civicrm-sync-group { display: flex; align-items: baseline; + &-select { margin-right: 4px; margin-bottom: 0; } + &-edit { visibility: hidden; } diff --git a/package.json b/package.json index 51468ca..331b2f8 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,18 @@ "browserslist": [ "extends @decidim/browserslist-config" ], + "scripts": { + "lint": "eslint -c .eslintrc.json --ext .js {decidim-module-catcomu_managers/,}app/packs/", + "lint-fix": "eslint -c .eslintrc.json --ext .js {decidim-module-catcomu_managers/,}app/packs/ --fix", + "stylelint": "stylelint {decidim-module-catcomu_managers/,}app/packs/stylesheets", + "stylelint-fix": "stylelint {decidim-module-catcomu_managers/,}app/packs/stylesheets --fix" + }, + "stylelint": { + "extends": "@decidim/stylelint-config", + "rules": { + "block-opening-brace-space-before": "always" + } + }, "devDependencies": { "@decidim/dev": "^0.26.8", "@decidim/eslint-config": "^0.26.8",