Skip to content

Commit f5d080d

Browse files
committed
lint and fix issues
1 parent 1fff821 commit f5d080d

File tree

5 files changed

+2110
-2087
lines changed

5 files changed

+2110
-2087
lines changed

helpers.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var url = require('url')
2+
13
module.exports.capitalizeFirstLetter = function (string) {
24
return string.charAt(0).toUpperCase() + string.slice(1)
35
}

index.js

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,16 @@ module.exports = {
3131
options.enabled = []
3232
}
3333

34-
if (typeof options.lighthouse === 'undefined') {
35-
options.lighthouse = {
36-
enabled: false
37-
}
38-
}
39-
4034
if (typeof options.puppeteer === 'undefined') {
4135
options.puppeteer = {
4236
headless: true,
4337
defaultViewport: null
4438
}
4539
}
4640

47-
let actions = [articleParser(options, socket)];
41+
const actions = [articleParser(options, socket)]
4842

49-
if ( options.enabled.includes('lighthouse') ) {
43+
if (options.enabled.includes('lighthouse')) {
5044
actions.push(lighthouseAnalysis(options, socket))
5145
}
5246

@@ -108,12 +102,10 @@ const articleParser = async function (options, socket) {
108102
article.meta.title.text = await page.title()
109103

110104
// Take mobile screenshot
111-
if ( options.enabled.includes('screenshot') ) {
112-
105+
if (options.enabled.includes('screenshot')) {
113106
socket.emit('parse:status', 'Taking Mobile Screenshot')
114107

115108
article.mobile = await page.screenshot({ encoding: 'base64', type: 'jpeg', quality: 60 })
116-
117109
}
118110

119111
// Evaluate meta
@@ -172,8 +164,7 @@ const articleParser = async function (options, socket) {
172164
article.title.text = content.title
173165

174166
// Get in article links
175-
if ( options.enabled.includes('links') ) {
176-
167+
if (options.enabled.includes('links')) {
177168
socket.emit('parse:status', 'Evaluating Links')
178169

179170
const { window } = new JSDOM(article.processed.html)
@@ -204,8 +195,7 @@ const articleParser = async function (options, socket) {
204195
article.excerpt = helpers.capitalizeFirstLetter(article.processed.text.raw.replace(/^(.{200}[^\s]*).*/, '$1'))
205196

206197
// Sentiment
207-
if ( options.enabled.includes('sentiment') ) {
208-
198+
if (options.enabled.includes('sentiment')) {
209199
socket.emit('parse:status', 'Sentiment Analysis')
210200

211201
const sentiment = new Sentiment()
@@ -218,12 +208,10 @@ const articleParser = async function (options, socket) {
218208
} else {
219209
article.sentiment.result = 'Neutral'
220210
}
221-
222211
}
223212

224213
// Named Entity Recognition
225-
if ( options.enabled.includes('entities') ) {
226-
214+
if (options.enabled.includes('entities')) {
227215
socket.emit('parse:status', 'Named Entity Recognition')
228216

229217
// People
@@ -253,21 +241,17 @@ const articleParser = async function (options, socket) {
253241
article.topics.sort(function (a, b) {
254242
return (a.percent > b.percent) ? -1 : 1
255243
})
256-
257244
}
258245

259246
// Spelling
260-
if ( options.enabled.includes('spelling') ) {
261-
262-
socket.emit('parse:status', 'Check Spelling')
247+
if (options.enabled.includes('spelling')) {
248+
socket.emit('parse:status', 'Check Spelling')
263249

264250
article.spelling = await spellCheck(article.processed.text.formatted, article.topics, options.retextspell)
265-
266251
}
267252

268253
// Evaluate keywords & keyphrases
269-
if ( options.enabled.includes('keywords') ) {
270-
254+
if (options.enabled.includes('keywords')) {
271255
socket.emit('parse:status', 'Evaluating Keywords')
272256

273257
// Evaluate meta title keywords & keyphrases
@@ -281,7 +265,6 @@ const articleParser = async function (options, socket) {
281265

282266
// Evaluate processed content keywords & keyphrases
283267
Object.assign(article.processed, await keywordParser(article.processed.text.raw, options.retextkeywords))
284-
285268
}
286269

287270
await browser.close()
@@ -483,7 +466,6 @@ const keywordParser = function (html, options) {
483466
}
484467

485468
const lighthouseAnalysis = async function (options, socket) {
486-
487469
socket.emit('parse:status', 'Starting Lighthouse')
488470

489471
// Init puppeteer
@@ -499,7 +481,6 @@ const lighthouseAnalysis = async function (options, socket) {
499481
socket.emit('parse:status', 'Lighthouse Analysis Complete')
500482

501483
return results.lhr
502-
503484
}
504485

505486
const getContent = function (document) {

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"retext-pos": "^2.0.2",
3535
"retext-spell": "^3.0.0",
3636
"sentiment": "^5.0.1",
37+
"url": "^0.11.0",
3738
"vfile-reporter-json": "^2.0.0"
3839
},
3940
"devDependencies": {

testresults.json

Lines changed: 2077 additions & 2059 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)