Browse Source

Merge pull request #498 from communitiesuk/lint-task

Ensure more code is covered by linting
pull/505/head
Paul Robert Lloyd 3 years ago committed by GitHub
parent
commit
b2493a7dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .erb-lint.yml
  2. 14
      .github/workflows/staging_pipeline.yml
  3. 1
      Gemfile
  4. 10
      Gemfile.lock
  5. 35
      app/frontend/styles/_document-list.scss
  6. 4
      app/frontend/styles/_filter-layout.scss
  7. 4
      app/frontend/styles/_filter.scss
  8. 3
      app/frontend/styles/_pagination.scss
  9. 4
      app/frontend/styles/_panel.scss
  10. 30
      app/frontend/styles/_primary-navigation.scss
  11. 1
      app/frontend/styles/application.scss
  12. 2
      app/views/form/check_answers.html.erb
  13. 6
      app/views/form/review.html.erb
  14. 2
      app/views/layouts/application.html.erb
  15. 17
      lib/tasks/lint.rake
  16. 7
      package.json
  17. 748
      yarn.lock

2
.erb-lint.yml

@ -1,5 +1,7 @@
--- ---
EnableDefaultLinters: true EnableDefaultLinters: true
exclude:
- "**/vendor/**/*"
linters: linters:
Rubocop: Rubocop:
enabled: true enabled: true

14
.github/workflows/staging_pipeline.yml

@ -82,9 +82,19 @@ jobs:
with: with:
bundler-cache: true bundler-cache: true
- name: Rubocop - name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16
- name: Install packages and symlink local dependencies
run: |
yarn install --immutable --immutable-cache --check-cache
- name: Lint
run: | run: |
bundle exec rubocop bundle exec rake lint
audit: audit:
name: Audit dependencies name: Audit dependencies

1
Gemfile

@ -83,7 +83,6 @@ group :development do
gem "rubocop-govuk", require: false gem "rubocop-govuk", require: false
gem "rubocop-performance", require: false gem "rubocop-performance", require: false
gem "rubocop-rails", require: false gem "rubocop-rails", require: false
gem "scss_lint-govuk"
end end
group :test do group :test do

10
Gemfile.lock

@ -410,15 +410,6 @@ GEM
ruby-progressbar (1.11.0) ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5) ruby2_keywords (0.0.5)
rubyzip (2.3.2) rubyzip (2.3.2)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
scss_lint (0.59.0)
sass (~> 3.5, >= 3.5.5)
scss_lint-govuk (0.2.0)
scss_lint
selenium-webdriver (4.1.0) selenium-webdriver (4.1.0)
childprocess (>= 0.5, < 5.0) childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5) rexml (~> 3.2, >= 3.2.5)
@ -514,7 +505,6 @@ DEPENDENCIES
rubocop-govuk rubocop-govuk
rubocop-performance rubocop-performance
rubocop-rails rubocop-rails
scss_lint-govuk
selenium-webdriver selenium-webdriver
sentry-rails sentry-rails
sentry-ruby sentry-ruby

35
app/frontend/styles/_document-list.scss

@ -18,11 +18,6 @@
margin: 0 0 govuk-spacing(1); margin: 0 0 govuk-spacing(1);
} }
.app-document-list__item-metadata {
padding: 0;
margin: 0;
}
.app-document-list__item-description { .app-document-list__item-description {
@include govuk-font($size: 16); @include govuk-font($size: 16);
margin: govuk-spacing(1) 0; margin: govuk-spacing(1) 0;
@ -32,35 +27,5 @@
@include govuk-font($size: 16); @include govuk-font($size: 16);
color: $govuk-secondary-text-colour; color: $govuk-secondary-text-colour;
margin: 0; margin: 0;
}
.app-document-list {
list-style: none;
padding: 0; padding: 0;
} }
.app-document-list__item {
margin-bottom: govuk-spacing(4);
&:last-child {
border-bottom: 0;
margin-bottom: 0;
padding-bottom: 0;
}
}
.app-document-list__item-title {
@include govuk-font($size: 16, $weight: "bold");
margin: 0 0 govuk-spacing(1);
}
.app-document-list__item-description {
@include govuk-font($size: 16);
margin: govuk-spacing(1) 0;
}
.app-document-list__item-metadata {
@include govuk-font($size: 16);
color: $govuk-secondary-text-colour;
padding: 0;
margin: 0;
}

4
app/frontend/styles/_filter-layout.scss

@ -34,9 +34,7 @@
.app-filter-layout__content { .app-filter-layout__content {
@include govuk-media-query(desktop) { @include govuk-media-query(desktop) {
float: right; float: right;
max-width: calc( max-width: calc(#{govuk-grid-width("three-quarters")} - #{govuk-spacing(6)});
#{govuk-grid-width("three-quarters")} - #{govuk-spacing(6)}
);
width: 100%; width: 100%;
} }
} }

4
app/frontend/styles/_filter.scss

@ -50,7 +50,7 @@
border: 0; border: 0;
} }
&::before { &:before {
background-image: url("../assets/images/icon-cross.svg"); background-image: url("../assets/images/icon-cross.svg");
content: ""; content: "";
display: inline-block; display: inline-block;
@ -94,7 +94,7 @@
.govuk-radios__label { .govuk-radios__label {
@include govuk-font(16); @include govuk-font(16);
&::before { &:before {
background-color: govuk-colour("white"); background-color: govuk-colour("white");
} }
} }

3
app/frontend/styles/_pagination.scss

@ -1,4 +1,3 @@
// https://github.com/alphagov/govuk-frontend/blob/add-pagination-prototype/src/govuk/components/pagination/_index.scss // https://github.com/alphagov/govuk-frontend/blob/add-pagination-prototype/src/govuk/components/pagination/_index.scss
.app-pagination { .app-pagination {
border-top: 1px solid $govuk-border-colour; border-top: 1px solid $govuk-border-colour;
@ -117,7 +116,7 @@
} }
.app-pagination__icon { .app-pagination__icon {
fill: currentColor; fill: currentcolor;
} }
.app-pagination__item--prev .app-pagination__link, .app-pagination__item--prev .app-pagination__link,

4
app/frontend/styles/_panel.scss

@ -19,8 +19,8 @@
margin-bottom: 0; margin-bottom: 0;
} }
.govuk-radios__label::before, .govuk-radios__label:before,
& ::after { & :after {
color: govuk-colour("black"); color: govuk-colour("black");
border-color: govuk-colour("black"); border-color: govuk-colour("black");
background-color: govuk-colour("white"); background-color: govuk-colour("white");

30
app/frontend/styles/_primary-navigation.scss

@ -2,13 +2,13 @@
@include govuk-font(19, $weight: bold); @include govuk-font(19, $weight: bold);
background-color: govuk-colour("light-grey"); background-color: govuk-colour("light-grey");
border-bottom: 1px solid $govuk-border-colour; border-bottom: 1px solid $govuk-border-colour;
} }
.govuk-phase-banner + .app-primary-navigation { .govuk-phase-banner + .app-primary-navigation {
margin-top: -1px; margin-top: -1px;
} }
.app-primary-navigation__list { .app-primary-navigation__list {
@include govuk-clearfix; @include govuk-clearfix;
left: govuk-spacing(-3); left: govuk-spacing(-3);
list-style: none; list-style: none;
@ -17,9 +17,9 @@
position: relative; position: relative;
right: govuk-spacing(-3); right: govuk-spacing(-3);
width: calc(100% + #{govuk-spacing(6)}); width: calc(100% + #{govuk-spacing(6)});
} }
.app-primary-navigation__item { .app-primary-navigation__item {
box-sizing: border-box; box-sizing: border-box;
display: block; display: block;
float: left; float: left;
@ -27,9 +27,9 @@
height: 50px; height: 50px;
padding: 0 govuk-spacing(3); padding: 0 govuk-spacing(3);
position: relative; position: relative;
} }
.app-primary-navigation__item--current { .app-primary-navigation__item--current {
border-bottom: $govuk-border-width-narrow solid $govuk-link-colour; border-bottom: $govuk-border-width-narrow solid $govuk-link-colour;
&:hover { &:hover {
@ -39,15 +39,15 @@
&:active { &:active {
border-bottom-color: $govuk-link-active-colour; border-bottom-color: $govuk-link-active-colour;
} }
} }
.app-primary-navigation__item--align-right { .app-primary-navigation__item--align-right {
@include govuk-media-query($from: tablet) { @include govuk-media-query($from: tablet) {
float: right; float: right;
} }
} }
.app-primary-navigation__link { .app-primary-navigation__link {
@include govuk-link-common; @include govuk-link-common;
@include govuk-link-style-no-visited-state; @include govuk-link-style-no-visited-state;
@include govuk-link-style-no-underline; @include govuk-link-style-no-underline;
@ -62,8 +62,8 @@
right: 0; right: 0;
top: 0; top: 0;
} }
} }
.app-primary-navigation__item--current .app-primary-navigation__link:hover { .app-primary-navigation__item--current .app-primary-navigation__link:hover {
text-decoration: none; text-decoration: none;
} }

1
app/frontend/styles/application.scss

@ -34,6 +34,7 @@ $govuk-new-link-styles: true;
// App utilities // App utilities
.app-\!-colour-muted { .app-\!-colour-muted {
// stylelint-disable declaration-no-important
color: $govuk-secondary-text-colour !important; color: $govuk-secondary-text-colour !important;
} }

2
app/views/form/check_answers.html.erb

@ -17,7 +17,7 @@
<% end %> <% end %>
<%= display_answered_questions_summary(subsection, @case_log) %> <%= display_answered_questions_summary(subsection, @case_log) %>
<%= render partial: 'form/check_answers_summary_list', locals: { <%= render partial: "form/check_answers_summary_list", locals: {
subsection:, subsection:,
case_log: @case_log, case_log: @case_log,
} %> } %>

6
app/views/form/review.html.erb

@ -1,8 +1,8 @@
<% content_for :title, "Review lettings log" %> <% content_for :title, "Review lettings log" %>
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { <% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: {
"Logs" => "/logs", "Logs" => "/logs",
"Log #{@case_log.id.to_s}" => "/logs/" + @case_log.id.to_s, "Log #{@case_log.id}" => "/logs/#{@case_log.id}",
"Review lettings log" => "" "Review lettings log" => "",
}) %> }) %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
@ -21,7 +21,7 @@
<h3 class="x-govuk-summary-card__title"><%= subsection.label %></h3> <h3 class="x-govuk-summary-card__title"><%= subsection.label %></h3>
</div> </div>
<div class="x-govuk-summary-card__body"> <div class="x-govuk-summary-card__body">
<%= render partial: 'form/check_answers_summary_list', locals: { <%= render partial: "form/check_answers_summary_list", locals: {
subsection:, subsection:,
case_log: @case_log, case_log: @case_log,
} %> } %>

2
app/views/layouts/application.html.erb

@ -45,7 +45,7 @@
<%= govuk_header( <%= govuk_header(
classes: "app-header", classes: "app-header",
service_url: current_user.nil? ? "/" : "/logs", service_url: current_user.nil? ? "/" : "/logs",
navigation_classes: "govuk-header__navigation--end" navigation_classes: "govuk-header__navigation--end",
) do |component| ) do |component|
component.product_name(name: t("service_name")) component.product_name(name: t("service_name"))
if current_user.nil? if current_user.nil?

17
lib/tasks/lint.rake

@ -0,0 +1,17 @@
desc "Run Rubocop"
task rubocop: :environment do
sh "bundle exec rubocop"
end
desc "Run ERB Lint"
task erblint: :environment do
sh "bundle exec erblint --lint-all"
end
desc "Run Stylelint"
task stylelint: :environment do
sh "yarn stylelint app/frontend/styles"
end
desc "Run all the linters"
task lint: %i[rubocop erblint stylelint]

7
package.json

@ -37,7 +37,9 @@
}, },
"version": "0.1.0", "version": "0.1.0",
"devDependencies": { "devDependencies": {
"are-you-es5": "^2.1.2" "are-you-es5": "^2.1.2",
"stylelint": "^14.7.1",
"stylelint-config-gds": "^0.2.0"
}, },
"browserslist": { "browserslist": {
"production": [ "production": [
@ -51,6 +53,9 @@
"last 1 safari version" "last 1 safari version"
] ]
}, },
"stylelint": {
"extends": "stylelint-config-gds/scss"
},
"scripts": { "scripts": {
"build": "webpack --config webpack.config.js" "build": "webpack --config webpack.config.js"
} }

748
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save