Skip to content

Commit

Permalink
Format JavaScript with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Dec 16, 2023
1 parent c08b8cc commit 5872ae2
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 46 deletions.
40 changes: 21 additions & 19 deletions eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ module.exports = function (eleventyConfig) {
fontFamily: 'system-ui, sans-serif',
icons: {
mask: 'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-mask-icon.svg?raw=true',
shortcut: 'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-favicon.ico',
touch: 'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-apple-touch-icon.png'
shortcut:
'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-favicon.ico',
touch:
'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-apple-touch-icon.png'
},
opengraphImageUrl: 'https://x-govuk.github.io/govuk-prototype-components/assets/opengraph-image.png',
opengraphImageUrl:
'https://x-govuk.github.io/govuk-prototype-components/assets/opengraph-image.png',
homeKey: 'GOV.UK Prototype Components',
parentSite: {
url: 'https://x-govuk.github.io/#projects',
Expand All @@ -21,9 +24,7 @@ module.exports = function (eleventyConfig) {
url: process.env.GITHUB_ACTIONS
? 'https://x-govuk.github.io/govuk-prototype-components/'
: '/',
stylesheets: [
'/styles/application.css'
],
stylesheets: ['/styles/application.css'],
header: {
organisationLogo: 'x-govuk',
organisationName: 'X-GOVUK',
Expand Down Expand Up @@ -65,21 +66,24 @@ module.exports = function (eleventyConfig) {
})

// Collections
eleventyConfig.addCollection('homepage', collection =>
collection.getFilteredByGlob([
'docs/autocomplete.md',
'docs/masthead.md',
'docs/primary-navigation.md',
'docs/sub-navigation.md',
'docs/related-navigation.md',
'docs/data-attributes.md'
]).sort((a, b) => (a.data.order || 0) - (b.data.order || 0))
eleventyConfig.addCollection('homepage', (collection) =>
collection
.getFilteredByGlob([
'docs/autocomplete.md',
'docs/masthead.md',
'docs/primary-navigation.md',
'docs/sub-navigation.md',
'docs/related-navigation.md',
'docs/data-attributes.md'
])
.sort((a, b) => (a.data.order || 0) - (b.data.order || 0))
)

// Passthrough
eleventyConfig.addPassthroughCopy('./docs/assets')
eleventyConfig.addPassthroughCopy({
'./node_modules/@x-govuk/govuk-prototype-components/x-govuk/*.js': './assets/x-govuk'
'./node_modules/@x-govuk/govuk-prototype-components/x-govuk/*.js':
'./assets/x-govuk'
})
eleventyConfig.addPassthroughCopy({
'./node_modules/iframe-resizer/js/*.js': './assets'
Expand All @@ -94,8 +98,6 @@ module.exports = function (eleventyConfig) {
layouts: '_layouts',
includes: '_components'
},
pathPrefix: process.env.GITHUB_ACTIONS
? '/govuk-prototype-components'
: '/'
pathPrefix: process.env.GITHUB_ACTIONS ? '/govuk-prototype-components' : '/'
}
}
6 changes: 4 additions & 2 deletions govuk-prototype-kit/init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
if (window.GOVUKPrototypeKit &&
if (
window.GOVUKPrototypeKit &&
window.GOVUKPrototypeKit.documentReady &&
window.GOVUKPrototypeKit.majorVersion >= 13) {
window.GOVUKPrototypeKit.majorVersion >= 13
) {
window.GOVUKPrototypeKit.documentReady(function () {
window.GOVUKPrototypeComponents.initAll()
})
Expand Down
25 changes: 11 additions & 14 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import commonJs from '@rollup/plugin-commonjs'
import { nodeResolve } from '@rollup/plugin-node-resolve'

export default [{
input: [
'x-govuk/all.mjs'
],
output: {
dir: 'x-govuk',
format: 'umd',
name: 'GOVUKPrototypeComponents'
},
plugins: [
nodeResolve(),
commonJs()
]
}]
export default [
{
input: ['x-govuk/all.mjs'],
output: {
dir: 'x-govuk',
format: 'umd',
name: 'GOVUKPrototypeComponents'
},
plugins: [nodeResolve(), commonJs()]
}
]
13 changes: 5 additions & 8 deletions x-govuk/all.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Autocomplete from './components/autocomplete/autocomplete.js'
import Edge from './components/edge/edge.js'
import WarnOnUnsavedChanges from './components/warn-on-unsaved-changes/warn-on-unsaved-changes.js'

function initAll (options) {
function initAll(options) {
// Set the options to an empty object by default if no options are passed.
options = typeof options !== 'undefined' ? options : {}

Expand All @@ -20,15 +20,12 @@ function initAll (options) {
new Edge($edge).init()
})

const $forms = scope.querySelectorAll('[data-module="warn-on-unsaved-changes"]')
const $forms = scope.querySelectorAll(
'[data-module="warn-on-unsaved-changes"]'
)
$forms.forEach(function ($form) {
new WarnOnUnsavedChanges($form).init()
})
}

export {
initAll,
Autocomplete,
Edge,
WarnOnUnsavedChanges
}
export { initAll, Autocomplete, Edge, WarnOnUnsavedChanges }
9 changes: 6 additions & 3 deletions x-govuk/components/edge/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ export default function ($module) {
}

const nodes = $module.querySelectorAll('a[href="#"]')
nodes.forEach(node => { events.on('click', node, alertUser) })
nodes.forEach((node) => {
events.on('click', node, alertUser)
})

function alertUser (event) {
function alertUser(event) {

Check warning on line 14 in x-govuk/components/edge/edge.js

View workflow job for this annotation

GitHub Actions / Run tests (18)

Missing JSDoc comment

Check warning on line 14 in x-govuk/components/edge/edge.js

View workflow job for this annotation

GitHub Actions / Run tests (20)

Missing JSDoc comment
event.preventDefault()
const message = event.target.dataset.message || 'Sorry, this hasn’t been built yet'
const message =
event.target.dataset.message || 'Sorry, this hasn’t been built yet'

window.alert(message)
}
Expand Down

0 comments on commit 5872ae2

Please sign in to comment.