Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

refactor: Apply ESLint fixes #580

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
tests/support/var/
2 changes: 2 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const express = require('express');
const fs = require('fs');
const compression = require('compression');

const app = express();
const diggerAPI = require('./routes/api');
const bodyParser = require('body-parser');

app.use(bodyParser.json());

const distPublicDir = './dist/public';
Expand Down
14 changes: 8 additions & 6 deletions engine/browserParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export default class BrowserParser {
read() {
return Promise.all([
cache.readJson(this.urls.webkitCore)
.then((coreResults) =>
.then(coreResults =>
// Combine the web core and javascript core specs and features.
cache.readJson(this.urls.webkitJavaScript).then((jsResults) => {
coreResults.specification = coreResults.specification.concat(jsResults.specification);
coreResults.features = coreResults.features.concat(jsResults.features);
return coreResults;
})
}),
)
.then((results) => {
results.specification.forEach((spec) => {
Expand All @@ -34,21 +34,23 @@ export default class BrowserParser {
});
const merged = results.specification.concat(results.features);
this.results.webkit = new Map(
merged.map(entry => [entry.name, entry])
merged.map(entry => [entry.name, entry]),
);
})
.catch(e => console.warn(`Error retrieving WebKit status: ${e}`)),

cache.readJson(this.urls.chrome)
.then((results) => {
this.results.chrome = new Map(
results.map(entry => [entry.id, entry])
results.map(entry => [entry.id, entry]),
);
})
.catch(e => console.warn(`Error retrieving Chrome status: ${e}`)),

cache.readJson(this.urls.ie)
.then(results => {
.then((results) => {
this.results.ie = new Map(
results.map(entry => [entry.name, entry])
results.map(entry => [entry.name, entry]),
);
})
.catch(e => console.warn(`Error retrieving IE status: ${e}`)),
Expand Down
40 changes: 20 additions & 20 deletions engine/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function selectIndex() {
return resolve();
}
redisIndex = process.env.REDIS_INDEX;
client.select(redisIndex, err => {
client.select(redisIndex, (err) => {
if (err) {
client.quit();
reject(err);
Expand All @@ -28,34 +28,34 @@ function selectIndex() {
function getRequest() {
if (eu) {
return selectIndex()
.then(() => eu);
.then(() => eu);
}
client = redis.createClient({
url: process.env.REDIS_URL,
});
return selectIndex()
.then(() => {
const store = new Eu.RedisStore(client);
const cache = new Eu.Cache(store);
eu = new Eu(cache);
return eu;
});
.then(() => {
const store = new Eu.RedisStore(client);
const cache = new Eu.Cache(store);
eu = new Eu(cache);
return eu;
});
}

function readJson(url) {
return getRequest()
.then(request => new Promise((resolve, reject) => {
// we're getting the JSON anyway (?)
request.get(url, { json: true }, (err, res, body) => {
if (err) {
return reject(err);
}
if (res.statusCode === 404) {
return reject(new Error('Not Found'));
}
resolve(body);
});
}));
.then(request => new Promise((resolve, reject) => {
// we're getting the JSON anyway (?)
request.get(url, { json: true }, (err, res, body) => {
if (err) {
return reject(err);
}
if (res.statusCode === 404) {
return reject(new Error('Not Found'));
}
resolve(body);
});
}));
}

function quitRedis() {
Expand Down
14 changes: 7 additions & 7 deletions engine/digger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import redis from './redis-helper';
// return status as an object
function getStatus() {
return redis.get('status')
.then(status => JSON.parse(status));
.then(status => JSON.parse(status));
}

// return status of a feature as an object
function getFeatureStatus(slug) {
return getStatus()
.then(status => {
if (!status || !status[slug]) {
throw new Error('Not Found');
}
return status[slug];
});
.then((status) => {
if (!status || !status[slug]) {
throw new Error('Not Found');
}
return status[slug];
});
}

export default {
Expand Down
3 changes: 2 additions & 1 deletion engine/fixtureParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import glob from 'glob';
import matter from 'gray-matter';
import MarkdownIt from 'markdown-it';

const markdown = new MarkdownIt();

export default class FixtureParser {
Expand All @@ -21,7 +22,7 @@ export default class FixtureParser {
const meta = matter.read(src);

if (Object.keys(meta.data).length === 0) {
throw new Error(`Error while parsing '${src}'.`);
throw new Error(`Error while parsing '${src}'.`);
}

const summary = markdown.renderInline(meta.content);
Expand Down
Loading