Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump eslint from 8.57.1 to 9.12.0 #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .eslintignore

This file was deleted.

17 changes: 0 additions & 17 deletions .eslintrc

This file was deleted.

82 changes: 82 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

// eslint-disable-next-line no-underscore-dangle
const __filename = fileURLToPath(import.meta.url);
// eslint-disable-next-line no-underscore-dangle
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: [
'bin/**/*',
'build/**/*',
'coverage/**/*',
'docs/**/*',
'jsdoc/**/*',
'templates/**/*',
'tests/bench/**/*',
'tests/fixtures/**/*',
'tests/performance/**/*',
'tmp/**/*',
'public/**/*',
'node_modules/**/*',
'lib-cov/**/*',
'.grunt/**/*',
'.sonar/**/*',
'logs/**/*',
'.idea/**/*',
'samples/**/*',
],
},
...compat.extends('eslint-config-prettier'),
{
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
...globals.mongo,
},
},

rules: {
'no-await-in-loop': 0,
'comma-dangle': 0,
'max-classes-per-file': 0,

'max-len': [
'error',
{
code: 190,
ignoreComments: true,
ignoreUrls: true,
},
],

'no-underscore-dangle': [
1,
{
allow: ['_config', '_connection', '_maxListeners'],
allowAfterThis: true,
},
],

'no-return-await': 'off',
'no-console': 'error',
'no-param-reassign': 'error',
'global-require': 'error',
'no-unused-expressions': 'error',
'no-sequences': 'error',
'prefer-rest-params': 'error',
'func-names': ['error', 'as-needed'],
Comment on lines +73 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added these manually to replace some of the rules removed by removing the airbnb config.

},
},
];
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@
"serialize-error": "^8.0.1"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"child-process-promise": "^2.2.1",
"dot-only-hunter": "^1.0.3",
"eslint": "^8.25.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"globals": "^15.11.0",
"mocha": "^10.0.0",
"nyc": "^17.0.0",
"prettier": "^3.0.0",
Expand Down
3 changes: 0 additions & 3 deletions src/modules/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,4 @@ class Consumer {
}
}

/* eslint no-unused-expressions: "off" */
/* eslint no-sequences: "off" */
/* eslint arrow-body-style: "off" */
module.exports = Consumer;
2 changes: 1 addition & 1 deletion src/modules/hooks/base_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports = class BaseHooks {

const hookPromises = [];
// This rule intends to restrict it for arrays, but this is a Set which doesn't have a '.map' function to use instead.
// eslint-disable-next-line no-restricted-syntax

for (const callback of callbacks) {
hookPromises.push(runHook(source, eventName, payload, callback));
}
Expand Down
12 changes: 6 additions & 6 deletions src/modules/message-parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ module.exports.in = (msg) => {
* @param {object} options amqp.node message options object
* @return {Buffer} node.js Buffer object, sent by amqp.node
*/
/* eslint no-param-reassign: "off" */
module.exports.out = (content, options) => {
let parsedContent = content;
const falsie = [undefined, null];
if (!falsie.includes(content) && typeof content !== 'string') {
if (content.error instanceof Error) {
content.error = serializeError(content.error);
if (parsedContent.error instanceof Error) {
parsedContent.error = serializeError(parsedContent.error);
}
// if content is not a string, we JSONify it (JSON.parse can handle numbers, etc. so we can skip all the checks)
content = JSON.stringify(content);
parsedContent = JSON.stringify(parsedContent);
options.contentType = 'application/json';
} else if (falsie.includes(content)) {
} else if (falsie.includes(parsedContent)) {
return Buffer.from([]);
}

return Buffer.from(content, 'utf-8');
return Buffer.from(parsedContent, 'utf-8');
};
6 changes: 1 addition & 5 deletions src/modules/producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class Producer {
* @param {object} options message options (persistent, durable, rpc, etc.)
* @return {Promise} checkRpc response
*/
/* eslint prefer-rest-params: off */
produce(queue, msg, options) {
return this.publish(queue, msg, options);
}
Expand All @@ -217,7 +216,6 @@ class Producer {
* @param {object} options message options (persistent, durable, rpc, etc.)
* @return {Promise} checkRpc response
*/
/* eslint no-param-reassign: "off" */
async publish(queue, msg, options) {
// default options are persistent and durable because we do not want to miss any outgoing message
// unless user specify it
Expand All @@ -236,6 +234,7 @@ class Producer {
async _sendToQueue(queue, message, settings, currentRetryNumber) {
// undefined can't be serialized/buffered :p
if (!message) {
// eslint-disable-next-line no-param-reassign
message = null;
}

Expand Down Expand Up @@ -311,7 +310,4 @@ class Producer {
}
}

/* eslint no-unused-expressions: "off" */
/* eslint no-sequences: "off" */
/* eslint arrow-body-style: "off" */
module.exports = Producer;
4 changes: 1 addition & 3 deletions test/disconnect-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ const docker = require('./docker');
const arnavmqConfigurator = require('../src/index');
const utils = require('../src/modules/utils');

/* eslint func-names: "off" */
/* eslint prefer-arrow-callback: "off" */
describe('disconnections', function () {
describe('disconnections', () => {
let arnavmq;

beforeEach(() => {
Expand Down
4 changes: 1 addition & 3 deletions test/producer-consumer-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ function createFakeChannel() {
};
}

/* eslint func-names: "off" */
/* eslint prefer-arrow-callback: "off" */
describe('producer/consumer', function () {
describe('producer/consumer', () => {
const sandbox = sinon.createSandbox();
afterEach(() => sandbox.restore());

Expand Down
2 changes: 1 addition & 1 deletion test/rpc-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Producer/Consumer RPC messaging:', () => {
done(error);
}
// delete the replyTo so we don't return rpc to client
delete properties.replyTo; // eslint-disable-line
delete properties.replyTo;
})
.then(() =>
arnavmq.producer
Expand Down
Loading