From a915f310ed3850f2db3aed729da1efd50abe0d83 Mon Sep 17 00:00:00 2001 From: omrilotan Date: Mon, 14 Sep 2020 07:13:22 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=20Autofix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/build/activityPage/index.js | 4 ++-- lib/build/constructAppData/index.js | 2 +- lib/build/createBundle/index.js | 2 +- lib/build/index.js | 10 +++++----- lib/previewImage/index.js | 2 +- lib/serve/index.js | 6 +++--- lib/sortObjectByValue/index.js | 4 ++-- scripts/sort/index.js | 2 +- src/sames/serviceworker.js | 4 ++-- src/scripts/index.js | 2 +- src/scripts/menu/index.js | 2 +- src/scripts/service-worker/index.js | 2 +- src/scripts/suggest.js | 4 ++-- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/build/activityPage/index.js b/lib/build/activityPage/index.js index 445713c7..02c605d2 100644 --- a/lib/build/activityPage/index.js +++ b/lib/build/activityPage/index.js @@ -9,7 +9,7 @@ const previewImage = require('../../previewImage'); * @param {string} o.template * @param {object} o.appData */ -module.exports = async function activityPage({base, dist, key, thing, template, appData}) { +module.exports = async function activityPage({ base, dist, key, thing, template, appData }) { const preview = await previewImage({ dist: join(base, dist), filename: key, @@ -17,7 +17,7 @@ module.exports = async function activityPage({base, dist, key, thing, template, }); await writeFile( - join(base, dist, key, ['index', 'html'].join('.')), + join(base, dist, key, [ 'index', 'html' ].join('.')), phrase( template, Object.assign( diff --git a/lib/build/constructAppData/index.js b/lib/build/constructAppData/index.js index fab2842d..90527455 100644 --- a/lib/build/constructAppData/index.js +++ b/lib/build/constructAppData/index.js @@ -23,7 +23,7 @@ module.exports = async function constructAppData({ size: all.length, tagline, link: homepage, - preview: [homepage , 'images', '960x640.png'].join('/'), + preview: [ homepage, 'images', '960x640.png' ].join('/'), cacheKeyVersion, }; diff --git a/lib/build/createBundle/index.js b/lib/build/createBundle/index.js index 9c26a696..5c193083 100644 --- a/lib/build/createBundle/index.js +++ b/lib/build/createBundle/index.js @@ -9,7 +9,7 @@ const phrase = require('paraphrase/double'); */ module.exports = async function createBundle(input, appData) { const bundle = await rollup({ input }); - const { output: [{ code }] } = await bundle.generate({ + const { output: [ { code } ] } = await bundle.generate({ compact: false, strict: false, format: 'iife', diff --git a/lib/build/index.js b/lib/build/index.js index 61b59012..51f5c3b6 100644 --- a/lib/build/index.js +++ b/lib/build/index.js @@ -70,8 +70,8 @@ const destinations = { sources, }); - await writeFile(destinations.indoors, JSON.stringify(Object.keys({...indoors, ...anywhere}))); - await writeFile(destinations.outdoors, JSON.stringify(Object.keys({...outdoors, ...anywhere}))); + await writeFile(destinations.indoors, JSON.stringify(Object.keys({ ...indoors, ...anywhere }))); + await writeFile(destinations.outdoors, JSON.stringify(Object.keys({ ...outdoors, ...anywhere }))); await writeFile(destinations.all, JSON.stringify(Object.keys(activities))); await writeFile(destinations.scripts, await createBundle(sources.scripts, appData)); @@ -87,7 +87,7 @@ const destinations = { const template = await readFile(sources.template); Object.entries(activities).forEach( - ([key, thing]) => activityPage({base, dist, key, thing, template, appData}), + ([ key, thing ]) => activityPage({ base, dist, key, thing, template, appData }), ); await writeFile(destinations.sitemap, await createSitemap(sources.sitemap, appData)); @@ -96,8 +96,8 @@ const destinations = { 'Built site with ', Object.keys(activities).length, ' activities. ', - '(', Object.keys({...indoors, ...anywhere}).length, ' indoors,', - ' ', Object.keys({...outdoors, ...anywhere}).length, ' outdoors)', + '(', Object.keys({ ...indoors, ...anywhere }).length, ' indoors,', + ' ', Object.keys({ ...outdoors, ...anywhere }).length, ' outdoors)', '\n', 'Build duration: ', (Number(process.hrtime.bigint() - start) / 1e6).toFixed(2), diff --git a/lib/previewImage/index.js b/lib/previewImage/index.js index ff88b92c..6ec337c6 100644 --- a/lib/previewImage/index.js +++ b/lib/previewImage/index.js @@ -42,7 +42,7 @@ module.exports = async function previewImage({ dist, filename, text }) { words.forEach( function (word) { - const testLine = [line, word].filter(Boolean).join(' '); + const testLine = [ line, word ].filter(Boolean).join(' '); const testLineWidth = textContext.measureText(testLine).width; if (testLineWidth > MAX_LINE_WIDTH) { diff --git a/lib/serve/index.js b/lib/serve/index.js index 4576f521..eeaf5928 100644 --- a/lib/serve/index.js +++ b/lib/serve/index.js @@ -10,7 +10,7 @@ const { const mime = require('mime-types'); const logger = require('../logger'); -const [,, port = '1337'] = process.argv; +const [ ,, port = '1337' ] = process.argv; module.exports = () => createServer( async function(request, response) { @@ -34,10 +34,10 @@ module.exports = () => createServer( response.write(file, 'binary'); response.end(); - logger.info(['🌐 http://127.0.0.1:', port, url].join('')); + logger.info([ '🌐 http://127.0.0.1:', port, url ].join('')); } catch (error) { - response.writeHead(500, {'Content-Type': 'text/plain'}); + response.writeHead(500, { 'Content-Type': 'text/plain' }); response.write(error.message); response.end(); diff --git a/lib/sortObjectByValue/index.js b/lib/sortObjectByValue/index.js index 5fef3821..f6901614 100644 --- a/lib/sortObjectByValue/index.js +++ b/lib/sortObjectByValue/index.js @@ -5,8 +5,8 @@ */ module.exports = obj => Object.fromEntries(Object.entries(obj).sort(sort)); -function sort([, one], [, two]) { - const [a, b] = [one, two].map( +function sort([ , one ], [ , two ]) { + const [ a, b ] = [ one, two ].map( value => value.toLowerCase(), ); diff --git a/scripts/sort/index.js b/scripts/sort/index.js index 6c5fce61..84c47715 100755 --- a/scripts/sort/index.js +++ b/scripts/sort/index.js @@ -4,7 +4,7 @@ const { join } = require('path'); const readLines = require('../../lib/readLines'); const writeFile = require('../../lib/writeFile'); -const [ , , ...files] = process.argv; +const [ , , ...files ] = process.argv; async function sortFile (filename) { const filepath = join(process.cwd(), filename); diff --git a/src/sames/serviceworker.js b/src/sames/serviceworker.js index 821be1f5..194645f0 100644 --- a/src/sames/serviceworker.js +++ b/src/sames/serviceworker.js @@ -10,7 +10,7 @@ function updateCacheKey(value = '1') { version = value; - cacheKey = [CACHE_KEY_PREFIX, version].join('-'); + cacheKey = [ CACHE_KEY_PREFIX, version ].join('-'); clearOldCache(); } @@ -167,7 +167,7 @@ } function err(error, message) { - error.message = [error.message, message].join(' '); + error.message = [ error.message, message ].join(' '); setTimeout(() => { throw error; }); } })(); diff --git a/src/scripts/index.js b/src/scripts/index.js index 343f2989..d8e9e472 100644 --- a/src/scripts/index.js +++ b/src/scripts/index.js @@ -11,7 +11,7 @@ import { addShareButton } from './share/index.js'; /** * @type {string[]} Existing lists */ -const LISTS = ['all', 'indoors', 'outdoors']; +const LISTS = [ 'all', 'indoors', 'outdoors' ]; const next = location => fetch(`/${location}.json`) .then( diff --git a/src/scripts/menu/index.js b/src/scripts/menu/index.js index f7e4ad85..14c709e0 100644 --- a/src/scripts/menu/index.js +++ b/src/scripts/menu/index.js @@ -5,7 +5,7 @@ import { location } from '../location/index.js'; import slider from '../slider/index.js'; export default function menu() { - const template = document.querySelector('template[name="nav"]'); + const template = document.querySelector('template[name="nav"]'); if (!template) { return; } const nav = template.content.querySelector('nav'); diff --git a/src/scripts/service-worker/index.js b/src/scripts/service-worker/index.js index 06433b20..338a6528 100644 --- a/src/scripts/service-worker/index.js +++ b/src/scripts/service-worker/index.js @@ -19,7 +19,7 @@ export default async function registerServiceWorker() { await navigator.serviceWorker.ready; setTimeout( - () => navigator.serviceWorker.controller && navigator.serviceWorker.controller.postMessage({action: 'updateCacheKey', value: cacheKey()}), + () => navigator.serviceWorker.controller && navigator.serviceWorker.controller.postMessage({ action: 'updateCacheKey', value: cacheKey() }), 1000 ); } diff --git a/src/scripts/suggest.js b/src/scripts/suggest.js index 24473c1f..9e11e7e5 100644 --- a/src/scripts/suggest.js +++ b/src/scripts/suggest.js @@ -23,9 +23,9 @@ import random from './random/index.js'; const [ textarea ] = target; const { value } = textarea; if (!value) { return textarea.focus(); } - [target, textarea].forEach(e => e.setAttribute('disabled', 'disabled')); + [ target, textarea ].forEach(e => e.setAttribute('disabled', 'disabled')); send(value).then(thanks).catch( - () => [target, textarea].forEach(e => e.removeAttribute('disabled')) + () => [ target, textarea ].forEach(e => e.removeAttribute('disabled')) ); } );