-
Notifications
You must be signed in to change notification settings - Fork 333
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
Upgrade ESLint configuration for ES2015 (without classes) #3770
Conversation
We may take this higher once we confirm the browser support guarded by our “cut the mustard” checks
Including implicit `.toString()` for booleans and numbers within template strings
We can now us arrow functions instead
Fixes warnings from ESLint `@typescript/no-this-alias`
c621b56
to
260c736
Compare
260c736
to
96b19ad
Compare
var $accordions = $scope.querySelectorAll('[data-module="govuk-accordion"]') | ||
$accordions.forEach(function ($accordion) { | ||
const $accordions = $scope.querySelectorAll('[data-module="govuk-accordion"]') | ||
$accordions.forEach(($accordion) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all these arrow function changes I'm aware they're split into:
- Arrow functions used to preserve
this
as the component instance - Arrow functions wrappers to avoid
.bind(this)
in event handlers - Arrow functions simply for "code style" or consistency
We have plenty of event listeners and .forEach()
loops (like this one) that never actually refer to this
so we may consider it unnecessary to change them to arrow functions outside of component scope
Terser is going to convert all that it can to arrow functions anyway to save KBs
Upgrade ESLint configuration for ES2015 (without classes)
This PR updates our ESLint config as part of #3463 to:
this
in componentsA + 'to' + B
concatenationlet
orconst
with block scoping rather thanvar
I've left ESLint rules in place for
.prototype
inheritance as we'll move to ES2015 classes in another PRBrowser support
We may go higher than ES2015 once we confirm the browser support guarded by our “cut the mustard” checks
We know that browsers supporting
<script type="module">
already support the new features above