Skip to content
This repository has been archived by the owner on Mar 9, 2021. 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 Dec 11, 2020
1 parent 3dae92c commit d13355f
Show file tree
Hide file tree
Showing 4 changed files with 2,893 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
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
6 changes: 5 additions & 1 deletion Jenkinsfile
Expand Up @@ -3,5 +3,9 @@
library("govuk")

node {
govuk.buildProject(brakeman: true)
govuk.buildProject(
beforeTest: { sh("yarn install") },
brakeman: true,
sassLint: false,
)
}
31 changes: 31 additions & 0 deletions package.json
@@ -0,0 +1,31 @@
{
"name": "calculators",
"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'",
"lint:scss": "stylelint app/assets/stylesheets/"
},
"standardx": {
"env": {
"browser": true,
"jquery": true
}
},
"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"
}
}

0 comments on commit d13355f

Please sign in to comment.