Skip to content

Commit

Permalink
eslint+prettier+reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Dec 4, 2024
1 parent 36c5f51 commit 1d53f88
Show file tree
Hide file tree
Showing 57 changed files with 6,519 additions and 2,408 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
indent_style = space
indent_size = 4

[{package,bower}.json]
indent_style = space
indent_size = 2

[*.yml]
indent_style = space
indent_size = 2

[*.js]
quote_type = "double"
68 changes: 0 additions & 68 deletions .eslintrc.js

This file was deleted.

31 changes: 18 additions & 13 deletions benchmarks/cluster/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
/* eslint-disable no-console */

"use strict";

const
os = require("os"),
const os = require("os"),
cluster = require("cluster"),
stopSignals = [
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT",
"SIGBUS", "SIGFPE", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGTERM"
"SIGHUP",
"SIGINT",
"SIGQUIT",
"SIGILL",
"SIGTRAP",
"SIGABRT",
"SIGBUS",
"SIGFPE",
"SIGUSR1",
"SIGSEGV",
"SIGUSR2",
"SIGTERM"
],
production = true; //process.env.NODE_ENV == "production";

let stopping = false;

cluster.on("disconnect", function(worker) {
cluster.on("disconnect", function (worker) {
if (production) {
if (!stopping) {
cluster.fork();
}
} else
process.exit(1);
} else process.exit(1);
});

if (cluster.isMaster) {
Expand All @@ -30,11 +36,11 @@ if (cluster.isMaster) {
}

if (production) {
stopSignals.forEach(function(signal) {
process.on(signal, function() {
stopSignals.forEach(function (signal) {
process.on(signal, function () {
console.log(`Got ${signal}, stopping workers...`);
stopping = true;
cluster.disconnect(function() {
cluster.disconnect(function () {
console.log("All workers stopped, exiting.");
process.exit(0);
});
Expand All @@ -48,7 +54,6 @@ if (cluster.isMaster) {
worker.process.argv.push(hostname + "-worker-" + worker.id);

require("./worker.js");

}

/**
Expand Down
8 changes: 3 additions & 5 deletions benchmarks/cluster/worker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable no-console */
"use strict";

const { ServiceBroker } = require("moleculer");
const ApiService = require("../../index");
const { ServiceBroker } = require("moleculer");
const ApiService = require("../../index");

// Create broker
const broker = new ServiceBroker({
Expand All @@ -24,5 +23,4 @@ broker.createService({
broker.createService(ApiService);

// Start server
broker.start()
.then(() => console.log(`Worker '${broker.nodeID}' started.`));
broker.start().then(() => console.log(`Worker '${broker.nodeID}' started.`));
31 changes: 18 additions & 13 deletions benchmarks/remote/api/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
/* eslint-disable no-console */

"use strict";

const
os = require("os"),
const os = require("os"),
cluster = require("cluster"),
stopSignals = [
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT",
"SIGBUS", "SIGFPE", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGTERM"
"SIGHUP",
"SIGINT",
"SIGQUIT",
"SIGILL",
"SIGTRAP",
"SIGABRT",
"SIGBUS",
"SIGFPE",
"SIGUSR1",
"SIGSEGV",
"SIGUSR2",
"SIGTERM"
],
production = true; //process.env.NODE_ENV == "production";

let stopping = false;

cluster.on("disconnect", function(worker) {
cluster.on("disconnect", function (worker) {
if (production) {
if (!stopping) {
cluster.fork();
}
} else
process.exit(1);
} else process.exit(1);
});

if (cluster.isMaster) {
Expand All @@ -30,11 +36,11 @@ if (cluster.isMaster) {
}

if (production) {
stopSignals.forEach(function(signal) {
process.on(signal, function() {
stopSignals.forEach(function (signal) {
process.on(signal, function () {
console.log(`Got ${signal}, stopping workers...`);
stopping = true;
cluster.disconnect(function() {
cluster.disconnect(function () {
console.log("All workers stopped, exiting.");
process.exit(0);
});
Expand All @@ -48,7 +54,6 @@ if (cluster.isMaster) {
worker.process.argv.push(hostname + "-api-" + worker.id);

require("./worker.js");

}

/**
Expand Down
8 changes: 3 additions & 5 deletions benchmarks/remote/api/worker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable no-console */
"use strict";

let { ServiceBroker } = require("moleculer");
let ApiService = require("../../../index");
let { ServiceBroker } = require("moleculer");
let ApiService = require("../../../index");

// Create broker
let broker = new ServiceBroker({
Expand All @@ -17,5 +16,4 @@ let broker = new ServiceBroker({
broker.createService(ApiService);

// Start server
broker.start()
.then(() => console.log(`Worker '${broker.nodeID}' started.`));
broker.start().then(() => console.log(`Worker '${broker.nodeID}' started.`));
25 changes: 15 additions & 10 deletions benchmarks/remote/worker/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
/* eslint-disable no-console */

"use strict";

const
os = require("os"),
const os = require("os"),
cluster = require("cluster"),
stopSignals = [
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT",
"SIGBUS", "SIGFPE", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGTERM"
"SIGHUP",
"SIGINT",
"SIGQUIT",
"SIGILL",
"SIGTRAP",
"SIGABRT",
"SIGBUS",
"SIGFPE",
"SIGUSR1",
"SIGSEGV",
"SIGUSR2",
"SIGTERM"
],
production = true; //process.env.NODE_ENV == "production";

let stopping = false;

cluster.on("disconnect", function(worker) {
cluster.on("disconnect", function (worker) {
if (production) {
if (!stopping) {
cluster.fork();
}
} else
process.exit(1);
} else process.exit(1);
});

if (cluster.isMaster) {
Expand Down Expand Up @@ -48,5 +54,4 @@ if (cluster.isMaster) {
worker.process.argv.push(hostname + "-worker-" + worker.id);

require("./worker.js");

}
5 changes: 2 additions & 3 deletions benchmarks/remote/worker/worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

let { ServiceBroker } = require("moleculer");
let { ServiceBroker } = require("moleculer");

// Create broker
let broker = new ServiceBroker({
Expand All @@ -21,5 +21,4 @@ broker.createService({
});

// Start server
broker.start()
.then(() => console.log(`Worker '${broker.nodeID}' started.`));
broker.start().then(() => console.log(`Worker '${broker.nodeID}' started.`));
8 changes: 3 additions & 5 deletions benchmarks/simple/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable no-console */
"use strict";

const { ServiceBroker } = require("moleculer");
const ApiService = require("../../index");
const { ServiceBroker } = require("moleculer");
const ApiService = require("../../index");

// Create broker
const broker = new ServiceBroker({
Expand All @@ -23,8 +22,7 @@ broker.createService({
broker.createService(ApiService);

// Start server
broker.start()
.then(() => console.log("Test URL: http://localhost:3000/test/hello"));
broker.start().then(() => console.log("Test URL: http://localhost:3000/test/hello"));

/**
* Result on i7 4770K 32GB RAM Windows 10 x64
Expand Down
56 changes: 56 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const js = require("@eslint/js");
const globals = require("globals");
const eslintPluginPrettierRecommended = require("eslint-plugin-prettier/recommended");

/** @type {import('eslint').Linter.FlatConfig[]} */
module.exports = [
js.configs.recommended,
eslintPluginPrettierRecommended,
{
files: ["**/*.js", "**/*.mjs"],
languageOptions: {
parserOptions: {
sourceType: "module",
ecmaVersion: 2023
},
globals: {
...globals.node,
...globals.es2020,
...globals.commonjs,
...globals.es6,
...globals.jquery,
...globals.jest,
...globals.jasmine,
process: "readonly",
fetch: "readonly"
}
},
// plugins: ["node", "security"],
rules: {
"no-var": ["error"],
"no-console": ["error"],
"no-unused-vars": ["warn"],
"no-trailing-spaces": ["error"],
"security/detect-object-injection": ["off"],
"security/detect-non-literal-require": ["off"],
"security/detect-non-literal-fs-filename": ["off"],
"no-process-exit": ["off"],
"node/no-unpublished-require": 0
},
ignores: ["benchmark/test.js", "test/typescript/hello-world/out/*.js"]
},
{
files: ["test/**/*.js"],
rules: {
"no-console": ["off"],
"no-unused-vars": ["off"]
}
},
{
files: ["benchmarks/**/*.js", "examples/**/*.js"],
rules: {
"no-console": ["off"],
"no-unused-vars": ["off"]
}
}
];
Loading

0 comments on commit 1d53f88

Please sign in to comment.