From 9a2e60c1c917610f14600a64f31afad4623c3b6b Mon Sep 17 00:00:00 2001 From: daniel-j Date: Tue, 8 Oct 2019 11:31:42 +0200 Subject: [PATCH] lint --- gulpfile.babel.js | 10 ++-- package.json | 2 +- src/FimFic2Epub.js | 128 +++++++++++++++++++++++---------------------- src/cleanMarkup.js | 18 +++---- src/cli.js | 1 - src/constants.js | 8 +-- src/eventPage.js | 6 +-- src/fetch.js | 10 ++-- src/fetchRemote.js | 16 +++--- src/kepubify.js | 12 ++--- src/main.js | 62 +++++++++++----------- src/subsetFont.js | 4 +- src/templates.js | 48 ++++++++--------- src/utils.js | 22 ++++---- webpack.config.js | 2 +- 15 files changed, 175 insertions(+), 174 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index fa18ef9..68ca2a0 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -33,7 +33,7 @@ if (isStandalone) { webpackConfig.pop() } -let watchOpts = { +const watchOpts = { readDelay: 500, verbose: true, read: false @@ -41,12 +41,12 @@ let watchOpts = { let packageVersion = require('./package.json').version -let webpackDefines = new webpack.DefinePlugin({ +const webpackDefines = new webpack.DefinePlugin({ FIMFIC2EPUB_VERSION: JSON.stringify(packageVersion) }) // No need to bloat the build with a list of all tlds... -let replaceTlds = new webpack.NormalModuleReplacementPlugin(/^tlds$/, '../../src/false') +const replaceTlds = new webpack.NormalModuleReplacementPlugin(/^tlds$/, '../../src/false') webpackConfig.forEach((c) => { c.plugins.push(webpackDefines) @@ -89,8 +89,8 @@ function webpackTask () { } function convertFontAwesomeVars (contents) { - let vars = {} - let matchVar = /\$fa-var-(.*?): "\\(.*?)";/g + const vars = {} + const matchVar = /\$fa-var-(.*?): "\\(.*?)";/g let ma for (;(ma = matchVar.exec(contents));) { vars[ma[1]] = String.fromCharCode(parseInt(ma[2], 16)) diff --git a/package.json b/package.json index d474bc7..b0dda38 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/daniel-j/fimfic2epub.git" }, "scripts": { - "build": "NODE_ENV=production gulp", + "build": "gulp", "dev": "NODE_ENV=development gulp" }, "bin": { diff --git a/src/FimFic2Epub.js b/src/FimFic2Epub.js index f2df4d7..55076a2 100644 --- a/src/FimFic2Epub.js +++ b/src/FimFic2Epub.js @@ -31,9 +31,9 @@ const trimWhitespace = /^\s*()+|()+\s*$/ig class FimFic2Epub extends EventEmitter { static getStoryId (id) { if (isNaN(id)) { - let url = URL(id) + const url = URL(id) if (url.hostname === 'www.fimfiction.net' || url.hostname === 'fimfiction.net') { - let m = url.pathname.match(/^\/story\/(\d+)/) + const m = url.pathname.match(/^\/story\/(\d+)/) if (m) { id = m[1] } @@ -49,7 +49,7 @@ class FimFic2Epub extends EventEmitter { static fetchStoryInfo (storyId, raw = false) { return new Promise((resolve, reject) => { storyId = FimFic2Epub.getStoryId(storyId) - let url = '/api/story.php?story=' + storyId + const url = '/api/story.php?story=' + storyId fetch(url).then((content) => { let data try { @@ -63,7 +63,7 @@ class FimFic2Epub extends EventEmitter { reject(new Error(data.error + ' (id: ' + storyId + ')')) return } - let story = data.story + const story = data.story if (raw) { resolve(story) return @@ -223,20 +223,20 @@ class FimFic2Epub extends EventEmitter { this.progress(0, 0, 'Fetching chapters...') - let chapterCount = this.storyInfo.chapters.length - let url = 'https://fimfiction.net/story/download/' + this.storyInfo.id + '/html' + const chapterCount = this.storyInfo.chapters.length + const url = 'https://fimfiction.net/story/download/' + this.storyInfo.id + '/html' this.pcache.chapters = fetch(url).then((html) => { let p = Promise.resolve() - let matchChapter = /
[\s\S]*?<\/header>([\s\S]*?)<\/article>/g + const matchChapter = /
[\s\S]*?<\/header>([\s\S]*?)<\/article>/g for (let ma, i = 0; (ma = matchChapter.exec(html)); i++) { const ch = this.storyInfo.chapters[i] let chapterContent = ma[1] chapterContent = chapterContent.replace(/