mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Use strict equality checking
Remove usage of == and != in favour of === and !==.
This commit is contained in:
1 parent
ee81fbb7f6
commit
a84f2d5eb6
13 files changed
+29
-21
No files matched your search
+1
-1
@@ -73,7 +73,7 @@ module.exports = {
|
||||
"dot-location": ["error", "property"],
|
||||
"dot-notation": ["warn", { "allowKeywords": true }],
|
||||
"eol-last": "error",
|
||||
"eqeqeq": "warn",
|
||||
"eqeqeq": "error",
|
||||
"func-call-spacing": "error",
|
||||
"func-name-matching": "error",
|
||||
"func-names": "off",
|
||||
|
||||
@@ -55,7 +55,7 @@ async function loadJsonAsMap(filePath) {
|
||||
return new Map(Object.entries(parsed));
|
||||
|
||||
} catch (err) {
|
||||
if (err.code == "ENOENT") {
|
||||
if (err.code === "ENOENT") {
|
||||
// File does not exist, return empty map
|
||||
return new Map();
|
||||
|
||||
@@ -117,7 +117,7 @@ async function loadJsonArrayAsMap(filePath) {
|
||||
return map;
|
||||
|
||||
} catch (err) {
|
||||
if (err.code == "ENOENT") {
|
||||
if (err.code === "ENOENT") {
|
||||
// File does not exist, return empty map
|
||||
return new Map();
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ async function generatePassword(length) {
|
||||
|
||||
if (validChar(byte)) {
|
||||
password += String.fromCharCode(byte);
|
||||
if (password.length == length) {
|
||||
if (password.length === length) {
|
||||
return password;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
|
||||
}
|
||||
|
||||
let { seq, type, data } = message;
|
||||
if (type == "hello") {
|
||||
if (type === "hello") {
|
||||
console.log(`SOCKET | received hello from master version ${data.version}`);
|
||||
this.emit("hello", data);
|
||||
if (this._sessionToken) {
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports.isJSON = function(string){
|
||||
} catch (e){
|
||||
return false;
|
||||
}
|
||||
if(typeof x == "object" || typeof string == "object"){
|
||||
if (typeof x === "object" || typeof string === "object"){
|
||||
stringIsJson = true;
|
||||
}
|
||||
return stringIsJson;
|
||||
|
||||
@@ -118,7 +118,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
|
||||
this.technologies.set(name, { level, progress, researched });
|
||||
if (progress) {
|
||||
this.progressToBroadcast.add(name);
|
||||
} else if (researched || baseLevel(name) != level) {
|
||||
} else if (researched || baseLevel(name) !== level) {
|
||||
this.broadcastEventToSlaves(this.info.messages.finished, { name, level });
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ class neuralDole {
|
||||
for (var i = 1; i <= samples; i++) {
|
||||
sum+=this.stats[itemname][i].req;
|
||||
}
|
||||
if (sum==0) return 0.1;
|
||||
if (sum === 0) {
|
||||
return 0.1;
|
||||
}
|
||||
return sum/samples;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ function Dose(numreq,instore,store_last_tick,dole,carry,prev_req,numreq_total_ad
|
||||
numreq=Number(numreq);
|
||||
instore=Number(instore);
|
||||
var instore_adj=instore;
|
||||
if (instore_adj==0) instore_adj=0.1;
|
||||
if (instore_adj === 0) {
|
||||
instore_adj = 0.1;
|
||||
}
|
||||
|
||||
var b=Math.trunc(prev_req/instore_adj*numreq);
|
||||
var inp1=[numreq,instore_adj,store_last_tick/numreq,dole,carry];//0..4
|
||||
@@ -97,7 +99,9 @@ function Dose(numreq,instore,store_last_tick,dole,carry,prev_req,numreq_total_ad
|
||||
function Tick(instore,dole,store_last_tick,numreq_total_adj)
|
||||
{
|
||||
var instore_adj=instore;
|
||||
if (instore_adj==0) instore_adj=0.1;
|
||||
if (instore_adj === 0) {
|
||||
instore_adj = 0.1;
|
||||
}
|
||||
var inputs=[instore,dole,store_last_tick/instore_adj,store_last_tick/numreq_total_adj,store_last_tick,numreq_total_adj];
|
||||
var internal=new Array(10).fill(0);
|
||||
var outputs=[0,0];
|
||||
|
||||
@@ -17,7 +17,9 @@ describe("subspace_storage endpoints", function() {
|
||||
|
||||
let contains20SteelPlate = false;
|
||||
inventory.forEach(itemStack => {
|
||||
if(itemStack.name == "steel-plate" && itemStack.count >= 20) contains20SteelPlate = true;
|
||||
if (itemStack.name === "steel-plate" && itemStack.count >= 20) {
|
||||
contains20SteelPlate = true;
|
||||
}
|
||||
});
|
||||
assert(contains20SteelPlate, "Please ensure there are at least 20 steel plate in the inventory");
|
||||
});
|
||||
|
||||
@@ -50,7 +50,7 @@ async function get(path) {
|
||||
url: `https://localhost:4443${path}`,
|
||||
core: { rejectUnauthorized: false },
|
||||
});
|
||||
if (res.statusCode != 200) {
|
||||
if (res.statusCode !== 200) {
|
||||
throw new Error(`Got response code ${res.statusCode}, content: ${res.body}`);
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -204,7 +204,7 @@ describe("Integration of lib/factorio/server", function() {
|
||||
describe(".start() termination detection", function() {
|
||||
it("should tell if Factorio got killed", async function() {
|
||||
// This does not work on Windows
|
||||
if (process.platform == "win32") {
|
||||
if (process.platform === "win32") {
|
||||
this.skip();
|
||||
}
|
||||
slowTest(this);
|
||||
|
||||
@@ -87,7 +87,7 @@ describe("lib/prometheus", function() {
|
||||
prometheus.defaultRegistry.unregister(collector);
|
||||
}
|
||||
assert(
|
||||
prometheus.defaultRegistry.collectors.length == 0,
|
||||
prometheus.defaultRegistry.collectors.length === 0,
|
||||
"Collectors left over after removing the default ones"
|
||||
);
|
||||
});
|
||||
@@ -367,7 +367,7 @@ describe("lib/prometheus", function() {
|
||||
gauge.labels({ a: "3", b: "4" });
|
||||
gauge.labels({ a: "5", b: "6" });
|
||||
gauge.clear();
|
||||
assert(gauge._values.size == 0, "values was not cleared");
|
||||
assert(gauge._values.size === 0, "values was not cleared");
|
||||
});
|
||||
it("should throw when used on an unlabled metric", function() {
|
||||
let gauge = new prometheus.Gauge("test", "Help", { register: false });
|
||||
@@ -389,7 +389,7 @@ describe("lib/prometheus", function() {
|
||||
}
|
||||
|
||||
assert(
|
||||
results.length == 1,
|
||||
results.length === 1,
|
||||
"collector did not give exactly one result"
|
||||
);
|
||||
|
||||
@@ -409,7 +409,7 @@ describe("lib/prometheus", function() {
|
||||
}
|
||||
|
||||
assert(
|
||||
results.length == 1,
|
||||
results.length === 1,
|
||||
"collector did not give exactly one result"
|
||||
);
|
||||
|
||||
@@ -430,7 +430,7 @@ describe("lib/prometheus", function() {
|
||||
}
|
||||
|
||||
assert(
|
||||
results.length == 1,
|
||||
results.length === 1,
|
||||
"collector did not give exactly one result"
|
||||
);
|
||||
|
||||
@@ -451,7 +451,7 @@ describe("lib/prometheus", function() {
|
||||
}
|
||||
|
||||
assert(
|
||||
results.length == 1,
|
||||
results.length === 1,
|
||||
"collector did not give exactly one result"
|
||||
);
|
||||
|
||||
@@ -604,7 +604,7 @@ describe("lib/prometheus", function() {
|
||||
it("should not have any collectors in the default registry", function() {
|
||||
this.skip(); // XXX Doesn't work in Clusterio's shared testing env
|
||||
assert(
|
||||
prometheus.defaultRegistry.collectors.length == 0,
|
||||
prometheus.defaultRegistry.collectors.length === 0,
|
||||
"Collectors left over by test code"
|
||||
);
|
||||
});
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ describe("Slave testing", function() {
|
||||
|
||||
it("should unlink removed mods", async function() {
|
||||
// This does not work on Windows
|
||||
if (process.platform == "win32") {
|
||||
if (process.platform === "win32") {
|
||||
this.skip();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user