Skip to content

Commit

Permalink
UPDATE eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Nov 13, 2019
1 parent a6a6613 commit 41d1cd8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"sourceType": "module"
},
"rules": {
"accessor-pairs": "error",
"accessor-pairs": "off",
"array-bracket-newline": "off",
"array-bracket-spacing": [
"error",
Expand Down Expand Up @@ -265,6 +265,7 @@
"single"
],
"radix": "off",
"require-atomic-updates": "off",
"require-await": "off",
"require-jsdoc": "off",
"rest-spread-spacing": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"convert-hrtime": "3.0.0",
"copyfiles": "2.1.1",
"cross-env": "6.0.3",
"eslint": "5.16.0",
"eslint": "6.6.0",
"gzip-size-cli": "3.0.0",
"http-server": "0.11.1",
"karma": "4.4.1",
Expand Down
4 changes: 2 additions & 2 deletions src/leader-election/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import unload from 'unload';

const LeaderElection = function(channel, options) {
const LeaderElection = function (channel, options) {
this._channel = channel;
this._options = options;

Expand Down Expand Up @@ -86,7 +86,7 @@ LeaderElection.prototype = {

awaitLeadership() {
if (
/* _awaitLeadershipPromise */
/* _awaitLeadershipPromise */
!this._aLP
) {
this._aLP = _awaitLeadershipOnce(this);
Expand Down
58 changes: 29 additions & 29 deletions src/methods/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ async function createSocketEventEmitter(channelName, readerUuid, paths) {
const emitter = new events.EventEmitter();
const server = net
.createServer(stream => {
stream.on('end', function() {});
stream.on('data', function(msg) {
stream.on('end', function () { });
stream.on('data', function (msg) {
emitter.emit('data', msg.toString());
});
});
Expand Down Expand Up @@ -348,8 +348,8 @@ async function cleanOldMessages(messageObjects, ttl) {
const olderThen = Date.now() - ttl;
await Promise.all(
messageObjects
.filter(obj => (obj.time / 1000) < olderThen)
.map(obj => unlink(obj.path).catch(() => null))
.filter(obj => (obj.time / 1000) < olderThen)
.map(obj => unlink(obj.path).catch(() => null))
);
}

Expand Down Expand Up @@ -466,9 +466,9 @@ async function handleMessagePing(state, msgObj) {
// read contents
await Promise.all(
useMessages
.map(
msgObj => readMessage(msgObj).then(content => msgObj.content = content)
)
.map(
msgObj => readMessage(msgObj).then(content => msgObj.content = content)
)
);

useMessages.forEach(msgObj => {
Expand All @@ -494,30 +494,30 @@ function refreshReaderClients(channelState) {
.forEach(async (readerUuid) => {
try {
await channelState.otherReaderClients[readerUuid].destroy();
} catch (err) {}
} catch (err) { }
delete channelState.otherReaderClients[readerUuid];
});

// add new readers
return Promise.all(
otherReaders
.filter(readerUuid => readerUuid !== channelState.uuid) // not own
.filter(readerUuid => !channelState.otherReaderClients[readerUuid]) // not already has client
.map(async (readerUuid) => {
try {
if (channelState.closed) return;
.filter(readerUuid => readerUuid !== channelState.uuid) // not own
.filter(readerUuid => !channelState.otherReaderClients[readerUuid]) // not already has client
.map(async (readerUuid) => {
try {
const client = await openClientConnection(channelState.channelName, readerUuid);
channelState.otherReaderClients[readerUuid] = client;
if (channelState.closed) return;
try {
const client = await openClientConnection(channelState.channelName, readerUuid);
channelState.otherReaderClients[readerUuid] = client;
} catch (err) {
// this can throw when the cleanup of another channel was interrupted
// or the socket-file does not exits yet
}
} catch (err) {
// this can throw when the cleanup of another channel was interrupted
// or the socket-file does not exits yet
// this might throw if the other channel is closed at the same time when this one is running refresh
// so we do not throw an error
}
} catch (err) {
// this might throw if the other channel is closed at the same time when this one is running refresh
// so we do not throw an error
}
})
})
);
});
}
Expand Down Expand Up @@ -547,12 +547,12 @@ function postMessage(channelState, messageJson) {

const writeToReadersPromise = Promise.all(
Object.values(channelState.otherReaderClients)
.filter(client => client.writable) // client might have closed in between
.map(client => {
return new Promise(res => {
client.write(pingStr, res);
});
})
.filter(client => client.writable) // client might have closed in between
.map(client => {
return new Promise(res => {
client.write(pingStr, res);
});
})
);

/**
Expand Down Expand Up @@ -627,7 +627,7 @@ function close(channelState) {
if (channelState.infoFilePath) {
try {
fs.unlinkSync(channelState.infoFilePath);
} catch (err) {}
} catch (err) { }
}
}

Expand Down

0 comments on commit 41d1cd8

Please sign in to comment.