mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Fix capitalization of constructors
Enforce new-cap rule and fix capitalization and mistakes related to constructors.
This commit is contained in:
1 parent
00a1f6aea7
commit
8586dfb95f
10 files changed
+25
-25
No files matched your search
+1
-1
@@ -111,7 +111,7 @@ module.exports = {
|
|||||||
"max-statements-per-line": "off",
|
"max-statements-per-line": "off",
|
||||||
"multiline-comment-style": ["warn", "separate-lines"],
|
"multiline-comment-style": ["warn", "separate-lines"],
|
||||||
"multiline-ternary": "off",
|
"multiline-ternary": "off",
|
||||||
"new-cap": "warn",
|
"new-cap": "error",
|
||||||
"new-parens": "error",
|
"new-parens": "error",
|
||||||
"newline-after-var": "off",
|
"newline-after-var": "off",
|
||||||
"newline-before-return": "off",
|
"newline-before-return": "off",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const events = require("events");
|
const events = require("events");
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
const jszip = require("jszip");
|
const JSZip = require("jszip");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ const knownScenarios = {
|
|||||||
* Returns the name of the folder that all files in the zip file is
|
* Returns the name of the folder that all files in the zip file is
|
||||||
* contained in. Throws an error if there are multiple such folders.
|
* contained in. Throws an error if there are multiple such folders.
|
||||||
*
|
*
|
||||||
* @param {module:jszip.JSZip} zip - Zip to search through.
|
* @param {JSZip} zip - Zip to search through.
|
||||||
* @returns {string} name of the root folder.
|
* @returns {string} name of the root folder.
|
||||||
* @memberof module:lib/factorio
|
* @memberof module:lib/factorio
|
||||||
* @private
|
* @private
|
||||||
@@ -213,7 +213,7 @@ function reorderDependencies(modules) {
|
|||||||
* @memberof module:lib/factorio
|
* @memberof module:lib/factorio
|
||||||
*/
|
*/
|
||||||
async function patch(savePath, modules) {
|
async function patch(savePath, modules) {
|
||||||
let zip = await jszip.loadAsync(await fs.readFile(savePath));
|
let zip = await JSZip.loadAsync(await fs.readFile(savePath));
|
||||||
let root = zip.folder(findRoot(zip));
|
let root = zip.folder(findRoot(zip));
|
||||||
|
|
||||||
let patchInfoFile = root.file("clusterio.json");
|
let patchInfoFile = root.file("clusterio.json");
|
||||||
|
|||||||
@@ -1751,7 +1751,7 @@ async function startServer() {
|
|||||||
|
|
||||||
// Only start listening for connections after all plugins have loaded
|
// Only start listening for connections after all plugins have loaded
|
||||||
if (httpPort) {
|
if (httpPort) {
|
||||||
httpServer = require("http").Server(app);
|
httpServer = new (require("http").Server)(app);
|
||||||
await listen(httpServer, httpPort);
|
await listen(httpServer, httpPort);
|
||||||
console.log("Listening for HTTP on port %s...", httpServer.address().port);
|
console.log("Listening for HTTP on port %s...", httpServer.address().port);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class DataTable extends Component {
|
|||||||
sorter = sorter || this.state.sorter;
|
sorter = sorter || this.state.sorter;
|
||||||
// console.log(pagination, filters, sorter)
|
// console.log(pagination, filters, sorter)
|
||||||
|
|
||||||
|
// eslint-disable-next-line new-cap
|
||||||
let data = await this.props.DataFunction();
|
let data = await this.props.DataFunction();
|
||||||
// await fetchApi(this.state.dataUrl, "post", {
|
// await fetchApi(this.state.dataUrl, "post", {
|
||||||
// database: this.props.Database,
|
// database: this.props.Database,
|
||||||
@@ -69,6 +70,7 @@ class DataTable extends Component {
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
data = data || {};
|
data = data || {};
|
||||||
this.setState({
|
this.setState({
|
||||||
|
// eslint-disable-next-line new-cap
|
||||||
tableData: this.props.CustomDataFilterFunction ? this.props.CustomDataFilterFunction(data) : data,
|
tableData: this.props.CustomDataFilterFunction ? this.props.CustomDataFilterFunction(data) : data,
|
||||||
pagination: { ...pagination, ...data.pagination },
|
pagination: { ...pagination, ...data.pagination },
|
||||||
sorter,
|
sorter,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const prometheusDoleFactorGauge = new Gauge(
|
|||||||
{ labels: ["resource"] }
|
{ labels: ["resource"] }
|
||||||
);
|
);
|
||||||
|
|
||||||
class neuralDole {
|
class NeuralDole {
|
||||||
|
|
||||||
getRequestStats(itemname,samples)
|
getRequestStats(itemname,samples)
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ class neuralDole {
|
|||||||
|
|
||||||
doMagic() {
|
doMagic() {
|
||||||
for (let [name, count] of this.items._items) {
|
for (let [name, count] of this.items._items) {
|
||||||
let magicData = doleNN.Tick(
|
let magicData = doleNN.tick(
|
||||||
count,
|
count,
|
||||||
this.dole[name],
|
this.dole[name],
|
||||||
this.itemsLastTick.get(name),
|
this.itemsLastTick.get(name),
|
||||||
@@ -64,7 +64,7 @@ class neuralDole {
|
|||||||
}
|
}
|
||||||
|
|
||||||
divider(object) {
|
divider(object) {
|
||||||
let magicData = doleNN.Dose(
|
let magicData = doleNN.dose(
|
||||||
object.count, // numReq
|
object.count, // numReq
|
||||||
this.items.getItemCount(object.name),
|
this.items.getItemCount(object.name),
|
||||||
this.itemsLastTick.get(object.name) || 0,
|
this.itemsLastTick.get(object.name) || 0,
|
||||||
@@ -131,5 +131,5 @@ function doleDivider({
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
doleDivider,
|
doleDivider,
|
||||||
neuralDole,
|
NeuralDole,
|
||||||
};
|
};
|
||||||
@@ -41,8 +41,7 @@ function sigmoid3(x)
|
|||||||
//1.New dole for item X
|
//1.New dole for item X
|
||||||
//2.New carry for item X slave Y
|
//2.New carry for item X slave Y
|
||||||
//3.New debt
|
//3.New debt
|
||||||
function Dose(numreq,instore,store_last_tick,dole,carry,prev_req,numreq_total_adj,debt)
|
function dose(numreq, instore, store_last_tick, dole, carry, prev_req, numreq_total_adj, debt) {
|
||||||
{
|
|
||||||
numreq=Number(numreq);
|
numreq=Number(numreq);
|
||||||
instore=Number(instore);
|
instore=Number(instore);
|
||||||
var instore_adj=instore;
|
var instore_adj=instore;
|
||||||
@@ -96,8 +95,7 @@ function Dose(numreq,instore,store_last_tick,dole,carry,prev_req,numreq_total_ad
|
|||||||
//Returns: Array of 2 elements
|
//Returns: Array of 2 elements
|
||||||
//0.New dole for item X
|
//0.New dole for item X
|
||||||
//1.Guessed percentage average of items supplied in last 10 ticks
|
//1.Guessed percentage average of items supplied in last 10 ticks
|
||||||
function Tick(instore,dole,store_last_tick,numreq_total_adj)
|
function tick(instore, dole, store_last_tick, numreq_total_adj) {
|
||||||
{
|
|
||||||
var instore_adj=instore;
|
var instore_adj=instore;
|
||||||
if (instore_adj === 0) {
|
if (instore_adj === 0) {
|
||||||
instore_adj = 0.1;
|
instore_adj = 0.1;
|
||||||
@@ -121,4 +119,4 @@ function Tick(instore,dole,store_last_tick,numreq_total_adj)
|
|||||||
return [sigmoid0(outputs[0]),avg];
|
return [sigmoid0(outputs[0]),avg];
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { Dose,Tick };
|
module.exports = { dose, tick };
|
||||||
@@ -40,7 +40,7 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
|
|||||||
});
|
});
|
||||||
}, this.master.config.get("subspace_storage.autosave_interval") * 1000);
|
}, this.master.config.get("subspace_storage.autosave_interval") * 1000);
|
||||||
|
|
||||||
this.neuralDole = new dole.neuralDole({ items: this.items });
|
this.neuralDole = new dole.NeuralDole({ items: this.items });
|
||||||
this.doleMagicId = setInterval(() => {
|
this.doleMagicId = setInterval(() => {
|
||||||
if (this.master.config.get("subspace_storage.division_method") === "neural_dole") {
|
if (this.master.config.get("subspace_storage.division_method") === "neural_dole") {
|
||||||
this.neuralDole.doMagic();
|
this.neuralDole.doMagic();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const assert = require("assert").strict;
|
const assert = require("assert").strict;
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
const jszip = require("jszip");
|
const JSZip = require("jszip");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const libFactorio = require("@clusterio/lib/factorio");
|
const libFactorio = require("@clusterio/lib/factorio");
|
||||||
@@ -33,14 +33,14 @@ describe("Integration of lib/factorio/patch", function() {
|
|||||||
require: [],
|
require: [],
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
let zip = await jszip.loadAsync(await fs.readFile(savePath));
|
let zip = await JSZip.loadAsync(await fs.readFile(savePath));
|
||||||
assert.equal(await zip.file("test/modules/test/test.lua").async("string"), "-- test\n");
|
assert.equal(await zip.file("test/modules/test/test.lua").async("string"), "-- test\n");
|
||||||
assert.equal(await zip.file("test/modules/subdir/dir/test.lua").async("string"), "-- test\n");
|
assert.equal(await zip.file("test/modules/subdir/dir/test.lua").async("string"), "-- test\n");
|
||||||
});
|
});
|
||||||
it("should remove old modules in a save", async function() {
|
it("should remove old modules in a save", async function() {
|
||||||
slowTest(this);
|
slowTest(this);
|
||||||
await libFactorio.patch(savePath, []);
|
await libFactorio.patch(savePath, []);
|
||||||
let zip = await jszip.loadAsync(await fs.readFile(savePath));
|
let zip = await JSZip.loadAsync(await fs.readFile(savePath));
|
||||||
assert.equal(zip.file("test/modules/test/test.lua"), null);
|
assert.equal(zip.file("test/modules/test/test.lua"), null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const assert = require("assert").strict;
|
const assert = require("assert").strict;
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
const jszip = require("jszip");
|
const JSZip = require("jszip");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const libFactorio = require("@clusterio/lib/factorio");
|
const libFactorio = require("@clusterio/lib/factorio");
|
||||||
@@ -10,7 +10,7 @@ const libFactorio = require("@clusterio/lib/factorio");
|
|||||||
describe("lib/factorio", function() {
|
describe("lib/factorio", function() {
|
||||||
describe("findRoot()", function() {
|
describe("findRoot()", function() {
|
||||||
it("should find the root of a zip", function() {
|
it("should find the root of a zip", function() {
|
||||||
let zip = new jszip();
|
let zip = new JSZip();
|
||||||
zip.file("root/foo.txt", "");
|
zip.file("root/foo.txt", "");
|
||||||
zip.file("root/bar.txt", "");
|
zip.file("root/bar.txt", "");
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ describe("lib/factorio", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should throw if files are at the root of the zip", function() {
|
it("should throw if files are at the root of the zip", function() {
|
||||||
let zip = new jszip();
|
let zip = new JSZip();
|
||||||
zip.file("root/foo.txt", "");
|
zip.file("root/foo.txt", "");
|
||||||
zip.file("bar.txt", "");
|
zip.file("bar.txt", "");
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ describe("lib/factorio", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should throw if there are multiple root dirs", function() {
|
it("should throw if there are multiple root dirs", function() {
|
||||||
let zip = new jszip();
|
let zip = new JSZip();
|
||||||
zip.file("root-1/foo.txt", "");
|
zip.file("root-1/foo.txt", "");
|
||||||
zip.file("root-2/bar.txt", "");
|
zip.file("root-2/bar.txt", "");
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ describe("lib/factorio", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should throw if given an empty zip file", function() {
|
it("should throw if given an empty zip file", function() {
|
||||||
let zip = new jszip();
|
let zip = new JSZip();
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => libFactorio._findRoot(zip),
|
() => libFactorio._findRoot(zip),
|
||||||
@@ -211,7 +211,7 @@ describe("lib/factorio", function() {
|
|||||||
|
|
||||||
describe("patch()", function() {
|
describe("patch()", function() {
|
||||||
it("should throw on unknown scenario", async function() {
|
it("should throw on unknown scenario", async function() {
|
||||||
let zip = new jszip();
|
let zip = new JSZip();
|
||||||
zip.file("world/control.lua", "-- unknown\n");
|
zip.file("world/control.lua", "-- unknown\n");
|
||||||
let zipPath = path.join("temp", "test", "patch.zip");
|
let zipPath = path.join("temp", "test", "patch.zip");
|
||||||
await fs.outputFile(zipPath, await zip.generateAsync({ type: "nodebuffer" }));
|
await fs.outputFile(zipPath, await zip.generateAsync({ type: "nodebuffer" }));
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ describe("lib/prometheus", function() {
|
|||||||
});
|
});
|
||||||
it("should throw on unrecoginzed option", function() {
|
it("should throw on unrecoginzed option", function() {
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => new prometheus.serializeResult({
|
() => prometheus.serializeResult({
|
||||||
metric: new prometheus.Metric("type", "name", "Help"),
|
metric: new prometheus.Metric("type", "name", "Help"),
|
||||||
samples: new Map([["", 3]]),
|
samples: new Map([["", 3]]),
|
||||||
}, { invalid: true }),
|
}, { invalid: true }),
|
||||||
|
|||||||
Reference in new issue
Block a user