Skip to content

Commit

Permalink
eslint9 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Apr 27, 2024
1 parent 9cf8b0f commit 25e849b
Show file tree
Hide file tree
Showing 37 changed files with 83 additions and 194 deletions.
43 changes: 0 additions & 43 deletions .eslintrc.js

This file was deleted.

18 changes: 0 additions & 18 deletions benchmark/.eslintrc.js

This file was deleted.

2 changes: 0 additions & 2 deletions benchmark/memleak-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

const kleur = require("kleur");
Expand Down
2 changes: 0 additions & 2 deletions benchmark/perf-runner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console, no-unused-vars */

"use strict";

const fs = require("fs");
Expand Down
1 change: 0 additions & 1 deletion benchmark/suites/serializers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
"use strict";

const ServiceBroker = require("../../src/service-broker");
Expand Down
2 changes: 0 additions & 2 deletions benchmark/suites/throughput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

const kleur = require("kleur");
Expand Down
38 changes: 0 additions & 38 deletions benchmark/test.js

This file was deleted.

19 changes: 0 additions & 19 deletions dev/.eslintrc.js

This file was deleted.

70 changes: 70 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const js = require("@eslint/js");
const globals = require("globals");
const pluginSecurity = require('eslint-plugin-security');

/** @type {import('eslint').Linter.FlatConfig[]} */
module.exports = [
js.configs.recommended,
pluginSecurity.configs.recommended,
//"plugin:security/recommended-legacy",
//"plugin:prettier/recommended",
{
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/typescript/hello-world/out/*.js"],
languageOptions: {
globals: {
exports: "readonly",
require: "readonly",
__dirname: "readonly",
console: "readonly",
process: "readonly",
}
},
rules: {
"no-unused-vars": ["off"]
}
}, {
files: ["test/**/*.js"],
rules: {
"no-console": ["off"],
"no-unused-vars": ["off"]
}
}, {
files: ["dev/**/*.js", "benchmark/**/*.js", "examples/**/*.js"],
rules: {
"no-console": ["off"],
"no-unused-vars": ["off"]
}
}
];
19 changes: 0 additions & 19 deletions examples/.eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/client-server/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
"use strict";

let _ = require("lodash");
Expand Down
2 changes: 0 additions & 2 deletions examples/loadtest/client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

let { times, random, padStart } = require("lodash");
Expand Down
2 changes: 0 additions & 2 deletions examples/loadtest/clients.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

const os = require("os"),
Expand Down
2 changes: 0 additions & 2 deletions examples/loadtest/local.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

let random = require("lodash/random");
Expand Down
2 changes: 0 additions & 2 deletions examples/loadtest/nats.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

let nc1 = require("nats").connect();
let nc2 = require("nats").connect();

Expand Down
2 changes: 0 additions & 2 deletions examples/loadtest/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

let ServiceBroker = require("../../src/service-broker");
Expand Down
2 changes: 0 additions & 2 deletions examples/middlewares/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

let path = require("path");
Expand Down
2 changes: 0 additions & 2 deletions examples/multi-nodes/master.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

const path = require("path");
Expand Down
2 changes: 0 additions & 2 deletions examples/multi-nodes/node-controller.service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

const _ = require("lodash");
const kleur = require("kleur");
const cluster = require("cluster");
Expand Down
2 changes: 0 additions & 2 deletions examples/multi-nodes/node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

const _ = require("lodash");
Expand Down
2 changes: 0 additions & 2 deletions examples/opentelemetry/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

"use strict";

// Instead use `-r ./tracing.js` // require("./tracing");
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"deps": "ncu -i --format group",
"postdeps": "npm run lint:lock && npm test",
"dev": "nodemon dev/index.js",
"lint": "eslint --ext=.js benchmark bin examples src test",
"lint:fix": "eslint --fix --ext=.js benchmark bin examples src test",
"lint": "eslint benchmark bin examples src test",
"lint:fix": "eslint --fix benchmark bin examples src test",
"lint:lock": "lockfile-lint --path package-lock.json --type npm --validate-https --allowed-hosts npm",
"perf": "nodemon --allow-natives-syntax benchmark/perf-runner.js",
"pperf": "node --inspect --expose-gc benchmark/perf-runner.js",
Expand Down
2 changes: 0 additions & 2 deletions src/loggers/formatted.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* MIT Licensed
*/

/* eslint-disable no-console */

"use strict";

const BaseLogger = require("./base");
Expand Down
8 changes: 4 additions & 4 deletions src/runner-esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class MoleculerRunner {

if (this.flags.envfile) dotenv.config({ path: this.flags.envfile });
else dotenv.config();
} catch (err) {
} catch {
throw new Error(
"The 'dotenv' package is missing! Please install it with 'npm install dotenv --save' command."
);
Expand Down Expand Up @@ -216,7 +216,7 @@ export default class MoleculerRunner {

try {
return require.resolve(configPath, resolveOptions);
} catch (_) {
} catch {
return null;
}
}
Expand Down Expand Up @@ -320,7 +320,7 @@ export default class MoleculerRunner {
isDirectory(p) {
try {
return fs.lstatSync(p).isDirectory();
} catch (_) {
} catch {
// ignore
}
return false;
Expand All @@ -335,7 +335,7 @@ export default class MoleculerRunner {
isServiceFile(p) {
try {
return !fs.lstatSync(p).isDirectory();
} catch (_) {
} catch {
// ignore
}
return false;
Expand Down
8 changes: 4 additions & 4 deletions src/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class MoleculerRunner {

if (this.flags.envfile) dotenv.config({ path: this.flags.envfile });
else dotenv.config();
} catch (err) {
} catch {
throw new Error(
"The 'dotenv' package is missing! Please install it with 'npm install dotenv --save' command."
);
Expand Down Expand Up @@ -227,7 +227,7 @@ class MoleculerRunner {

try {
return require.resolve(configPath, resolveOptions);
} catch (_) {
} catch {
return null;
}
}
Expand Down Expand Up @@ -331,7 +331,7 @@ class MoleculerRunner {
isDirectory(p) {
try {
return fs.lstatSync(p).isDirectory();
} catch (_) {
} catch {
// ignore
}
return false;
Expand All @@ -346,7 +346,7 @@ class MoleculerRunner {
isServiceFile(p) {
try {
return !fs.lstatSync(p).isDirectory();
} catch (_) {
} catch {
// ignore
}
return false;
Expand Down
Loading

0 comments on commit 25e849b

Please sign in to comment.