Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed May 30, 2018
1 parent 8e0d5b0 commit 8e982a3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
9 changes: 3 additions & 6 deletions lib/backend/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,22 @@ module.exports = function (core) {
countDb += 1;
timerDb = setTimeout(() => {
timerDb = null;
const rev = core.rev;
pjson.save(core.name + '.docs', {rev: core.rev, db: core.db}, () => {
core.log.debug('saved', core.name + '.docs rev', rev);
core.log.debug('saved', core.name + '.docs rev', core.rev);
});
}, timeout);
} else if (timerDb) {
clearTimeout(timerDb);
timerDb = null;
countDb = 0;
const rev = core.rev;
pjson.save(core.name + '.docs', {rev: core.rev, db: core.db}, () => {
core.log.debug('saved', core.name + '.docs rev', rev);
core.log.debug('saved', core.name + '.docs rev', core.rev);
});
} else {
timerDb = setTimeout(() => {
timerDb = null;
const rev = core.rev;
pjson.save(core.name + '.docs', {rev: core.rev, db: core.db}, () => {
core.log.debug('saved', core.name + '.docs rev', rev);
core.log.debug('saved', core.name + '.docs rev', core.rev);
});
}, timeout);
}
Expand Down
9 changes: 3 additions & 6 deletions lib/core.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* eslint-disable no-case-declarations, no-restricted-modules */

const os = require('os');
const path = require('path');
const cluster = require('cluster');
const EventEmitter = require('events').EventEmitter;
const {EventEmitter} = require('events');
const oe = require('obj-ease');

let time;
Expand All @@ -28,8 +26,8 @@ class Core extends EventEmitter {

/* istanbul ignore else */
if (config.verbosity === 'debug') {
time = console.time;
timeEnd = console.timeEnd;
time = console.time; // eslint-disable-line prefer-destructuring
timeEnd = console.timeEnd; // eslint-disable-line prefer-destructuring
} else {
time = () => {};
timeEnd = () => {};
Expand Down Expand Up @@ -290,7 +288,6 @@ class Core extends EventEmitter {
this.log.debug('sending query', id, 'to worker', workerId, payload);
this.workers[workerId].send({type: 'query', id, payload, init: init ? this.views[id] : undefined});
}

}

module.exports = Core;
18 changes: 9 additions & 9 deletions lib/worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const domain = require('domain'); // eslint-disable-line no-restricted-modules
const domain = require('domain');
const vm = require('vm');
const oe = require('obj-ease');
const mqttWildcard = require('mqtt-wildcard');
Expand Down Expand Up @@ -63,9 +63,7 @@ class Views {
// Create/overwrite view
this.queries[id] = payload;

const map = payload.map;
const reduce = payload.reduce;
const filter = payload.filter;
const {map, reduce, filter} = payload;

if (!this.viewsEnv[id]) {
this.viewsEnv[id] = {};
Expand Down Expand Up @@ -133,7 +131,8 @@ class Views {
api: {
/**
* @method api.forEachDocument
* @param {forEachDocumentCallback} callback
* @param {forEachDocumentCallback} callback function called for each document
* @returns {undefined}
* @description executes a provided function once for each document. Mind that using this
* function inside a map script can result in O(n²) complexity and could ruin view
* composition performance. If you need it you should instead use it in the reduce script.
Expand Down Expand Up @@ -175,7 +174,8 @@ class Views {
},
/**
* @method emit
* @param {*} item
* @param {*} item data that gets pushed to the result array
* @returns {undefined}
* @description push an item to the result array
*/
emit: item => Sandbox.api._result.push(item)
Expand All @@ -193,11 +193,11 @@ class Views {

execView(id, callback) {
time(process.pid + ' execView ' + id);
const script = this.viewsEnv[id].script;
const {script} = this.viewsEnv[id];
time(process.pid + ' create domain ' + id);
const viewDomain = domain.create();
timeEnd(process.pid + ' create domain ' + id);
const context = this.viewsEnv[id].context;
const {context} = this.viewsEnv[id];

viewDomain.on('error', err => {
this.views[id].error = 'script execution: ' + err.message;
Expand All @@ -209,7 +209,7 @@ class Views {

viewDomain.run(() => {
setImmediate(() => {
const rev = this.rev;
const {rev} = this;
time(process.pid + ' runInContext ' + id);
script.runInContext(context, {
filename: 'view-' + id,
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"space": 4,
"ignore": [
"test/test.js"
]
],
"rules": {
"no-case-declarations": "warn",
"no-restricted-modules": "warn",
"node/no-deprecated-api": "warn"
}
}
}

0 comments on commit 8e982a3

Please sign in to comment.