Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Stylelint to lint Sass and Standardx to lint JS #1972

Merged
merged 9 commits into from
Jan 14, 2021
Merged

Conversation

kevindew
Copy link
Member

Trello: https://trello.com/c/MeG1zc2m/195-roll-out-stylelint-config-gds-across-govuk

This project previously had no JS linting and used the Ruby based scss-lint_govuk project for Sass linting. This adds in JS linting from Standardx and replaces the Ruby Sass linter with Stylelint.

More info in the commits...

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

This saves a dependency given sass-rails is just a wrapper around
sassc-rails.

I've added this to dependabot as most GOV.UK apps have
sass-rails/sassc-rails managed there with this repo being an omission.
This option no longer has any effect.
This got missed when the assets changed location.
This is added to this project as part of roll-out across GOV.UK of stylelint
to replace scss_lint-govuk as the default linter.

This project previously didn't have any JS linting installed so Standard is
installed as per the GDS Way [1]. For SCSS linting stylelint-config-gds [2]
is used which is a GDS standard based upon stylelint [3]. Both of these
projects are then added to dependabot to have their versions maintained with
the same approach we use for rubocop-govuk.

Standardx is used instead of standard because Standard 16 introduced a rule
that disallowed the use of `var`, instead preferring `let` or `const` [4].
This conflicts with the GOV.UK approach where we tend to not embrace features
that we know will break old browsers even if they're not necessarily supported
[5], disallowing var will mean that < IE 11 will be unable to run any of the JS.

In order to customise standard rules this project has switched to using
standardx [6] which allows us to disallow rules. I've used this so we
can disallow the 'no-var' rule.

[1]: https://gds-way.cloudapps.digital/manuals/programming-languages/js.html#linting
[2]: https://github.com/alphagov/stylelint-config-gds
[3]: https://stylelint.io/
[4]: standard/standard#633
[5]: alphagov/govuk_publishing_components#1611 (comment)
[6]: https://github.com/standard/standardx
npx standardx --fix 'app/assets/javascripts/**/*.js'
'spec/javascripts/**/*.js'
This has been replaced by stylelint.
This also updates the Rakefile to be more consistent with the other ones
on GOV.UK apps, by clearing a default task if it exists and re-defining
default as all lint and test tasks.
@bevanloon bevanloon temporarily deployed to government-f-node-linte-xsdgv5 January 11, 2021 09:57 Inactive
kevindew added a commit to alphagov/govuk-docker that referenced this pull request Jan 13, 2021
@kevindew kevindew merged commit 0010d34 into master Jan 14, 2021
@kevindew kevindew deleted the node-linters branch January 14, 2021 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants