From 8cb21c5fa816059ab2b3b8368a3108e425ecffca Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 17 Jun 2020 14:45:50 +0200 Subject: [PATCH] Add dangling commas Ensure multiline object and array litterals are consistenly typed out with dangling commas for the last element. --- clusterctl.js | 12 +++++----- lib/config/definitions.js | 4 ++-- lib/factorio/server.js | 10 ++++---- lib/link/messages.js | 10 ++++---- lib/manager/modManager.js | 10 ++++---- lib/schema.js | 4 ++-- master.js | 8 +++---- plugins/research_sync/info.js | 2 +- plugins/research_sync/master.js | 2 +- plugins/statistics_exporter/test/plugin.js | 8 +++---- plugins/subspace_storage/dole.js | 4 ++-- test/integration/clusterio.js | 2 +- test/lib/config/classes.js | 26 ++++++++++---------- test/lib/factorio/lines.js | 28 +++++++++++----------- test/lib/prometheus.js | 6 ++--- test/mock.js | 2 +- 16 files changed, 69 insertions(+), 69 deletions(-) diff --git a/clusterctl.js b/clusterctl.js index 2f1f72c4..7f1161f7 100644 --- a/clusterctl.js +++ b/clusterctl.js @@ -202,10 +202,10 @@ commands.push(new Command({ yargs.option("id", { type: "number", nargs: 1, describe: "Slave id", default: null }); yargs.option("name", { type: "string", nargs: 1, describe: "Slave name", default: null }); yargs.option("generate-token", { - type: "boolean", nargs: 0, describe: "Generate authentication token", default: false + type: "boolean", nargs: 0, describe: "Generate authentication token", default: false, }); yargs.option("output", { - type: "string", nargs: 1, describe: "Path to output config (- for stdout)", default: "config-slave.json" + type: "string", nargs: 1, describe: "Path to output config (- for stdout)", default: "config-slave.json", }); }], handler: async function(args, control) { @@ -236,7 +236,7 @@ commands.push(new Command({ handler: async function(args, control) { let response = await link.messages.listInstances.send(control); console.log(asTable(response.list)); - } + }, })); commands.push(new Command({ @@ -258,7 +258,7 @@ commands.push(new Command({ type: "boolean", nargs: 0, describe: "Specify this is a base config", - group: "Instance Config:" + group: "Instance Config:", }); }], handler: async function(args, control) { @@ -433,7 +433,7 @@ commands.push(new Command({ handler: async function(args, control) { let response = await link.messages.sendRcon.send(control, { instance_id: await resolveInstance(control, args.instance), - command: args.command + command: args.command, }); // Factorio includes a newline in it's response output. @@ -469,7 +469,7 @@ commands.push(new Command({ let response = await link.messages.createRole.send(control, { name: args.name, description: args.description, - permissions: args.permissions + permissions: args.permissions, }); console.log(`Created role ID ${response.id}`); }, diff --git a/lib/config/definitions.js b/lib/config/definitions.js index 1d5f0b64..02f2ee6d 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -28,7 +28,7 @@ MasterGroup.define({ title: "HTTP Port", description: "Port to listen for HTTP connections on, set to null to not listen for HTTP connections.", type: "number", - optional: true + optional: true, }); MasterGroup.define({ name: "https_port", @@ -139,7 +139,7 @@ SlaveGroup.define({ name: "factorio_directory", description: "Path to directory to look for factorio installs", type: "string", - initial_value: "factorio" + initial_value: "factorio", }); SlaveGroup.define({ name: "instances_directory", diff --git a/lib/factorio/server.js b/lib/factorio/server.js index c8d4511b..0ca12a86 100644 --- a/lib/factorio/server.js +++ b/lib/factorio/server.js @@ -375,7 +375,7 @@ const outputHeuristics = [ filter: { type: "log", message: /^updateTick\(\d+\) changing state from\(CreatingGame\) to\(InGame\)$/ }, action: function(output) { this._notifyGameReady().catch((err) => { this.emit("error", err); }); - } + }, }, // Message indicating the server has started an autosave @@ -414,14 +414,14 @@ const outputHeuristics = [ }, action: function(output) { this.emit("_saved"); - } + }, }, // Message indicating the server is shutting down { filter: { type: "generic", - message: /^Quitting: / + message: /^Quitting: /, }, action: function(output) { this.emit("_quitting"); @@ -432,7 +432,7 @@ const outputHeuristics = [ if (process.platform === "win32" && output.message === "Quitting: multiplayer error.") { this._server.kill(); } - } + }, }, // Messages that might be tha cause of an unexpected shutdown. @@ -1047,7 +1047,7 @@ class FactorioServer extends events.EventEmitter { path: { "read-data": this.dataPath(), "write-data": this.writePath(), - } + }, }); await fs.outputFile(this.writePath("config.ini"), content); } diff --git a/lib/link/messages.js b/lib/link/messages.js index 42b17f26..85c0e9d3 100644 --- a/lib/link/messages.js +++ b/lib/link/messages.js @@ -122,7 +122,7 @@ class Request extends Message { }, ], }, - } + }, }); } @@ -448,7 +448,7 @@ messages.sendRcon = new Request({ }, responseProperties: { "result": { type: "string" }, - } + }, }); messages.listPermissions = new Request({ @@ -503,7 +503,7 @@ messages.createRole = new Request({ }, responseProperties: { "id": { type: "integer" }, - } + }, }); messages.updateRole = new Request({ @@ -697,7 +697,7 @@ class Event extends Message { if ( this.broadcastTo === "instance" && [ - "instance-slave", "slave-master", "control-master", "master-slave" + "instance-slave", "slave-master", "control-master", "master-slave", ].includes(`${link.target}-${link.source}`) ) { if (!handler) { @@ -759,7 +759,7 @@ messages.instanceInitialized = new Event({ "plugins": { type: "object", additionalProperties: { type: "string" }, - } + }, }, }); messages.instanceStarted = new Event({ diff --git a/lib/manager/modManager.js b/lib/manager/modManager.js index 16b44cde..8dc0fabb 100644 --- a/lib/manager/modManager.js +++ b/lib/manager/modManager.js @@ -54,7 +54,7 @@ async function listMods(config, instance) { factorioAPI.authenticate({ username: config.username, token: config.token, - require_ownership: false + require_ownership: false, }).then(token => { console.log("* Currently installed:"); factorioAPI.readModZips().then(list => { @@ -84,7 +84,7 @@ async function listMods(config, instance) { factorioAPI.authenticate({ username: config.username, token: config.token, - require_ownership: false + require_ownership: false, }).then(() => { console.log("\r\n"); console.log("* Mods shared by all instances:"); @@ -119,7 +119,7 @@ async function findMods(config, searchTerm) { factorioAPI.authenticate({ username: config.username, token: config.token, - require_ownership: false + require_ownership: false, }).then(token => { factorioAPI.searchMods(searchTerm).then(mods => { let result = asTable(mods.reverse().map(mod => { @@ -157,7 +157,7 @@ async function addMod(config, term, instance) { factorioAPI.authenticate({ username: config.username, token: config.token, - require_ownership: false + require_ownership: false, }).then(() => { factorioAPI.searchMods(term.split("/")[term.split("/").length-1]).then(body => { console.log("Im gonna download: "+body[0].name + " in version: " + body[0].latest_release.version); @@ -202,7 +202,7 @@ async function addMod(config, term, instance) { factorioAPI.authenticate({ username: config.username, token: config.token, - require_ownership: false + require_ownership: false, }).then(() => { factorioAPI.searchMods(term).then(body => { console.log(body); diff --git a/lib/schema.js b/lib/schema.js index c354c001..867f2497 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -88,7 +88,7 @@ const serverHandshake = ajv.compile({ type: "object", additionalProperties: { type: "string" }, }, - } + }, }, }, }, @@ -169,7 +169,7 @@ const clientHandshake = ajv.compile({ "token": { type: "string" }, "agent": { type: "string" }, "version": { type: "string" }, - } + }, }, }, }, diff --git a/master.js b/master.js index 7954e00f..1b8bc7c1 100644 --- a/master.js +++ b/master.js @@ -66,7 +66,7 @@ app.use(bodyParser.json({ app.use(bodyParser.urlencoded({ parameterLimit: 100000, limit: "10mb", - extended: true + extended: true, })); app.use(fileUpload()); app.use(compression()); @@ -1220,7 +1220,7 @@ wss.on("connection", function (socket, req) { // Start connection handshake. socket.send(JSON.stringify({ seq: null, type: "hello", data: { version, - plugins: pluginList + plugins: pluginList, }})); function attachHandler() { @@ -1350,7 +1350,7 @@ async function handleHandshake(message, socket, req, attachHandler) { } let sessionId = nextSessionId++; - let sessionToken = jwt.sign({ aud: masterSession, sid: sessionId, }, masterConfig.get("master.auth_secret")); + let sessionToken = jwt.sign({ aud: masterSession, sid: sessionId }, masterConfig.get("master.auth_secret")); let connector = new WebSocketServerConnector(socket, sessionId); activeConnectors.set(sessionId, connector); @@ -1647,7 +1647,7 @@ async function startServer() { httpsServer = require("https").createServer({ key: privateKey, - cert: certificate + cert: certificate, }, app); await listen(httpsServer, httpsPort); console.log("Listening for HTTPS on port %s...", httpsServer.address().port); diff --git a/plugins/research_sync/info.js b/plugins/research_sync/info.js index 16b99d69..c9d85316 100644 --- a/plugins/research_sync/info.js +++ b/plugins/research_sync/info.js @@ -14,7 +14,7 @@ const technologies = { { type: "integer" }, { type: ["null", "number"] }, { type: "boolean" }, - ] + ], }, }; diff --git a/plugins/research_sync/master.js b/plugins/research_sync/master.js index c120bf0e..060b19e6 100644 --- a/plugins/research_sync/master.js +++ b/plugins/research_sync/master.js @@ -184,5 +184,5 @@ async function saveTechnologies(masterConfig, technologies) { module.exports = { - MasterPlugin + MasterPlugin, }; diff --git a/plugins/statistics_exporter/test/plugin.js b/plugins/statistics_exporter/test/plugin.js index 210e070b..52d18595 100644 --- a/plugins/statistics_exporter/test/plugin.js +++ b/plugins/statistics_exporter/test/plugin.js @@ -24,16 +24,16 @@ describe("statistics_exporter plugin", function() { force_flow_statistics: { player: { item_production_statistics: { - input: { "inserter": 10, }, - output: { "iron-plate": 24, } + input: { "inserter": 10 }, + output: { "iron-plate": 24 }, }, - } + }, }, game_flow_statistics: { pollution_statistics: { input: { "boiler": 2000 }, output: { "tree-proxy": 560 }, - } + }, }, }) ); diff --git a/plugins/subspace_storage/dole.js b/plugins/subspace_storage/dole.js index 3b51c88f..60db186b 100644 --- a/plugins/subspace_storage/dole.js +++ b/plugins/subspace_storage/dole.js @@ -30,7 +30,7 @@ class neuralDole { } constructor({ - items + items, }){ // Set some storage variables for the dole divider this.items = items; @@ -127,5 +127,5 @@ function doleDivider({ module.exports = { doleDivider, - neuralDole + neuralDole, }; \ No newline at end of file diff --git a/test/integration/clusterio.js b/test/integration/clusterio.js index 5abbb528..fccc15bf 100644 --- a/test/integration/clusterio.js +++ b/test/integration/clusterio.js @@ -114,7 +114,7 @@ describe("Integration of Clusterio", function() { ], [ "ignore_player_limit_for_returning_players", true, - "ignore-player-limit-for-returning-players", "Ignore player limit for returning players: true." + "ignore-player-limit-for-returning-players", "Ignore player limit for returning players: true.", ], [ "max_players", 11, diff --git a/test/lib/config/classes.js b/test/lib/config/classes.js index 438f9224..fa4b0e24 100644 --- a/test/lib/config/classes.js +++ b/test/lib/config/classes.js @@ -25,35 +25,35 @@ describe("lib/config/classes", function() { for (let [def, error] of [ [ { name: "a", type: "invalid", optional: true }, - "invalid is not a valid type" + "invalid is not a valid type", ], [ { name: [], type: "string", optional: true }, - "name must be a string" + "name must be a string", ], [ { name: "a", type: "string", enum: true, optional: true }, - "enum must be an array" + "enum must be an array", ], [ { name: "a", title: 2, type: "string", optional: true }, - "title must be a string" + "title must be a string", ], [ { name: "a", description: 2, type: "string", optional: true }, - "description must be a string" + "description must be a string", ], [ { name: "a", type: "string", optional: "yes" }, - "optional must be a boolean" + "optional must be a boolean", ], [ { name: "a", type: "string", initial_value: 1 }, - "initial_value must match the type or be a function" + "initial_value must match the type or be a function", ], [ { name: "a", type: "string" }, - "Non-optional field a needs an initial_value" + "Non-optional field a needs an initial_value", ], ]) { assert.throws(() => TestGroup.define(def), new Error(error)); @@ -477,8 +477,8 @@ describe("lib/config/classes", function() { { name: "beta", fields: { bar: {} }, - } - ] + }, + ], }); }); }); @@ -521,7 +521,7 @@ describe("lib/config/classes", function() { { name: "beta", fields: { bar: { value: 20 }}, - } + }, ]; let testInstance = new TestConfig(); @@ -543,7 +543,7 @@ describe("lib/config/classes", function() { { name: "beta", fields: { bar: { value: 30 }}, - } + }, ]}, false); assert.deepEqual(testInstance.serialize(), { @@ -559,7 +559,7 @@ describe("lib/config/classes", function() { { name: "beta", fields: { bar: { value: 30 }}, - } + }, ], }); }); diff --git a/test/lib/factorio/lines.js b/test/lib/factorio/lines.js index 01537b7c..d5ced40e 100644 --- a/test/lib/factorio/lines.js +++ b/test/lib/factorio/lines.js @@ -11,7 +11,7 @@ let testLines = new Map([ level: "Info", file: "RemoteCommandProcessor.cpp:131", message: "Starting RCON interface at port 4000", - } + }, ], [ " 0.622 Warning FileUtil.cpp:527: test not found; using test.zip", @@ -22,7 +22,7 @@ let testLines = new Map([ level: "Warning", file: "FileUtil.cpp:527", message: "test not found; using test.zip", - } + }, ], [ " 0.554 Error Main.cpp:839: require_user_verification must be enabled for public games.", @@ -33,7 +33,7 @@ let testLines = new Map([ level: "Error", file: "Main.cpp:839", message: "require_user_verification must be enabled for public games.", - } + }, ], [ " 640.910 Quitting: remote-quit.", @@ -42,7 +42,7 @@ let testLines = new Map([ time: "640.910", type: "generic", message: "Quitting: remote-quit.", - } + }, ], [ "1641.421 Goodbye", @@ -51,7 +51,7 @@ let testLines = new Map([ time: "1641.421", type: "generic", message: "Goodbye", - } + }, ], [ "2019-01-20 10:30:04 [JOIN] User joined the game", @@ -61,7 +61,7 @@ let testLines = new Map([ type: "action", action: "JOIN", message: "User joined the game", - } + }, ], [ "2019-01-20 10:30:07 [CHAT] User: chat message", @@ -71,7 +71,7 @@ let testLines = new Map([ type: "action", action: "CHAT", message: "User: chat message", - } + }, ], [ "2019-01-20 10:30:14 [COMMAND] User (command): blah", @@ -81,7 +81,7 @@ let testLines = new Map([ type: "action", action: "COMMAND", message: "User (command): blah", - } + }, ], [ "2019-01-20 10:30:14 Cannot execute command. Error: [string \"blah\"]:1: syntax error near ", @@ -90,7 +90,7 @@ let testLines = new Map([ time: "2019-01-20 10:30:14", type: "generic", message: "Cannot execute command. Error: [string \"blah\"]:1: syntax error near ", - } + }, ], [ "2019-01-20 10:30:21 [LEAVE] User left the game", @@ -100,7 +100,7 @@ let testLines = new Map([ type: "action", action: "LEAVE", message: "User left the game", - } + }, ], [ "Error while running event level::on_nth_tick(1)", @@ -108,7 +108,7 @@ let testLines = new Map([ format: "none", type: "generic", message: "Error while running event level::on_nth_tick(1)", - } + }, ], [ "4802.763 Info AppManager.cpp:287: Saving to _autosave4 (blocking).", @@ -119,7 +119,7 @@ let testLines = new Map([ level: "Info", file: "AppManager.cpp:287", message: "Saving to _autosave4 (blocking).", - } + }, ], [ " 10.806 Info AppManager.cpp:394: Saving game as C:\\factorio\\saves\\world.zip", @@ -130,7 +130,7 @@ let testLines = new Map([ level: "Info", file: "AppManager.cpp:394", message: "Saving game as C:\\factorio\\saves\\world.zip", - } + }, ], [ "4202.780 Info AppManagerStates.cpp:1802: Saving finished", @@ -141,7 +141,7 @@ let testLines = new Map([ level: "Info", file: "AppManagerStates.cpp:1802", message: "Saving finished", - } + }, ], ]); diff --git a/test/lib/prometheus.js b/test/lib/prometheus.js index f8fa5433..9f5f96b9 100644 --- a/test/lib/prometheus.js +++ b/test/lib/prometheus.js @@ -523,7 +523,7 @@ describe("lib/prometheus", function() { let serializedResult = { metric: { type: "type", name: "name", help: "Help", labels: ["a", "b"] }, - samples: [ ['a="1",b="2"', 1], ['a="3",b="4"', 5], ] + samples: [ ['a="1",b="2"', 1], ['a="3",b="4"', 5] ], }; let deserializedResult = { metric: new prometheus.Metric("type", "name", "Help", ["a", "b"]), @@ -563,7 +563,7 @@ describe("lib/prometheus", function() { prometheus.serializeResult({ metric: new prometheus.Metric("type", "name", "Help"), samples: new Map([["", 2]]), - }, { metricName: "new", }), + }, { metricName: "new" }), { metric: { type: "type", name: "new", help: "Help", labels: [] }, samples: [["", 2]], @@ -573,7 +573,7 @@ describe("lib/prometheus", function() { prometheus.serializeResult({ metric: new prometheus.Metric("type", "name", "Help"), samples: new Map([["", 2]]), - }, { metricHelp: "old", }), + }, { metricHelp: "old" }), { metric: { type: "type", name: "name", help: "old", labels: [] }, samples: [["", 2]], diff --git a/test/mock.js b/test/mock.js index 71efcd72..c919d57c 100644 --- a/test/mock.js +++ b/test/mock.js @@ -69,7 +69,7 @@ class MockInstance extends link.Link { get: (name) => { if (name === "instance.id") { return 7357; } throw Error("Not implemented"); - } + }, }; } }