Fix the remaning linter warnings (#353)

Refactor the code base to remove all of the remaining warnings from
ESLint and convert them into errors.
This commit is contained in:
Hornwitser authored and GitHub committed 2021-01-05 22:28:08 +01:00
1 parent 9243731646
commit 1b901f5d1c
33 files changed
+718 -609

No files matched your search

+23 -25
View File
@@ -6,6 +6,28 @@ const libPlugin = require("@clusterio/lib/plugin");
const RateLimiter = require("@clusterio/lib/RateLimiter");
async function loadTechnologies(masterConfig, logger) {
let filePath = path.join(masterConfig.get("master.database_directory"), "technologies.json");
logger.verbose(`Loading ${filePath}`);
try {
return new Map(JSON.parse(await fs.readFile(filePath)));
} catch (err) {
if (err.code === "ENOENT") {
logger.verbose("Creating new technologies database");
return new Map();
}
throw err;
}
}
async function saveTechnologies(masterConfig, technologies, logger) {
let filePath = path.join(masterConfig.get("master.database_directory"), "technologies.json");
logger.verbose(`writing ${filePath}`);
await fs.outputFile(filePath, JSON.stringify([...technologies.entries()], null, 4));
}
class MasterPlugin extends libPlugin.BaseMasterPlugin {
async init() {
this.technologies = await loadTechnologies(this.master.config, this.logger);
@@ -92,9 +114,8 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
let match = /-(\d+)$/.exec(name);
if (!match) {
return 1;
} else {
return Number.parseInt(match[1], 10);
}
return Number.parseInt(match[1], 10);
}
for (let instanceTech of message.data.technologies) {
@@ -145,29 +166,6 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
}
}
async function loadTechnologies(masterConfig, logger) {
let filePath = path.join(masterConfig.get("master.database_directory"), "technologies.json");
logger.verbose(`Loading ${filePath}`);
try {
return new Map(JSON.parse(await fs.readFile(filePath)));
} catch (err) {
if (err.code === "ENOENT") {
logger.verbose("Creating new technologies database");
return new Map();
} else {
throw err;
}
}
}
async function saveTechnologies(masterConfig, technologies, logger) {
let filePath = path.join(masterConfig.get("master.database_directory"), "technologies.json");
logger.verbose(`writing ${filePath}`);
await fs.outputFile(filePath, JSON.stringify([...technologies.entries()], null, 4));
}
module.exports = {
MasterPlugin,