Skip to content

Commit 1d53f88

Browse files
committed
eslint+prettier+reformat
1 parent 36c5f51 commit 1d53f88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+6519
-2408
lines changed

.editorconfig

+6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ insert_final_newline = true
1919

2020
[*.md]
2121
trim_trailing_whitespace = false
22+
indent_style = space
23+
indent_size = 4
2224

2325
[{package,bower}.json]
2426
indent_style = space
2527
indent_size = 2
2628

29+
[*.yml]
30+
indent_style = space
31+
indent_size = 2
32+
2733
[*.js]
2834
quote_type = "double"

.eslintrc.js

-68
This file was deleted.

benchmarks/cluster/index.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
/* eslint-disable no-console */
2-
31
"use strict";
42

5-
const
6-
os = require("os"),
3+
const os = require("os"),
74
cluster = require("cluster"),
85
stopSignals = [
9-
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT",
10-
"SIGBUS", "SIGFPE", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGTERM"
6+
"SIGHUP",
7+
"SIGINT",
8+
"SIGQUIT",
9+
"SIGILL",
10+
"SIGTRAP",
11+
"SIGABRT",
12+
"SIGBUS",
13+
"SIGFPE",
14+
"SIGUSR1",
15+
"SIGSEGV",
16+
"SIGUSR2",
17+
"SIGTERM"
1118
],
1219
production = true; //process.env.NODE_ENV == "production";
1320

1421
let stopping = false;
1522

16-
cluster.on("disconnect", function(worker) {
23+
cluster.on("disconnect", function (worker) {
1724
if (production) {
1825
if (!stopping) {
1926
cluster.fork();
2027
}
21-
} else
22-
process.exit(1);
28+
} else process.exit(1);
2329
});
2430

2531
if (cluster.isMaster) {
@@ -30,11 +36,11 @@ if (cluster.isMaster) {
3036
}
3137

3238
if (production) {
33-
stopSignals.forEach(function(signal) {
34-
process.on(signal, function() {
39+
stopSignals.forEach(function (signal) {
40+
process.on(signal, function () {
3541
console.log(`Got ${signal}, stopping workers...`);
3642
stopping = true;
37-
cluster.disconnect(function() {
43+
cluster.disconnect(function () {
3844
console.log("All workers stopped, exiting.");
3945
process.exit(0);
4046
});
@@ -48,7 +54,6 @@ if (cluster.isMaster) {
4854
worker.process.argv.push(hostname + "-worker-" + worker.id);
4955

5056
require("./worker.js");
51-
5257
}
5358

5459
/**

benchmarks/cluster/worker.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/* eslint-disable no-console */
21
"use strict";
32

4-
const { ServiceBroker } = require("moleculer");
5-
const ApiService = require("../../index");
3+
const { ServiceBroker } = require("moleculer");
4+
const ApiService = require("../../index");
65

76
// Create broker
87
const broker = new ServiceBroker({
@@ -24,5 +23,4 @@ broker.createService({
2423
broker.createService(ApiService);
2524

2625
// Start server
27-
broker.start()
28-
.then(() => console.log(`Worker '${broker.nodeID}' started.`));
26+
broker.start().then(() => console.log(`Worker '${broker.nodeID}' started.`));

benchmarks/remote/api/index.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
/* eslint-disable no-console */
2-
31
"use strict";
42

5-
const
6-
os = require("os"),
3+
const os = require("os"),
74
cluster = require("cluster"),
85
stopSignals = [
9-
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT",
10-
"SIGBUS", "SIGFPE", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGTERM"
6+
"SIGHUP",
7+
"SIGINT",
8+
"SIGQUIT",
9+
"SIGILL",
10+
"SIGTRAP",
11+
"SIGABRT",
12+
"SIGBUS",
13+
"SIGFPE",
14+
"SIGUSR1",
15+
"SIGSEGV",
16+
"SIGUSR2",
17+
"SIGTERM"
1118
],
1219
production = true; //process.env.NODE_ENV == "production";
1320

1421
let stopping = false;
1522

16-
cluster.on("disconnect", function(worker) {
23+
cluster.on("disconnect", function (worker) {
1724
if (production) {
1825
if (!stopping) {
1926
cluster.fork();
2027
}
21-
} else
22-
process.exit(1);
28+
} else process.exit(1);
2329
});
2430

2531
if (cluster.isMaster) {
@@ -30,11 +36,11 @@ if (cluster.isMaster) {
3036
}
3137

3238
if (production) {
33-
stopSignals.forEach(function(signal) {
34-
process.on(signal, function() {
39+
stopSignals.forEach(function (signal) {
40+
process.on(signal, function () {
3541
console.log(`Got ${signal}, stopping workers...`);
3642
stopping = true;
37-
cluster.disconnect(function() {
43+
cluster.disconnect(function () {
3844
console.log("All workers stopped, exiting.");
3945
process.exit(0);
4046
});
@@ -48,7 +54,6 @@ if (cluster.isMaster) {
4854
worker.process.argv.push(hostname + "-api-" + worker.id);
4955

5056
require("./worker.js");
51-
5257
}
5358

5459
/**

benchmarks/remote/api/worker.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/* eslint-disable no-console */
21
"use strict";
32

4-
let { ServiceBroker } = require("moleculer");
5-
let ApiService = require("../../../index");
3+
let { ServiceBroker } = require("moleculer");
4+
let ApiService = require("../../../index");
65

76
// Create broker
87
let broker = new ServiceBroker({
@@ -17,5 +16,4 @@ let broker = new ServiceBroker({
1716
broker.createService(ApiService);
1817

1918
// Start server
20-
broker.start()
21-
.then(() => console.log(`Worker '${broker.nodeID}' started.`));
19+
broker.start().then(() => console.log(`Worker '${broker.nodeID}' started.`));

benchmarks/remote/worker/index.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
/* eslint-disable no-console */
2-
31
"use strict";
42

5-
const
6-
os = require("os"),
3+
const os = require("os"),
74
cluster = require("cluster"),
85
stopSignals = [
9-
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT",
10-
"SIGBUS", "SIGFPE", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGTERM"
6+
"SIGHUP",
7+
"SIGINT",
8+
"SIGQUIT",
9+
"SIGILL",
10+
"SIGTRAP",
11+
"SIGABRT",
12+
"SIGBUS",
13+
"SIGFPE",
14+
"SIGUSR1",
15+
"SIGSEGV",
16+
"SIGUSR2",
17+
"SIGTERM"
1118
],
1219
production = true; //process.env.NODE_ENV == "production";
1320

1421
let stopping = false;
1522

16-
cluster.on("disconnect", function(worker) {
23+
cluster.on("disconnect", function (worker) {
1724
if (production) {
1825
if (!stopping) {
1926
cluster.fork();
2027
}
21-
} else
22-
process.exit(1);
28+
} else process.exit(1);
2329
});
2430

2531
if (cluster.isMaster) {
@@ -48,5 +54,4 @@ if (cluster.isMaster) {
4854
worker.process.argv.push(hostname + "-worker-" + worker.id);
4955

5056
require("./worker.js");
51-
5257
}

benchmarks/remote/worker/worker.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
let { ServiceBroker } = require("moleculer");
3+
let { ServiceBroker } = require("moleculer");
44

55
// Create broker
66
let broker = new ServiceBroker({
@@ -21,5 +21,4 @@ broker.createService({
2121
});
2222

2323
// Start server
24-
broker.start()
25-
.then(() => console.log(`Worker '${broker.nodeID}' started.`));
24+
broker.start().then(() => console.log(`Worker '${broker.nodeID}' started.`));

benchmarks/simple/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/* eslint-disable no-console */
21
"use strict";
32

4-
const { ServiceBroker } = require("moleculer");
5-
const ApiService = require("../../index");
3+
const { ServiceBroker } = require("moleculer");
4+
const ApiService = require("../../index");
65

76
// Create broker
87
const broker = new ServiceBroker({
@@ -23,8 +22,7 @@ broker.createService({
2322
broker.createService(ApiService);
2423

2524
// Start server
26-
broker.start()
27-
.then(() => console.log("Test URL: http://localhost:3000/test/hello"));
25+
broker.start().then(() => console.log("Test URL: http://localhost:3000/test/hello"));
2826

2927
/**
3028
* Result on i7 4770K 32GB RAM Windows 10 x64

eslint.config.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const js = require("@eslint/js");
2+
const globals = require("globals");
3+
const eslintPluginPrettierRecommended = require("eslint-plugin-prettier/recommended");
4+
5+
/** @type {import('eslint').Linter.FlatConfig[]} */
6+
module.exports = [
7+
js.configs.recommended,
8+
eslintPluginPrettierRecommended,
9+
{
10+
files: ["**/*.js", "**/*.mjs"],
11+
languageOptions: {
12+
parserOptions: {
13+
sourceType: "module",
14+
ecmaVersion: 2023
15+
},
16+
globals: {
17+
...globals.node,
18+
...globals.es2020,
19+
...globals.commonjs,
20+
...globals.es6,
21+
...globals.jquery,
22+
...globals.jest,
23+
...globals.jasmine,
24+
process: "readonly",
25+
fetch: "readonly"
26+
}
27+
},
28+
// plugins: ["node", "security"],
29+
rules: {
30+
"no-var": ["error"],
31+
"no-console": ["error"],
32+
"no-unused-vars": ["warn"],
33+
"no-trailing-spaces": ["error"],
34+
"security/detect-object-injection": ["off"],
35+
"security/detect-non-literal-require": ["off"],
36+
"security/detect-non-literal-fs-filename": ["off"],
37+
"no-process-exit": ["off"],
38+
"node/no-unpublished-require": 0
39+
},
40+
ignores: ["benchmark/test.js", "test/typescript/hello-world/out/*.js"]
41+
},
42+
{
43+
files: ["test/**/*.js"],
44+
rules: {
45+
"no-console": ["off"],
46+
"no-unused-vars": ["off"]
47+
}
48+
},
49+
{
50+
files: ["benchmarks/**/*.js", "examples/**/*.js"],
51+
rules: {
52+
"no-console": ["off"],
53+
"no-unused-vars": ["off"]
54+
}
55+
}
56+
];

0 commit comments

Comments
 (0)