mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
Fix linting issues with new rules
This commit is contained in:
1 parent
256407b9fd
commit
7e2f10e842
32 files changed
+65
-66
No files matched your search
@@ -422,7 +422,7 @@ async function startup() {
|
|||||||
if (secondSigint) {
|
if (secondSigint) {
|
||||||
setBlocking(true);
|
setBlocking(true);
|
||||||
logger.fatal("Caught second interrupt, terminating immediately");
|
logger.fatal("Caught second interrupt, terminating immediately");
|
||||||
// eslint-disable-next-line node/no-process-exit
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,7 +435,7 @@ async function startup() {
|
|||||||
if (secondSigterm) {
|
if (secondSigterm) {
|
||||||
setBlocking(true);
|
setBlocking(true);
|
||||||
logger.fatal("Caught second termination, terminating immediately");
|
logger.fatal("Caught second termination, terminating immediately");
|
||||||
// eslint-disable-next-line node/no-process-exit
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import * as routes from "./routes";
|
|||||||
* @alias module:controller/src/BaseConnection
|
* @alias module:controller/src/BaseConnection
|
||||||
*/
|
*/
|
||||||
export default class BaseConnection extends lib.Link {
|
export default class BaseConnection extends lib.Link {
|
||||||
declare ["connector"]: WsServerConnector;
|
declare "connector": WsServerConnector;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
connector: lib.WebSocketBaseConnector,
|
connector: lib.WebSocketBaseConnector,
|
||||||
|
|||||||
@@ -901,7 +901,7 @@ export default class ControlConnection extends BaseConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A large number of small if statements are unavoidable when reducing the number of updates sent
|
// A large number of small if statements are unavoidable when reducing the number of updates sent
|
||||||
// eslint-disable-next-line complexity
|
|
||||||
async handleUserBulkImportRequest(request: lib.UserBulkImportRequest) {
|
async handleUserBulkImportRequest(request: lib.UserBulkImportRequest) {
|
||||||
let backup: undefined | Awaited<ReturnType<ControlConnection["handleUserBulkExportRequest"]>>;
|
let backup: undefined | Awaited<ReturnType<ControlConnection["handleUserBulkExportRequest"]>>;
|
||||||
const updated = new Map<ControllerUser["id"], ControllerUser>();
|
const updated = new Map<ControllerUser["id"], ControllerUser>();
|
||||||
|
|||||||
@@ -399,13 +399,13 @@ export default class Controller {
|
|||||||
|
|
||||||
async _startDevServer(args: ControllerArgs) {
|
async _startDevServer(args: ControllerArgs) {
|
||||||
logger.warn("Webpack development mode enabled");
|
logger.warn("Webpack development mode enabled");
|
||||||
/* eslint-disable @typescript-eslint/no-var-requires, node/no-unpublished-require */
|
|
||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const webpackDevMiddleware = require("webpack-dev-middleware");
|
const webpackDevMiddleware = require("webpack-dev-middleware");
|
||||||
const webpackConfigs = [];
|
const webpackConfigs = [];
|
||||||
|
|
||||||
if (args.dev) {
|
if (args.dev) {
|
||||||
// eslint-disable-next-line node/no-missing-require
|
|
||||||
webpackConfigs.push(require("../../../webpack.config")({})); // Path outside of build
|
webpackConfigs.push(require("../../../webpack.config")({})); // Path outside of build
|
||||||
}
|
}
|
||||||
if (args.devPlugin) {
|
if (args.devPlugin) {
|
||||||
@@ -421,7 +421,7 @@ export default class Controller {
|
|||||||
}
|
}
|
||||||
this.app.locals.devPlugins = devPlugins;
|
this.app.locals.devPlugins = devPlugins;
|
||||||
}
|
}
|
||||||
/* eslint-enable @typescript-eslint/no-var-requires, node/no-unpublished-require */
|
|
||||||
|
|
||||||
const compiler = webpack(webpackConfigs);
|
const compiler = webpack(webpackConfigs);
|
||||||
this.devMiddleware = webpackDevMiddleware(compiler, { serverSideRender: true });
|
this.devMiddleware = webpackDevMiddleware(compiler, { serverSideRender: true });
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default class HostConnection extends BaseConnection {
|
|||||||
this._checkPluginVersions();
|
this._checkPluginVersions();
|
||||||
|
|
||||||
for (let event of ["connect", "drop", "resume", "close"] as const) {
|
for (let event of ["connect", "drop", "resume", "close"] as const) {
|
||||||
// eslint-disable-next-line no-loop-func
|
|
||||||
this.connector.on(event, () => {
|
this.connector.on(event, () => {
|
||||||
for (let plugin of this._controller.plugins.values()) {
|
for (let plugin of this._controller.plugins.values()) {
|
||||||
plugin.onHostConnectionEvent(this, event);
|
plugin.onHostConnectionEvent(this, event);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ async function execFile(cmd, args) {
|
|||||||
escaped,
|
escaped,
|
||||||
{
|
{
|
||||||
shell: true,
|
shell: true,
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
env: process.platform === "win32" ? { ...process.env, pct: "%" } : undefined,
|
env: process.platform === "win32" ? { ...process.env, pct: "%" } : undefined,
|
||||||
},
|
},
|
||||||
(err, stdout, stderr) => {
|
(err, stdout, stderr) => {
|
||||||
@@ -396,7 +396,7 @@ async function installClusterio(mode, plugins) {
|
|||||||
}
|
}
|
||||||
for (let plugin of plugins) {
|
for (let plugin of plugins) {
|
||||||
if (!pluginList.has(plugin)) {
|
if (!pluginList.has(plugin)) {
|
||||||
// eslint-disable-next-line node/global-require
|
|
||||||
let pluginInfo = require(require.resolve(plugin, { paths: [process.cwd()] })).plugin;
|
let pluginInfo = require(require.resolve(plugin, { paths: [process.cwd()] })).plugin;
|
||||||
pluginList.set(pluginInfo.name, plugin);
|
pluginList.set(pluginInfo.name, plugin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function escapeArg(arg) {
|
|||||||
// For all other platforms the command is /bin/sh -c <command arg arg ...>
|
// For all other platforms the command is /bin/sh -c <command arg arg ...>
|
||||||
// The command and its arguments are passed as a single argument to the shell.
|
// The command and its arguments are passed as a single argument to the shell.
|
||||||
// See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02
|
// See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02
|
||||||
// eslint-disable-next-line no-lonely-if
|
|
||||||
if (!/[|&;<>()$`\\"' \t*?\[#~=%]/.test(arg)) {
|
if (!/[|&;<>()$`\\"' \t*?\[#~=%]/.test(arg)) {
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const plugin = {
|
|||||||
|
|
||||||
//%endif
|
//%endif
|
||||||
//%if controller
|
//%if controller
|
||||||
controllerEntrypoint: "./dist/node/controller",
|
controllerEntrypoint: "./dist/node/controller",
|
||||||
//%endif
|
//%endif
|
||||||
//%if controller & config
|
//%if controller & config
|
||||||
controllerConfigFields: {
|
controllerConfigFields: {
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ function MyTemplatePage() {
|
|||||||
|
|
||||||
return <PageLayout nav={[{ name: "__plugin_name__" }]}>
|
return <PageLayout nav={[{ name: "__plugin_name__" }]}>
|
||||||
<PageHeader title="__plugin_name__" />
|
<PageHeader title="__plugin_name__" />
|
||||||
//%if controller // Subscribing requires web content and the controller
|
//%if controller // Subscribing requires web content and the controller
|
||||||
Synced: {String(synced)} Data: {JSON.stringify([...subscribableData.values()])}
|
Synced: {String(synced)} Data: {JSON.stringify([...subscribableData.values()])}
|
||||||
//%endif
|
//%endif
|
||||||
</PageLayout>;
|
</PageLayout>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ function MyTemplatePage() {
|
|||||||
|
|
||||||
return <PageLayout nav={[{ name: "__plugin_name__" }]}>
|
return <PageLayout nav={[{ name: "__plugin_name__" }]}>
|
||||||
<PageHeader title="__plugin_name__" />
|
<PageHeader title="__plugin_name__" />
|
||||||
//%if controller // Subscribing requires web content and the controller
|
//%if controller // Subscribing requires web content and the controller
|
||||||
Synced: {String(synced)} Data: {JSON.stringify([...subscribableData.values()])}
|
Synced: {String(synced)} Data: {JSON.stringify([...subscribableData.values()])}
|
||||||
//%endif
|
//%endif
|
||||||
</PageLayout>;
|
</PageLayout>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -310,7 +310,7 @@ async function startControl() {
|
|||||||
control.shutdown().catch(err => {
|
control.shutdown().catch(err => {
|
||||||
setBlocking(true);
|
setBlocking(true);
|
||||||
logger.error(err.stack);
|
logger.error(err.stack);
|
||||||
// eslint-disable-next-line node/no-process-exit
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ async function startHost() {
|
|||||||
if (secondSigint) {
|
if (secondSigint) {
|
||||||
setBlocking(true);
|
setBlocking(true);
|
||||||
logger.fatal("Caught second interrupt, terminating immediately");
|
logger.fatal("Caught second interrupt, terminating immediately");
|
||||||
// eslint-disable-next-line node/no-process-exit
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ async function startHost() {
|
|||||||
if (secondSigterm) {
|
if (secondSigterm) {
|
||||||
setBlocking(true);
|
setBlocking(true);
|
||||||
logger.fatal("Caught second termination, terminating immediately");
|
logger.fatal("Caught second termination, terminating immediately");
|
||||||
// eslint-disable-next-line node/no-process-exit
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ export class HostRouter {
|
|||||||
* Connects to the controller over the WebSocket and manages intsances.
|
* Connects to the controller over the WebSocket and manages intsances.
|
||||||
*/
|
*/
|
||||||
export default class Host extends lib.Link {
|
export default class Host extends lib.Link {
|
||||||
declare ["connector"]: HostConnector;
|
declare "connector": HostConnector;
|
||||||
|
|
||||||
router = new HostRouter(this);
|
router = new HostRouter(this);
|
||||||
/**
|
/**
|
||||||
@@ -1201,7 +1201,7 @@ export default class Host extends lib.Link {
|
|||||||
+------------------------------------------------------------+
|
+------------------------------------------------------------+
|
||||||
${err.stack}`
|
${err.stack}`
|
||||||
);
|
);
|
||||||
// eslint-disable-next-line node/no-process-exit
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ async function loadLayeredIcon(
|
|||||||
iconLayer.scale(realScale);
|
iconLayer.scale(realScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-loop-func
|
|
||||||
iconLayer.scan(0, 0, iconLayer.bitmap.width, iconLayer.bitmap.height, (x, y, sidx) => {
|
iconLayer.scan(0, 0, iconLayer.bitmap.width, iconLayer.bitmap.height, (x, y, sidx) => {
|
||||||
x += xs;
|
x += xs;
|
||||||
y += ys;
|
y += ys;
|
||||||
|
|||||||
@@ -747,7 +747,7 @@ export class FactorioServer extends events.EventEmitter<FactorioServerEvents> {
|
|||||||
this._rconClient.on("authenticated", () => {
|
this._rconClient.on("authenticated", () => {
|
||||||
this._rconReady = true;
|
this._rconReady = true;
|
||||||
this.emit("rcon-ready");
|
this.emit("rcon-ready");
|
||||||
});
|
});
|
||||||
this._rconClient.on("end", () => {
|
this._rconClient.on("end", () => {
|
||||||
this._rconClient = null;
|
this._rconClient = null;
|
||||||
if (!this._rconReady) {
|
if (!this._rconReady) {
|
||||||
|
|||||||
Vendored
+7
-7
@@ -1,10 +1,10 @@
|
|||||||
export interface BuildArgs {
|
export interface BuildArgs {
|
||||||
factorioVersion?: string;
|
factorioVersion?: string;
|
||||||
dependencies?: Record<string, string>;
|
dependencies?: Record<string, string>;
|
||||||
clean?: boolean;
|
clean?: boolean;
|
||||||
pack?: boolean;
|
pack?: boolean;
|
||||||
build?: boolean;
|
build?: boolean;
|
||||||
outputDir: string;
|
outputDir: string;
|
||||||
sourceDir: string;
|
sourceDir: string;
|
||||||
};
|
};
|
||||||
export function build(args: BuildArgs): Promise<void>;
|
export function build(args: BuildArgs): Promise<void>;
|
||||||
@@ -291,7 +291,7 @@ export default class ModPack {
|
|||||||
const sizeBytes = uint32Bytes(entries.length);
|
const sizeBytes = uint32Bytes(entries.length);
|
||||||
const itemBytes = entries.flatMap(([key, item]) => [
|
const itemBytes = entries.flatMap(([key, item]) => [
|
||||||
immutableStringBytes(key),
|
immutableStringBytes(key),
|
||||||
// eslint-disable-next-line no-use-before-define
|
|
||||||
propertyTreeBytes(item),
|
propertyTreeBytes(item),
|
||||||
]);
|
]);
|
||||||
return Buffer.concat([
|
return Buffer.concat([
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Note: Run compile_validator script after making changes to this file.
|
// Note: Run compile_validator script after making changes to this file.
|
||||||
import { TSchema, Type, Static } from "@sinclair/typebox";
|
import { TSchema, Type, Static } from "@sinclair/typebox";
|
||||||
// eslint-disable-next-line node/no-missing-import
|
|
||||||
import messageValidate from "./message_validate"; // generated file
|
import messageValidate from "./message_validate"; // generated file
|
||||||
import { StringEnum } from "./composites";
|
import { StringEnum } from "./composites";
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ export class Message {
|
|||||||
static validate = messageValidate;
|
static validate = messageValidate;
|
||||||
|
|
||||||
static fromJSON(json: any) {
|
static fromJSON(json: any) {
|
||||||
/* eslint-disable no-use-before-define */
|
|
||||||
if (json.type === "hello") { return MessageHello.fromJSON(json); }
|
if (json.type === "hello") { return MessageHello.fromJSON(json); }
|
||||||
if (json.type === "registerHost") { return MessageRegisterHost.fromJSON(json); }
|
if (json.type === "registerHost") { return MessageRegisterHost.fromJSON(json); }
|
||||||
if (json.type === "registerControl") { return MessageRegisterControl.fromJSON(json); }
|
if (json.type === "registerControl") { return MessageRegisterControl.fromJSON(json); }
|
||||||
@@ -168,7 +168,7 @@ export class Message {
|
|||||||
if (json.type === "responseError") { return MessageResponseError.fromJSON(json); }
|
if (json.type === "responseError") { return MessageResponseError.fromJSON(json); }
|
||||||
if (json.type === "event") { return MessageEvent.fromJSON(json); }
|
if (json.type === "event") { return MessageEvent.fromJSON(json); }
|
||||||
if (json.type === "disconnect") { return MessageDisconnect.fromJSON(json); }
|
if (json.type === "disconnect") { return MessageDisconnect.fromJSON(json); }
|
||||||
/* eslint-enable no-use-before-define */
|
|
||||||
throw new Error(`Unrecognized message type ${json.type}`);
|
throw new Error(`Unrecognized message type ${json.type}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ export abstract class Datastore<
|
|||||||
V extends DatastoreValue,
|
V extends DatastoreValue,
|
||||||
U = V,
|
U = V,
|
||||||
> extends EventEmitter<{
|
> extends EventEmitter<{
|
||||||
"update": [ updates: U[] ],
|
"update": [ updates: U[] ],
|
||||||
}> {
|
}> {
|
||||||
private dirty = false;
|
private dirty = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/* eslint-disable node/global-require */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
if (process.env.APP_ENV === "browser") {
|
if (process.env.APP_ENV === "browser") {
|
||||||
// eslint-disable-next-line node/no-extraneous-require
|
|
||||||
module.exports = require("fast-deep-equal/es6");
|
module.exports = require("fast-deep-equal/es6");
|
||||||
} else {
|
} else {
|
||||||
module.exports = require("util").isDeepStrictEqual;
|
module.exports = require("util").isDeepStrictEqual;
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
module.exports = process.env.APP_ENV === "browser" ? window.WebSocket : require("ws");
|
module.exports = process.env.APP_ENV === "browser" ? window.WebSocket : require("ws");
|
||||||
@@ -271,7 +271,7 @@ export abstract class WebSocketBaseConnector<
|
|||||||
this._check("connected");
|
this._check("connected");
|
||||||
if (Date.now() - this._lastHeartbeatMs! > 2000 * this._heartbeatInterval!) {
|
if (Date.now() - this._lastHeartbeatMs! > 2000 * this._heartbeatInterval!) {
|
||||||
logger.verbose("Connector | closing after heartbeat timed out");
|
logger.verbose("Connector | closing after heartbeat timed out");
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
if (process.env.APP_ENV === "browser") {
|
if (process.env.APP_ENV === "browser") {
|
||||||
this._socket!.close(ConnectionClosed.Timeout, "Heartbeat timeout");
|
this._socket!.close(ConnectionClosed.Timeout, "Heartbeat timeout");
|
||||||
} else {
|
} else {
|
||||||
@@ -544,7 +544,7 @@ export abstract class WebSocketClientConnector extends WebSocketBaseConnector<We
|
|||||||
// Open WebSocket to controller
|
// Open WebSocket to controller
|
||||||
logger.verbose(`Connector | connecting to ${url}`);
|
logger.verbose(`Connector | connecting to ${url}`);
|
||||||
|
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
if (process.env.APP_ENV === "browser") {
|
if (process.env.APP_ENV === "browser") {
|
||||||
this._socket = new WebSocket(url) as WebSocketClusterio;
|
this._socket = new WebSocket(url) as WebSocketClusterio;
|
||||||
|
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ export async function queryLog(logDirectory: string, filter: QueryLogFilter, ind
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function handleUnhandledErrors() {
|
export function handleUnhandledErrors() {
|
||||||
/* eslint-disable node/no-process-exit */
|
|
||||||
process.on("uncaughtException", err => {
|
process.on("uncaughtException", err => {
|
||||||
logger.fatal(`Uncaught exception:\n${err.stack}`);
|
logger.fatal(`Uncaught exception:\n${err.stack}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@@ -528,7 +528,7 @@ export function handleUnhandledErrors() {
|
|||||||
logger.fatal(`Unhandled rejection:\n${reason.stack ? reason.stack : reason}`);
|
logger.fatal(`Unhandled rejection:\n${reason.stack ? reason.stack : reason}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
/* eslint-enable node/no-process-exit */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for testing only
|
// for testing only
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
||||||
/**
|
/**
|
||||||
* Helpers for loading plugins in Node.js
|
* Helpers for loading plugins in Node.js
|
||||||
* @module lib/plugin_loader
|
* @module lib/plugin_loader
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export async function handlePluginCommand(
|
|||||||
|
|
||||||
let pluginInfo: { name: string };
|
let pluginInfo: { name: string };
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
pluginInfo = require(pluginPath).plugin;
|
pluginInfo = require(pluginPath).plugin;
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
logger.error(`Unable to import plugin info from ${args.path}:\n${err.stack}`);
|
logger.error(`Unable to import plugin info from ${args.path}:\n${err.stack}`);
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ export default function BaseConfigTree(props: BaseConfigTreeProps) {
|
|||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line complexity
|
|
||||||
function computeTreeData(
|
function computeTreeData(
|
||||||
control: Control,
|
control: Control,
|
||||||
form: FormInstance<any>,
|
form: FormInstance<any>,
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ export function dose(
|
|||||||
let inp1 = [numreq, instore_adj, store_last_tick / numreq, dole, carry]; // 0..4
|
let inp1 = [numreq, instore_adj, store_last_tick / numreq, dole, carry]; // 0..4
|
||||||
let inp2 = [
|
let inp2 = [
|
||||||
prev_req / numreq,
|
prev_req / numreq,
|
||||||
numreq / numreq_total_adj,
|
numreq / numreq_total_adj,
|
||||||
store_last_tick / numreq_total_adj,
|
store_last_tick / numreq_total_adj,
|
||||||
prev_req/instore_adj,
|
prev_req/instore_adj,
|
||||||
b,
|
b,
|
||||||
numreq_total_adj,
|
numreq_total_adj,
|
||||||
store_last_tick,
|
store_last_tick,
|
||||||
debt,
|
debt,
|
||||||
]; // 5..12
|
]; // 5..12
|
||||||
let inputs = inp1.concat(inp2);
|
let inputs = inp1.concat(inp2);
|
||||||
let outputs = [0, 0, 0, 0];
|
let outputs = [0, 0, 0, 0];
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ async function exec(file, args) {
|
|||||||
const { stdout, stderr } = await execFile(
|
const { stdout, stderr } = await execFile(
|
||||||
file,
|
file,
|
||||||
args.map(escapeArg),
|
args.map(escapeArg),
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
{ shell: true, cwd: __dirname, env: { ...process.env, pct: "%"} }
|
{ shell: true, cwd: __dirname, env: { ...process.env, pct: "%"} }
|
||||||
);
|
);
|
||||||
return { stdout: JSON.parse(stdout), stderr };
|
return { stdout: JSON.parse(stdout), stderr };
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class TestHostConnector extends lib.WebSocketClientConnector {
|
|||||||
// Mark that this test takes a lot of time, or depeneds on a test
|
// Mark that this test takes a lot of time, or depeneds on a test
|
||||||
// that takes a lot of time.
|
// that takes a lot of time.
|
||||||
function slowTest(test) {
|
function slowTest(test) {
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
if (process.env.FAST_TEST) {
|
if (process.env.FAST_TEST) {
|
||||||
test.skip();
|
test.skip();
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ function getControl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function spawn(name, cmd, waitFor) {
|
function spawn(name, cmd, waitFor) {
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
const silent = process.env.SILENT_TEST;
|
const silent = process.env.SILENT_TEST;
|
||||||
const bootstrap = !controllerProcess || !hostProcess;
|
const bootstrap = !controllerProcess || !hostProcess;
|
||||||
function log(...args) {
|
function log(...args) {
|
||||||
@@ -264,7 +264,7 @@ async function spawnNode(name, cmd, waitFor) {
|
|||||||
before(async function() {
|
before(async function() {
|
||||||
this.timeout(40000);
|
this.timeout(40000);
|
||||||
|
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
const silent = process.env.SILENT_TEST;
|
const silent = process.env.SILENT_TEST;
|
||||||
if (silent) {
|
if (silent) {
|
||||||
console.log("SILENT_TEST is present in env, loggers after bootstrap will be muted.");
|
console.log("SILENT_TEST is present in env, loggers after bootstrap will be muted.");
|
||||||
@@ -278,7 +278,7 @@ before(async function() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// If fast test is enabled then output that it is
|
// If fast test is enabled then output that it is
|
||||||
// eslint-disable-next-line node/no-process-env
|
|
||||||
if (process.env.FAST_TEST) {
|
if (process.env.FAST_TEST) {
|
||||||
console.log("FAST_TEST is present in env, slow tests will be skipped.");
|
console.log("FAST_TEST is present in env, slow tests will be skipped.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -816,24 +816,24 @@ describe("lib/ModStore", function () {
|
|||||||
assert.equal(
|
assert.equal(
|
||||||
typeof firstMod.latest_release.version,
|
typeof firstMod.latest_release.version,
|
||||||
"string",
|
"string",
|
||||||
"latest_release version should be string" // eslint-disable-line max-len
|
"latest_release version should be string"
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
typeof firstMod.latest_release.sha1,
|
typeof firstMod.latest_release.sha1,
|
||||||
"string",
|
"string",
|
||||||
"latest_release should have a sha1 string" // eslint-disable-line max-len
|
"latest_release should have a sha1 string"
|
||||||
);
|
);
|
||||||
assert.ok(firstMod.latest_release.info_json, "latest_release should have info_json");
|
assert.ok(firstMod.latest_release.info_json, "latest_release should have info_json");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
typeof firstMod.latest_release.info_json.factorio_version,
|
typeof firstMod.latest_release.info_json.factorio_version,
|
||||||
"string",
|
"string",
|
||||||
"info_json should have factorio_version string" // eslint-disable-line max-len
|
"info_json should have factorio_version string"
|
||||||
);
|
);
|
||||||
// Check for an expected field from the user example
|
// Check for an expected field from the user example
|
||||||
assert.equal(
|
assert.equal(
|
||||||
typeof firstMod.downloads_count,
|
typeof firstMod.downloads_count,
|
||||||
"number",
|
"number",
|
||||||
"First mod should have downloads_count number" // eslint-disable-line max-len
|
"First mod should have downloads_count number"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// This should not happen for v1.1 but handles edge cases
|
// This should not happen for v1.1 but handles edge cases
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ describe("lib/data/ModPack", function() {
|
|||||||
Buffer.from(str),
|
Buffer.from(str),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
/* eslint-disable indent */
|
/* eslint-disable @stylistic/indent */
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
pack.toModSettingsDat(),
|
pack.toModSettingsDat(),
|
||||||
Buffer.concat([
|
Buffer.concat([
|
||||||
@@ -373,7 +373,6 @@ describe("lib/data/ModPack", function() {
|
|||||||
new Uint8Array(Float64Array.from([1]).buffer),
|
new Uint8Array(Float64Array.from([1]).buffer),
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
/* eslint-enable indent */
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("defaultModPacks", function() {
|
describe("defaultModPacks", function() {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ describe("lib/plugin_loader", function() {
|
|||||||
it("should reject on broken plugin", async function() {
|
it("should reject on broken plugin", async function() {
|
||||||
let brokenMessage;
|
let brokenMessage;
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line node/global-require
|
|
||||||
require(path.resolve(brokenPlugin));
|
require(path.resolve(brokenPlugin));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
brokenMessage = err.message;
|
brokenMessage = err.message;
|
||||||
|
|||||||
Reference in new issue
Block a user