Skip to content

Commit

Permalink
Use standardx for JS linting
Browse files Browse the repository at this point in the history
This applies standard for linting JavaScript as per the GDS Way [1]. Standardx
is used instead of standard because Standard 16 introduced a rule
that disallowed the use of `var`, instead preferring `let` or `const` [2].
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
[3], 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 [4] 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]: standard/standard#633
[3]: alphagov/govuk_publishing_components#1611 (comment)
[4]: https://github.com/standard/standardx
  • Loading branch information
kevindew committed Jan 6, 2021
1 parent 38312c6 commit 179611f
Show file tree
Hide file tree
Showing 3 changed files with 864 additions and 651 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/public/finder-frontend/
/coverage/*
node_modules
yarn-error.log
.env
credentials.json
token.yaml
token.yaml
24 changes: 21 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,28 @@
"author": "Government Digital Service",
"license": "MIT",
"scripts": {
"lint": "standard app/assets/javascripts/{*.js,**/*.js} spec/javascripts/{*.js,**/*.js}",
"lint:fix": "yarn run lint --fix"
"lint": "yarn run lint:js",
"lint:js": "standardx 'app/assets/javascripts/**/*.js' 'spec/javascripts/**/*.js'"
},
"standardx": {
"env": {
"browser": true,
"jquery": true,
"jasmine": true
},
"globals": [
"GOVUK"
],
"ignore": [
"spec/javascripts/vendor"
]
},
"eslintConfig": {
"rules": {
"no-var": 0
}
},
"devDependencies": {
"standard": "^12.0.1"
"standardx": "^7.0.0"
}
}
Loading

0 comments on commit 179611f

Please sign in to comment.