Skip to content

Commit

Permalink
chore(lint): follow new airbnb eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
yujiosaka committed Jun 24, 2018
1 parent febc78f commit 76e5b99
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions examples/custom-cache.js
Expand Up @@ -10,23 +10,28 @@ class FsCache extends BaseCache {
fs.writeFileSync(this._settings.file, '{}');
return Promise.resolve();
}

clear() {
fs.unlinkSync(this._settings.file);
return Promise.resolve();
}

close() {
return Promise.resolve();
}

get(key) {
const obj = JSON.parse(fs.readFileSync(this._settings.file));
return Promise.resolve(obj[key] || null);
}

set(key, value) {
const obj = JSON.parse(fs.readFileSync(this._settings.file));
obj[key] = value;
fs.writeFileSync(this._settings.file, JSON.stringify(obj));
return Promise.resolve();
}

enqueue(key, value, priority) {
const obj = JSON.parse(fs.readFileSync(this._settings.file));
const queue = obj[key] || [];
Expand All @@ -37,6 +42,7 @@ class FsCache extends BaseCache {
fs.writeFileSync(this._settings.file, JSON.stringify(obj));
return Promise.resolve();
}

dequeue(key) {
const obj = JSON.parse(fs.readFileSync(this._settings.file));
const queue = obj[key] || [];
Expand All @@ -45,11 +51,13 @@ class FsCache extends BaseCache {
if (!item) return Promise.resolve(null);
return Promise.resolve(item.value);
}

size(key) {
const obj = JSON.parse(fs.readFileSync(this._settings.file));
if (!obj[key]) return Promise.resolve(0);
return Promise.resolve(obj[key].length);
}

remove(key) {
const obj = JSON.parse(fs.readFileSync(this._settings.file));
delete obj[key];
Expand Down
1 change: 1 addition & 0 deletions examples/custom-exporter.js
Expand Up @@ -17,6 +17,7 @@ class InspectExporter extends BaseExporter {
}

writeHeader() {}

writeFooter() {}
}

Expand Down
1 change: 1 addition & 0 deletions lib/hccrawler.js
Expand Up @@ -554,6 +554,7 @@ class HCCrawler extends EventEmitter {
const page = await this._browser.newPage();
return new Crawler(page, options, depth, previousUrl);
}

/**
* @param {!Crawler} crawler
* @return {!Promise<!Object>}
Expand Down
2 changes: 1 addition & 1 deletion lib/helper.js
Expand Up @@ -76,7 +76,7 @@ class Helper {
const { protocol } = parse(url);
if (includes(['http:', 'https:'], protocol)) {
return url.split('#')[0];
} else if (!protocol) {
} else if (!protocol) { // eslint-disable-line no-else-return
return resolve(baseUrl, url).split('#')[0];
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/priority-queue.js
@@ -1,5 +1,5 @@
const AsyncEventEmitter = require('./async-events');
const noop = require('lodash/noop');
const AsyncEventEmitter = require('./async-events');
const { tracePublicAPI } = require('./helper');

const KEY = 'queue';
Expand Down

0 comments on commit 76e5b99

Please sign in to comment.