mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +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",
|
||||
"multiline-comment-style": ["warn", "separate-lines"],
|
||||
"multiline-ternary": "off",
|
||||
"new-cap": "warn",
|
||||
"new-cap": "error",
|
||||
"new-parens": "error",
|
||||
"newline-after-var": "off",
|
||||
"newline-before-return": "off",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"use strict";
|
||||
const events = require("events");
|
||||
const fs = require("fs-extra");
|
||||
const jszip = require("jszip");
|
||||
const JSZip = require("jszip");
|
||||
const path = require("path");
|
||||
const semver = require("semver");
|
||||
|
||||
@@ -27,7 +27,7 @@ const knownScenarios = {
|
||||
* 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.
|
||||
*
|
||||
* @param {module:jszip.JSZip} zip - Zip to search through.
|
||||
* @param {JSZip} zip - Zip to search through.
|
||||
* @returns {string} name of the root folder.
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
@@ -213,7 +213,7 @@ function reorderDependencies(modules) {
|
||||
* @memberof module:lib/factorio
|
||||
*/
|
||||
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 patchInfoFile = root.file("clusterio.json");
|
||||
|
||||
@@ -1751,7 +1751,7 @@ async function startServer() {
|
||||
|
||||
// Only start listening for connections after all plugins have loaded
|
||||
if (httpPort) {
|
||||
httpServer = require("http").Server(app);
|
||||
httpServer = new (require("http").Server)(app);
|
||||
await listen(httpServer, httpPort);
|
||||
console.log("Listening for HTTP on port %s...", httpServer.address().port);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ class DataTable extends Component {
|
||||
sorter = sorter || this.state.sorter;
|
||||
// console.log(pagination, filters, sorter)
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
let data = await this.props.DataFunction();
|
||||
// await fetchApi(this.state.dataUrl, "post", {
|
||||
// database: this.props.Database,
|
||||
@@ -69,6 +70,7 @@ class DataTable extends Component {
|
||||
console.log(data);
|
||||
data = data || {};
|
||||
this.setState({
|
||||
// eslint-disable-next-line new-cap
|
||||
tableData: this.props.CustomDataFilterFunction ? this.props.CustomDataFilterFunction(data) : data,
|
||||
pagination: { ...pagination, ...data.pagination },
|
||||
sorter,
|
||||
|
||||
@@ -15,7 +15,7 @@ const prometheusDoleFactorGauge = new Gauge(
|
||||
{ labels: ["resource"] }
|
||||
);
|
||||
|
||||
class neuralDole {
|
||||
class NeuralDole {
|
||||
|
||||
getRequestStats(itemname,samples)
|
||||
{
|
||||
@@ -46,7 +46,7 @@ class neuralDole {
|
||||
|
||||
doMagic() {
|
||||
for (let [name, count] of this.items._items) {
|
||||
let magicData = doleNN.Tick(
|
||||
let magicData = doleNN.tick(
|
||||
count,
|
||||
this.dole[name],
|
||||
this.itemsLastTick.get(name),
|
||||
@@ -64,7 +64,7 @@ class neuralDole {
|
||||
}
|
||||
|
||||
divider(object) {
|
||||
let magicData = doleNN.Dose(
|
||||
let magicData = doleNN.dose(
|
||||
object.count, // numReq
|
||||
this.items.getItemCount(object.name),
|
||||
this.itemsLastTick.get(object.name) || 0,
|
||||
@@ -131,5 +131,5 @@ function doleDivider({
|
||||
|
||||
module.exports = {
|
||||
doleDivider,
|
||||
neuralDole,
|
||||
NeuralDole,
|
||||
};
|
||||
@@ -41,8 +41,7 @@ function sigmoid3(x)
|
||||
//1.New dole for item X
|
||||
//2.New carry for item X slave Y
|
||||
//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);
|
||||
instore=Number(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
|
||||
//0.New dole for item X
|
||||
//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;
|
||||
if (instore_adj === 0) {
|
||||
instore_adj = 0.1;
|
||||
@@ -121,4 +119,4 @@ function Tick(instore,dole,store_last_tick,numreq_total_adj)
|
||||
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.neuralDole = new dole.neuralDole({ items: this.items });
|
||||
this.neuralDole = new dole.NeuralDole({ items: this.items });
|
||||
this.doleMagicId = setInterval(() => {
|
||||
if (this.master.config.get("subspace_storage.division_method") === "neural_dole") {
|
||||
this.neuralDole.doMagic();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const fs = require("fs-extra");
|
||||
const jszip = require("jszip");
|
||||
const JSZip = require("jszip");
|
||||
const path = require("path");
|
||||
|
||||
const libFactorio = require("@clusterio/lib/factorio");
|
||||
@@ -33,14 +33,14 @@ describe("Integration of lib/factorio/patch", function() {
|
||||
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/subdir/dir/test.lua").async("string"), "-- test\n");
|
||||
});
|
||||
it("should remove old modules in a save", async function() {
|
||||
slowTest(this);
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const fs = require("fs-extra");
|
||||
const jszip = require("jszip");
|
||||
const JSZip = require("jszip");
|
||||
const path = require("path");
|
||||
|
||||
const libFactorio = require("@clusterio/lib/factorio");
|
||||
@@ -10,7 +10,7 @@ const libFactorio = require("@clusterio/lib/factorio");
|
||||
describe("lib/factorio", function() {
|
||||
describe("findRoot()", 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/bar.txt", "");
|
||||
|
||||
@@ -18,7 +18,7 @@ describe("lib/factorio", 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("bar.txt", "");
|
||||
|
||||
@@ -29,7 +29,7 @@ describe("lib/factorio", 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-2/bar.txt", "");
|
||||
|
||||
@@ -40,7 +40,7 @@ describe("lib/factorio", function() {
|
||||
});
|
||||
|
||||
it("should throw if given an empty zip file", function() {
|
||||
let zip = new jszip();
|
||||
let zip = new JSZip();
|
||||
|
||||
assert.throws(
|
||||
() => libFactorio._findRoot(zip),
|
||||
@@ -211,7 +211,7 @@ describe("lib/factorio", function() {
|
||||
|
||||
describe("patch()", function() {
|
||||
it("should throw on unknown scenario", async function() {
|
||||
let zip = new jszip();
|
||||
let zip = new JSZip();
|
||||
zip.file("world/control.lua", "-- unknown\n");
|
||||
let zipPath = path.join("temp", "test", "patch.zip");
|
||||
await fs.outputFile(zipPath, await zip.generateAsync({ type: "nodebuffer" }));
|
||||
|
||||
@@ -582,7 +582,7 @@ describe("lib/prometheus", function() {
|
||||
});
|
||||
it("should throw on unrecoginzed option", function() {
|
||||
assert.throws(
|
||||
() => new prometheus.serializeResult({
|
||||
() => prometheus.serializeResult({
|
||||
metric: new prometheus.Metric("type", "name", "Help"),
|
||||
samples: new Map([["", 3]]),
|
||||
}, { invalid: true }),
|
||||
|
||||
Reference in new issue
Block a user