Skip to content

Commit

Permalink
Run eslint --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Jul 26, 2023
1 parent fc31d03 commit 6fc61cb
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions __tests__/cookie-functions.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('Cookie settings', () => {
const cookies = document.cookie.split(';')
cookies.forEach(function (cookie) {
const name = cookie.split('=')[0]
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/'
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=' + window.location.hostname + ';path=/'
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=${window.location.hostname};path=/`
})
})

Expand Down
6 changes: 3 additions & 3 deletions lib/file-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ exports.getFingerprint = function (file) {

// Skip fingerprints in development for Browsersync inject (without reload)
if (process.env.NODE_ENV === 'development') {
return '/' + slash(file)
return `/${slash(file)}`
}

// Grab fingerprint array from the template context
Expand All @@ -82,7 +82,7 @@ exports.getFingerprint = function (file) {
}

// Look for a fingerprinted asset at this path relative to the site root
return '/' + slash(fingerprints[file].path)
return `/${slash(fingerprints[file].path)}`
}

// This helper function takes a path of a *.md.njk file and
Expand All @@ -98,7 +98,7 @@ exports.getHTMLCode = path => {
html = nunjucks.renderString(content).trim()
} catch (err) {
if (err) {
console.log('Could not get HTML code from ' + path)
console.log(`Could not get HTML code from ${path}`)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/get-macro-options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function getMacroOptions (componentName) {
].concat(
nestedOptions.map(option => {
return {
name: 'Options for ' + option.name,
name: `Options for ${option.name}`,
id: option.name,
options: option.params
}
Expand All @@ -173,7 +173,7 @@ function getMacroOptions (componentName) {
additionalComponents.map(name => {
const additionalComponentOptions = getMacroOptionsJson(name).map(renderDescriptionsAsMarkdown)
return {
name: 'Options for ' + name,
name: `Options for ${name}`,
id: name,
options: additionalComponentOptions
}
Expand Down
6 changes: 3 additions & 3 deletions lib/metalsmith-title-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ module.exports = function titleChecker () {

if (filesWithoutTitles.length) {
throw Error(
'The following file(s) do not have titles:\n\n' +
filesWithoutTitles.map(file => `- ${file}`).join('\n') +
'\n'
`The following file(s) do not have titles:\n\n${
filesWithoutTitles.map(file => `- ${file}`).join('\n')
}\n`
)
}
done()
Expand Down
4 changes: 2 additions & 2 deletions src/javascripts/components/analytics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export default function loadAnalytics () {
})

const j = d.createElement(s)
const dl = l !== 'dataLayer' ? '&l=' + l : ''
const dl = l !== 'dataLayer' ? `&l=${l}` : ''

j.async = true
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl
j.src = `https://www.googletagmanager.com/gtm.js?id=${i}${dl}`
document.head.appendChild(j)
})(window, document, 'script', 'dataLayer', 'GTM-53XG2JT')
}
Expand Down
24 changes: 12 additions & 12 deletions src/javascripts/components/cookie-functions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const TRACKING_LIVE_ID = '116229859-1'

/* Users can (dis)allow different groups of cookies. */
const COOKIE_CATEGORIES = {
analytics: ['_ga', '_gid', '_gat_UA-' + TRACKING_PREVIEW_ID, '_gat_UA-' + TRACKING_LIVE_ID],
analytics: ['_ga', '_gid', `_gat_UA-${TRACKING_PREVIEW_ID}`, `_gat_UA-${TRACKING_LIVE_ID}`],
/* Essential cookies
*
* Essential cookies cannot be deselected, but we want our cookie code to
Expand Down Expand Up @@ -157,13 +157,13 @@ export function resetCookies () {
// Initialise analytics if allowed
if (cookieType === 'analytics' && options[cookieType]) {
// Enable GA if allowed
window['ga-disable-UA-' + TRACKING_PREVIEW_ID] = false
window['ga-disable-UA-' + TRACKING_LIVE_ID] = false
window[`ga-disable-UA-${TRACKING_PREVIEW_ID}`] = false
window[`ga-disable-UA-${TRACKING_LIVE_ID}`] = false
Analytics()
} else {
// Disable GA if not allowed
window['ga-disable-UA-' + TRACKING_PREVIEW_ID] = true
window['ga-disable-UA-' + TRACKING_LIVE_ID] = true
window[`ga-disable-UA-${TRACKING_PREVIEW_ID}`] = true
window[`ga-disable-UA-${TRACKING_LIVE_ID}`] = true
}

if (!options[cookieType]) {
Expand Down Expand Up @@ -220,7 +220,7 @@ function userAllowsCookie (cookieName) {
}

function getCookie (name) {
const nameEQ = name + '='
const nameEQ = `${name}=`
const cookies = document.cookie.split(';')
for (let i = 0, len = cookies.length; i < len; i++) {
let cookie = cookies[i]
Expand All @@ -239,14 +239,14 @@ function setCookie (name, value, options) {
if (typeof options === 'undefined') {
options = {}
}
let cookieString = name + '=' + value + '; path=/'
let cookieString = `${name}=${value}; path=/`
if (options.days) {
const date = new Date()
date.setTime(date.getTime() + (options.days * 24 * 60 * 60 * 1000))
cookieString = cookieString + '; expires=' + date.toGMTString()
cookieString = `${cookieString}; expires=${date.toGMTString()}`
}
if (document.location.protocol === 'https:') {
cookieString = cookieString + '; Secure'
cookieString = `${cookieString}; Secure`
}
document.cookie = cookieString
}
Expand All @@ -258,8 +258,8 @@ function deleteCookie (name) {
// If a cookie was set with a specified domain, it needs to be specified when deleted
// If a cookie wasn't set with the domain attribute, it shouldn't be there when deleted
// You can't tell if a cookie was set with a domain attribute or not, so try both options
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/'
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=' + window.location.hostname + ';path=/'
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=.' + window.location.hostname + ';path=/'
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=${window.location.hostname};path=/`
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=.${window.location.hostname};path=/`
}
}
4 changes: 2 additions & 2 deletions src/javascripts/components/cookies-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CookiesPage.prototype.savePreferences = function (event) {

this.$cookieFormFieldsets.forEach(function ($cookieFormFieldset) {
const cookieType = this.getCookieType($cookieFormFieldset)
const selectedItem = $cookieFormFieldset.querySelector('input[name=' + cookieType + ']:checked').value
const selectedItem = $cookieFormFieldset.querySelector(`input[name=${cookieType}]:checked`).value

preferences[cookieType] = selectedItem === 'yes'
}.bind(this))
Expand All @@ -53,7 +53,7 @@ CookiesPage.prototype.showUserPreference = function ($cookieFormFieldset, prefer
}

const radioValue = preference ? 'yes' : 'no'
const radio = $cookieFormFieldset.querySelector('input[name=' + cookieType + '][value=' + radioValue + ']')
const radio = $cookieFormFieldset.querySelector(`input[name=${cookieType}][value=${radioValue}]`)
radio.checked = true
}

Expand Down
4 changes: 2 additions & 2 deletions src/javascripts/components/navigation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Navigation.prototype.setInitialAriaStates = function () {
const $nextSubNav = $button.parentNode.querySelector(subNavJSClass)

if ($nextSubNav) {
const subNavTogglerId = 'js-mobile-nav-subnav-toggler-' + index
const nextSubNavId = 'js-mobile-nav__subnav-' + index
const subNavTogglerId = `js-mobile-nav-subnav-toggler-${index}`
const nextSubNavId = `js-mobile-nav__subnav-${index}`

$nextSubNav.setAttribute('id', nextSubNavId)
$button.setAttribute('id', subNavTogglerId)
Expand Down
4 changes: 2 additions & 2 deletions src/javascripts/components/options-table.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const OptionsTable = {
}

if (exampleName) {
const tabLink = document.querySelector('a[href="#' + exampleName + '-nunjucks"]')
const tabLink = document.querySelector(`a[href="#${exampleName}-nunjucks"]`)
const tabHeading = tabLink ? tabLink.parentNode : null
const optionsDetailsElement = document.getElementById('options-' + exampleName + '-details')
const optionsDetailsElement = document.getElementById(`options-${exampleName}-details`)

if (tabHeading && optionsDetailsElement) {
const tabsElement = optionsDetailsElement.parentNode
Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Search.prototype.handleOnConfirm = function (result) {
return
}
trackConfirm(searchQuery, searchResults, result)
window.location.href = '/' + permalink
window.location.href = `/${permalink}`
}

Search.prototype.inputValueTemplate = function (result) {
Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/search.tracking.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function trackConfirm (searchQuery, searchResults, result) {
eventDetails: {
category: 'site search',
action: 'click',
label: searchTerm + ' | ' + result.title
label: `${searchTerm} | ${result.title}`
},
ecommerce: {
click: {
Expand Down
4 changes: 2 additions & 2 deletions src/javascripts/components/tabs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ AppTabs.prototype.onClick = function (event) {
const isTabAlreadyOpen = $currentTab.getAttribute('aria-expanded') === 'true'

if (!$panel) {
throw new Error('Invalid example ID given: ' + panelId)
throw new Error(`Invalid example ID given: ${panelId}`)
}

// If the panel that's been called is already open, close it.
Expand Down Expand Up @@ -154,7 +154,7 @@ AppTabs.prototype.getMobileTab = function (panelId) {
AppTabs.prototype.getDesktopTab = function (panelId) {
const $desktopTabContainer = this.$module.querySelector('.app-tabs')
if ($desktopTabContainer) {
return $desktopTabContainer.querySelector('[aria-controls="' + panelId + '"]')
return $desktopTabContainer.querySelector(`[aria-controls="${panelId}"]`)
}
return null
}
Expand Down

0 comments on commit 6fc61cb

Please sign in to comment.