diff --git a/.eslintrc.js b/.eslintrc.js index a6e7c847..f82a6194 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -177,7 +177,7 @@ module.exports = { "no-octal-escape": "error", "no-param-reassign": "off", "no-path-concat": "error", - "no-plusplus": ["warn", { "allowForLoopAfterthoughts": true }], + "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }], "no-process-env": "error", "no-process-exit": "warn", "no-proto": "error", diff --git a/packages/lib/factorio/patch.js b/packages/lib/factorio/patch.js index 7e9fbec6..6b70b1d2 100644 --- a/packages/lib/factorio/patch.js +++ b/packages/lib/factorio/patch.js @@ -152,7 +152,7 @@ function reorderDependencies(modules) { // No unmet dependencies, record and continue present.set(module.name, module.version); - index++; + index += 1; if (hold.has(module.name)) { modules.splice(index, 0, ...hold.get(module.name)); diff --git a/packages/lib/link/connectors.js b/packages/lib/link/connectors.js index 37f9c05e..a8d494c9 100644 --- a/packages/lib/link/connectors.js +++ b/packages/lib/link/connectors.js @@ -34,7 +34,7 @@ class WebSocketBaseConnector extends events.EventEmitter { let dropCount = 0; for (let index = 0; index < this._sendBuffer.length; index++) { if (this._sendBuffer[index].seq <= seq) { - dropCount++; + dropCount += 1; } else { break; } @@ -102,12 +102,14 @@ class WebSocketBaseConnector extends events.EventEmitter { if (!["handshake", "connected", "closing"].includes(this._state)) { throw new libErrors.SessionLost("No session"); } - let message = { seq: this._seq, type, data }; + let seq = this._seq; + this._seq += 1; + let message = { seq, type, data }; this._sendBuffer.push(message); if (["connected", "closing"].includes(this._state)) { this._socket.send(JSON.stringify(message)); } - return this._seq++; + return seq; } /** @@ -450,8 +452,10 @@ class VirtualConnector extends events.EventEmitter { * @returns {number} the sequence number of the message sent */ send(type, data) { - this.other.emit("message", { seq: this._seq, type, data }); - return this._seq++; + let seq = this._seq; + this._seq += 1; + this.other.emit("message", { seq, type, data }); + return seq; } } diff --git a/packages/master/master.js b/packages/master/master.js index 6268151a..32827da3 100755 --- a/packages/master/master.js +++ b/packages/master/master.js @@ -1429,7 +1429,8 @@ async function handleHandshake(message, socket, req, attachHandler) { return; } - let sessionId = nextSessionId++; + let sessionId = nextSessionId; + nextSessionId += 1; let sessionToken = jwt.sign({ aud: masterSession, sid: sessionId }, masterConfig.get("master.auth_secret")); let connector = new WebSocketServerConnector(socket, sessionId); activeConnectors.set(sessionId, connector); diff --git a/plugins/global_chat/test/plugin.js b/plugins/global_chat/test/plugin.js index 7576a9b6..f371d360 100644 --- a/plugins/global_chat/test/plugin.js +++ b/plugins/global_chat/test/plugin.js @@ -46,7 +46,7 @@ describe("global_chat plugin", function() { instancePlugin.instance.connector.sentMessages = []; await instancePlugin.onOutput(output); assert(instancePlugin.instance.connector.sentMessages.length, "message was not sent"); - count++; + count += 1; } } assert(count > 0, "no lines were tested"); @@ -58,7 +58,7 @@ describe("global_chat plugin", function() { instancePlugin.instance.connector.sentMessages = []; await instancePlugin.onOutput(output); assert(!instancePlugin.instance.connector.sentMessages.length, "message was sent"); - count++; + count += 1; } } assert(count > 0, "no lines were tested"); diff --git a/test/integration/export.js b/test/integration/export.js index c7dc20f8..dccfbb10 100644 --- a/test/integration/export.js +++ b/test/integration/export.js @@ -24,7 +24,7 @@ describe("Integration of lib/factorio/export", function() { // Value is always a string, nearly always truthy if (!value) { - empty_keys++; + empty_keys += 1; } assert.equal(typeof value, "string"); } diff --git a/test/lib/factorio/patch.js b/test/lib/factorio/patch.js index d5d1bdfb..00850590 100644 --- a/test/lib/factorio/patch.js +++ b/test/lib/factorio/patch.js @@ -199,7 +199,7 @@ describe("lib/factorio", function() { } catch (err) { } if (success) { validate(modules); - successCount++; + successCount += 1; } } diff --git a/test/mock.js b/test/mock.js index 9b9f6cdb..c8cddfbb 100644 --- a/test/mock.js +++ b/test/mock.js @@ -58,10 +58,12 @@ class MockConnector extends events.EventEmitter { } send(type, data) { - let message = { seq: this._seq, type, data }; + let seq = this._seq; + this._seq += 1; + let message = { seq, type, data }; this.sentMessages.push(message); setImmediate(() => this.emit("send", message)); - return this._seq++; + return seq; } }