From 08b700bb14e5e12c1dff283e2eef729816a97f15 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 26 Jun 2022 20:57:06 -0300 Subject: lots of fixes from eslint --- .eslintrc.json | 6 +++++- src/gen-thumbs.js | 16 +++------------- src/listing-spec.js | 2 +- src/misc-templates.js | 5 +---- src/page/album-commentary.js | 5 +---- src/page/album.js | 29 ++++++++++++++--------------- src/page/artist-alias.js | 4 +--- src/page/artist.js | 7 +------ src/page/flash.js | 3 +-- src/page/group.js | 1 - src/page/listing.js | 2 -- src/page/news.js | 2 +- src/page/static.js | 4 ++-- src/page/tag.js | 17 +---------------- src/page/track.js | 14 +------------- src/repl.js | 9 --------- src/static/client.js | 41 +++-------------------------------------- src/static/lazy-loading.js | 5 +++-- src/upd8.js | 38 ++++++-------------------------------- src/util/find.js | 19 ++++++++++--------- src/util/html.js | 2 +- src/util/io.js | 8 ++++---- src/util/replacer.js | 20 ++++++++++---------- src/util/sugar.js | 13 ++----------- src/util/urls.js | 6 +++--- src/util/wiki-data.js | 2 +- 26 files changed, 76 insertions(+), 204 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 635116dd..e0b84311 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,6 +10,10 @@ "sourceType": "module" }, "rules": { - "indent": ["off"] + "indent": ["off"], + "no-unused-vars": ["error", { + "argsIgnorePattern": "^_", + "destructuredArrayIgnorePattern": "^" + }] } } diff --git a/src/gen-thumbs.js b/src/gen-thumbs.js index 82ddb34b..b5b918fd 100644 --- a/src/gen-thumbs.js +++ b/src/gen-thumbs.js @@ -110,7 +110,7 @@ function traverse( filterDir(name) ? recursive(names, path.join(subDirPath, name)) : [], - (err) => (filterFile(name) ? [path.join(subDirPath, name)] : []) + () => (filterFile(name) ? [path.join(subDirPath, name)] : []) ) ) ).then((pathArrays) => pathArrays.flatMap((x) => x)); @@ -123,7 +123,7 @@ function readFileMD5(filePath) { const md5 = createHash('md5'); const stream = createReadStream(filePath); stream.on('data', (data) => md5.update(data)); - stream.on('end', (data) => resolve(md5.digest('hex'))); + stream.on('end', () => resolve(md5.digest('hex'))); stream.on('error', (err) => reject(err)); }); } @@ -195,14 +195,6 @@ function generateImageThumbnails(filePath, {spawnConvert}) { promisifyProcess(convert('.medium', {size: 400, quality: 95}), false), promisifyProcess(convert('.small', {size: 250, quality: 85}), false), ]); - - return new Promise((resolve, reject) => { - if (Math.random() < 0.2) { - reject(new Error(`Them's the 8r8ks, kiddo!`)); - } else { - resolve(); - } - }); } export default async function genThumbs( @@ -248,8 +240,7 @@ export default async function genThumbs( } let cache, - firstRun = false, - failedReadingCache = false; + firstRun = false; try { cache = JSON.parse(await readFile(path.join(mediaPath, CACHE_FILE))); quietInfo`Cache file successfully read.`; @@ -258,7 +249,6 @@ export default async function genThumbs( if (error.code === 'ENOENT') { firstRun = true; } else { - failedReadingCache = true; logWarn`Malformed or unreadable cache file: ${error}`; logWarn`You may want to cancel and investigate this!`; logWarn`All-new thumbnails and cache will be generated for this run.`; diff --git a/src/listing-spec.js b/src/listing-spec.js index e08fd639..28f4b1ae 100644 --- a/src/listing-spec.js +++ b/src/listing-spec.js @@ -967,7 +967,7 @@ const listingSpec = [ html: ( {officialAlbumData, fandomAlbumData}, - {getLinkThemeString, language} + {getLinkThemeString} ) => fixWS`

Choose a link to go to a random page in that category or album! If your browser doesn't support relatively modern JavaScript or you've disabled it, these links won't work - sorry.

(Data files are downloading in the background! Please wait for data to load.)

diff --git a/src/misc-templates.js b/src/misc-templates.js index 0ff4c429..53a05950 100644 --- a/src/misc-templates.js +++ b/src/misc-templates.js @@ -107,7 +107,7 @@ export function getArtistString( ) { return language.formatConjunctionList( artists.map(({who, what}) => { - const {urls, directory, name} = who; + const {urls} = who; return [ link.artist(who), showContrib && what && `(${what})`, @@ -135,11 +135,8 @@ export function generateChronologyLinks( link, linkAnythingMan, language, - wikiData, } ) { - const {albumData} = wikiData; - const contributions = currentThing[contribKey]; if (!contributions) { return ''; diff --git a/src/page/album-commentary.js b/src/page/album-commentary.js index 8a5ba069..255a6584 100644 --- a/src/page/album-commentary.js +++ b/src/page/album-commentary.js @@ -18,9 +18,7 @@ export function targets({wikiData}) { return filterAlbumsByCommentary(wikiData.albumData); } -export function write(album, {wikiData}) { - const {wikiInfo} = wikiData; - +export function write(album) { const entries = [album, ...album.tracks] .filter((x) => x.commentary) .map((x) => x.commentary); @@ -35,7 +33,6 @@ export function write(album, {wikiData}) { getThemeString, link, language, - to, transformMultiline, }) => ({ title: language.$('albumCommentaryPage.title', {album: album.name}), diff --git a/src/page/album.js b/src/page/album.js index 5b7bc975..12755ae9 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -23,8 +23,6 @@ export function targets({wikiData}) { } export function write(album, {wikiData}) { - const {wikiInfo} = wikiData; - const unbound_trackToListItem = ( track, {getArtistString, getLinkThemeString, link, language} @@ -262,7 +260,6 @@ export function write(album, {wikiData}) { .map( ({ name, - color, startIndex, tracks, }) => fixWS` @@ -383,21 +380,23 @@ export function write(album, {wikiData}) { // Utility functions -export function generateAlbumSidebar( - album, - currentTrack, - {fancifyURL, getLinkThemeString, link, language, transformMultiline, wikiData} -) { +export function generateAlbumSidebar(album, currentTrack, { + fancifyURL, + getLinkThemeString, + link, + language, + transformMultiline, +}) { const listTag = getAlbumListTag(album); /* - const trackGroups = album.trackGroups || [{ - name: language.$('albumSidebar.trackList.fallbackGroupName'), - color: album.color, - startIndex: 0, - tracks: album.tracks - }]; - */ + const trackGroups = album.trackGroups || [{ + name: language.$('albumSidebar.trackList.fallbackGroupName'), + color: album.color, + startIndex: 0, + tracks: album.tracks + }]; + */ const {trackGroups} = album; diff --git a/src/page/artist-alias.js b/src/page/artist-alias.js index 46ad1a34..3d882f65 100644 --- a/src/page/artist-alias.js +++ b/src/page/artist-alias.js @@ -7,9 +7,7 @@ export function targets({wikiData}) { return wikiData.artistAliasData; } -export function write(aliasArtist, {wikiData}) { - // This function doesn't actually use wikiData, 8ut, um, consistency? - +export function write(aliasArtist) { const {aliasedArtist} = aliasArtist; const redirect = { diff --git a/src/page/artist.js b/src/page/artist.js index eb57f5cf..481b4e36 100644 --- a/src/page/artist.js +++ b/src/page/artist.js @@ -16,8 +16,6 @@ import { chunkByProperties, getTotalDuration, sortAlbumsTracksChronologically, - sortByDate, - sortByDirectory, sortChronologically, } from '../util/wiki-data.js'; @@ -357,7 +355,6 @@ export function write(artist, {wikiData}) { getArtistString, link, language, - to, transformMultiline, }) => { const generateTrackList = bindOpts(unbound_generateTrackList, { @@ -514,7 +511,6 @@ export function write(artist, {wikiData}) { ${chunk .map( ({ - album, track, key, ...props @@ -629,7 +625,7 @@ export function write(artist, {wikiData}) { )}