Use node plugin for Eslint

The Node.js specific rules for Eslint were deprecated in favour of the
node plugin for Eslint.  Add node plugin for eslint and switch over to
using its rules, fixing any issues detected.
This commit is contained in:
Hornwitser committed 2021-05-15 23:22:37 +02:00
1 parent 95b2262cc3
commit b0067eccc6
22 files changed
+129 -39

No files matched your search

+83 -10
View File
@@ -1,5 +1,8 @@
"use strict";
module.exports = {
"plugins": [
"node",
],
"env": {
"node": true,
"commonjs": true,
@@ -18,6 +21,8 @@ module.exports = {
"rules": {
"prefer-arrow-callback": "off",
"no-invalid-this": "off",
"node/no-unpublished-import": "off",
"node/no-unpublished-require": "off",
},
},
{
@@ -31,6 +36,44 @@ module.exports = {
"jsx": true,
},
},
"rules": {
"node/callback-return": "off",
"node/exports-style": "off",
"node/file-extension-in-import": "off",
"node/global-require": "off",
"node/handle-callback-err": "off",
"node/no-callback-literal": "off",
"node/no-deprecated-api": "off",
"node/no-exports-assign": "off",
"node/no-extraneous-import": "off",
"node/no-extraneous-require": "off",
"node/no-missing-import": "off",
"node/no-missing-require": "off",
"node/no-mixed-requires": "off",
"node/no-new-require": "off",
"node/no-path-concat": "off",
"node/no-process-env": "off",
"node/no-process-exit": "off",
"node/no-restricted-require": "off",
"node/no-sync": "off",
"node/no-unpublished-bin": "off",
"node/no-unpublished-import": "off",
"node/no-unpublished-require": "off",
"node/no-unsupported-features/es-builtins": "off",
"node/no-unsupported-features/es-syntax": "off",
"node/no-unsupported-features/node-builtins": "off",
"node/prefer-global/buffer": "off",
"node/prefer-global/console": "off",
"node/prefer-global/process": "off",
"node/prefer-global/text-decoder": "off",
"node/prefer-global/text-encoder": "off",
"node/prefer-global/url-search-params": "off",
"node/prefer-global/url": "off",
"node/prefer-promises/dns": "off",
"node/prefer-promises/fs": "off",
"node/process-exit-as-throw": "off",
"node/shebang": "off",
},
},
],
@@ -46,7 +89,6 @@ module.exports = {
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"callback-return": "off",
"camelcase": "off",
"capitalized-comments": "off",
"class-methods-use-this": "off",
@@ -81,10 +123,8 @@ module.exports = {
"function-call-argument-newline": "off",
"function-paren-newline": "off",
"generator-star-spacing": ["error", { "before": false, "after": true }],
"global-require": "error",
"grouped-accessor-pairs": "error",
"guard-for-in": "error",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
@@ -160,7 +200,6 @@ module.exports = {
],
},
],
"no-mixed-requires": "error",
"no-multi-assign": "error",
"no-multi-spaces": "error",
"no-multi-str": "error",
@@ -172,19 +211,14 @@ module.exports = {
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-restricted-exports": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
@@ -194,7 +228,6 @@ module.exports = {
"no-sequences": "error",
"no-shadow": ["error", { "allow": ["yargs"] }],
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": ["error", { "allowIndentationTabs": true }],
"no-template-curly-in-string": "error",
"no-ternary": "off",
@@ -279,5 +312,45 @@ module.exports = {
"wrap-regex": "off",
"yield-star-spacing": "error",
"yoda": ["error", "never", { "exceptRange": true }],
"node/callback-return": "off",
"node/exports-style": "off",
"node/file-extension-in-import": "off",
"node/global-require": "error",
"node/handle-callback-err": "error",
"node/no-callback-literal": "error",
"node/no-deprecated-api": "error",
"node/no-exports-assign": "error",
"node/no-extraneous-import": "error",
"node/no-extraneous-require": "error",
"node/no-missing-import": "error",
"node/no-missing-require": "error",
"node/no-mixed-requires": "error",
"node/no-new-require": "error",
"node/no-path-concat": "error",
"node/no-process-env": "error",
"node/no-process-exit": "error",
"node/no-restricted-require": "off",
"node/no-sync": "error",
"node/no-unpublished-bin": "error",
"node/no-unpublished-import": "error",
"node/no-unpublished-require": [
"error",
{ "allowModules": ["webpack", "webpack-merge", "webpack-dev-middleware"] },
],
"node/no-unsupported-features/es-builtins": "error",
"node/no-unsupported-features/es-syntax": "error",
"node/no-unsupported-features/node-builtins": "error",
"node/prefer-global/buffer": "error",
"node/prefer-global/console": "error",
"node/prefer-global/process": "error",
"node/prefer-global/text-decoder": "error",
"node/prefer-global/text-encoder": "error",
"node/prefer-global/url-search-params": "error",
"node/prefer-global/url": "error",
"node/prefer-promises/dns": "off",
"node/prefer-promises/fs": "off",
"node/process-exit-as-throw": "error",
"node/shebang": "error",
},
};
+1
View File
@@ -22,6 +22,7 @@
},
"devDependencies": {
"eslint": "^7.25.0",
"eslint-plugin-node": "^11.1.0",
"jsdoc": "^3.6.6",
"lerna": "^4.0.0",
"mocha": "^8.4.0",
+1 -1
View File
@@ -962,7 +962,7 @@ async function startControl() {
control.shutdown().catch(err => {
setBlocking(true);
logger.error(err.stack);
// eslint-disable-next-line no-process-exit
// eslint-disable-next-line node/no-process-exit
process.exit(1);
});
});
+1
View File
@@ -22,6 +22,7 @@
"as-table": "^1.0.31",
"fs-extra": "^8.1.0",
"phin": "^3.5.1",
"set-blocking": "^2.0.0",
"winston": "^3.3.3",
"yargs": "^14.2.0"
},
+5 -3
View File
@@ -1,11 +1,13 @@
/* eslint-disable global-require */
/**
* Configuration System
* @author Hornwitser
* @module lib/config
*/
"use strict";
const classes = require("./classes");
const definitions = require("./definitions");
module.exports = {
...require("./classes"),
...require("./definitions"),
...classes,
...definitions,
};
+7 -4
View File
@@ -1,12 +1,15 @@
/* eslint-disable global-require */
/**
* Library for interfacing with Factorio Servers and saves.
* @module lib/factorio
* @author Hornwitser
*/
"use strict";
const export_ = require("./export");
const patch = require("./patch");
const server = require("./server");
module.exports = {
...require("./export"),
...require("./patch"),
...require("./server"),
...export_,
...patch,
...server,
};
+3 -2
View File
@@ -1,7 +1,8 @@
/* eslint-disable global-require */
/* eslint-disable node/global-require */
"use strict";
// eslint-disable-next-line no-process-env
// eslint-disable-next-line node/no-process-env
if (process.env.APP_ENV === "browser") {
// eslint-disable-next-line node/no-extraneous-require
module.exports = require("fast-deep-equal/es6");
} else {
module.exports = require("util").isDeepStrictEqual;
+1 -1
View File
@@ -249,7 +249,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
// Open WebSocket to master
logger.verbose(`SOCKET | connecting to ${url}`);
// eslint-disable-next-line no-process-env
// eslint-disable-next-line node/no-process-env
if (process.env.APP_ENV === "browser") {
this._socket = new WebSocket(url);
+7 -4
View File
@@ -1,12 +1,15 @@
/* eslint-disable global-require */
/**
* Library for message based communication between nodes
* @module lib/link
* @author Hornwitser
*/
"use strict";
const link = require("./link");
const messages = require("./messages");
const connectors = require("./connectors");
module.exports = {
...require("./link"),
...require("./messages"),
...require("./connectors"),
...link,
...messages,
...connectors,
};
+1 -1
View File
@@ -1,4 +1,4 @@
/* eslint-disable global-require */
/* eslint-disable node/global-require */
/**
* Helpers for loading plugins in Node.js
* @module lib/plugin_loader
+1 -1
View File
@@ -55,7 +55,7 @@ async function handlePluginCommand(args, pluginList, pluginListPath) {
let pluginInfo;
try {
// eslint-disable-next-line global-require
// eslint-disable-next-line node/global-require
pluginInfo = require(path.posix.join(pluginPath, "info"));
} catch (err) {
logger.error(`Unable to import plugin info from ${args.path}:\n${err.stack}`);
+1
View File
@@ -0,0 +1 @@
webpack.config.js
+2 -2
View File
@@ -322,7 +322,7 @@ async function startup() {
if (secondSigint) {
setBlocking(true);
logger.fatal("Caught second interrupt, terminating immediately");
// eslint-disable-next-line no-process-exit
// eslint-disable-next-line node/no-process-exit
process.exit(1);
}
@@ -335,7 +335,7 @@ async function startup() {
if (secondSigterm) {
setBlocking(true);
logger.fatal("Caught second termination, terminating immediately");
// eslint-disable-next-line no-process-exit
// eslint-disable-next-line node/no-process-exit
process.exit(1);
}
+2 -2
View File
@@ -118,7 +118,7 @@ class Master {
// Start webpack development server if enabled
if (args.dev || args.devPlugin) {
logger.warn("Webpack development mode enabled");
/* eslint-disable global-require */
/* eslint-disable node/global-require, node/no-unpublished-require */
const webpack = require("webpack");
const webpackDevMiddleware = require("webpack-dev-middleware");
const webpackConfigs = [];
@@ -136,7 +136,7 @@ class Master {
webpackConfigs.push(config);
}
}
/* eslint-enable global-require */
/* eslint-enable node/global-require, node/no-unpublished-require */
const compiler = webpack(webpackConfigs);
this.devMiddleware = webpackDevMiddleware(compiler, {});
+3 -3
View File
@@ -1413,7 +1413,7 @@ class Slave extends libLink.Link {
+--------------------------------------------------------------------+
${err.stack}`
);
// eslint-disable-next-line no-process-exit
// eslint-disable-next-line node/no-process-exit
process.exit(1);
}
}
@@ -1619,7 +1619,7 @@ async function startSlave() {
if (secondSigint) {
setBlocking(true);
logger.fatal("Caught second interrupt, terminating immediately");
// eslint-disable-next-line no-process-exit
// eslint-disable-next-line node/no-process-exit
process.exit(1);
}
@@ -1632,7 +1632,7 @@ async function startSlave() {
if (secondSigterm) {
setBlocking(true);
logger.fatal("Caught second termination, terminating immediately");
// eslint-disable-next-line no-process-exit
// eslint-disable-next-line node/no-process-exit
process.exit(1);
}
+1
View File
@@ -0,0 +1 @@
webpack.config.js
+1
View File
@@ -0,0 +1 @@
webpack.config.js
+1
View File
@@ -0,0 +1 @@
webpack.config.js
+1
View File
@@ -0,0 +1 @@
webpack.config.js
+1
View File
@@ -0,0 +1 @@
webpack.config.js
+1 -1
View File
@@ -46,7 +46,7 @@ class TestControlConnector extends libLink.WebSocketClientConnector {
// Mark that this test takes a lot of time, or depeneds on a test
// that takes a lot of time.
function slowTest(test) {
// eslint-disable-next-line no-process-env
// eslint-disable-next-line node/no-process-env
if (process.env.FAST_TEST) {
test.skip();
}
+4 -4
View File
@@ -5,10 +5,10 @@
"node": ">=12"
},
"dependencies": {
"@clusterio/ctl": "2.0.0-alpha.5",
"@clusterio/lib": "2.0.0-alpha.5",
"@clusterio/master": "2.0.0-alpha.5",
"@clusterio/slave": "2.0.0-alpha.5",
"@clusterio/ctl": "^2.0.0-alpha.6",
"@clusterio/lib": "^2.0.0-alpha.6",
"@clusterio/master": "^2.0.0-alpha.6",
"@clusterio/slave": "^2.0.0-alpha.6",
"express": "^4.16.2",
"fs-extra": "^8.1.0",
"jsonwebtoken": "^8.2.1",