Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
Install node based JS and SCSS linters
Browse files Browse the repository at this point in the history
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
---
  • Loading branch information
kevindew committed Jan 12, 2021
1 parent f916ad3 commit 504e734
Show file tree
Hide file tree
Showing 5 changed files with 2,914 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ updates:
- dependency-name: sassc-rails
dependency-type: direct

- package-ecosystem: npm
directory: /
schedule:
interval: daily
allow:
# Internal packages
- dependency-name: stylelint-config-gds
dependency-type: direct
# Framework packages
- dependency-name: standardx
dependency-type: direct
- dependency-name: stylelint
dependency-type: direct

# Ruby needs to be upgraded manually in multiple places, so cannot
# be upgraded by Dependabot. That effectively makes the below
# config redundant, as ruby is the only updatable thing in the
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@
!/log/.keep
/tmp
coverage
/public/assets

# Yarn
/node_modules
/yarn-error.log
5 changes: 4 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
library("govuk")

node {
govuk.buildProject(brakeman: true)
govuk.buildProject(
beforeTest: { sh("yarn install") },
brakeman: true,
)
}
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "service-manual-frontend",
"description": "Frontend application for GOV.UK",
"private": true,
"author": "Government Digital Service",
"license": "MIT",
"scripts": {
"lint": "yarn run lint:js && yarn run lint:scss",
"lint:js": "standardx 'app/assets/javascripts/**/*.js' 'spec/javascripts/**/*.js'",
"lint:scss": "stylelint app/assets/stylesheets/"
},
"standardx": {
"env": {
"browser": true,
"jquery": true,
"jasmine": true
},
"globals": [
"GOVUK"
],
"ignore": [
"spec/javascripts/vendor"
]
},
"eslintConfig": {
"rules": {
"no-var": 0
}
},
"stylelint": {
"extends": "stylelint-config-gds/scss"
},
"devDependencies": {
"standardx": "^7.0.0",
"stylelint": "^13.8.0",
"stylelint-config-gds": "^0.1.0"
}
}
Loading

0 comments on commit 504e734

Please sign in to comment.