refactor(core): Remove linting exceptions in nodes-base (#4794)

*  enabled array-type

*  await-thenable on

*  ban-types on

*  default-param-last on

*  dot-notation on

*  member-delimiter-style on

*  no-duplicate-imports on

*  no-empty-interface on

*  no-floating-promises on

*  no-for-in-array on

*  no-invalid-void-type on

*  no-loop-func on

*  no-shadow on

*  ban-ts-comment re enabled

*  @typescript-eslint/lines-between-class-members on

* address my own comment

* @typescript-eslint/return-await on

* @typescript-eslint/promise-function-async on

* @typescript-eslint/no-unnecessary-boolean-literal-compare on

* @typescript-eslint/no-unnecessary-type-assertion on

* prefer-const on

* @typescript-eslint/prefer-optional-chain on

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Michael Kret
2022-12-02 22:54:28 +02:00
committed by GitHub
parent 8101c05d6f
commit 61e26804ba
796 changed files with 3735 additions and 2847 deletions

View File

@@ -214,8 +214,8 @@ export class EmailReadImapV1 implements INodeType {
if (!_.isEmpty(tlsOptions)) {
config.imap.tlsOptions = tlsOptions;
}
const conn = imapConnect(config).then(async (conn) => {
return conn;
const conn = imapConnect(config).then(async (entry) => {
return entry;
});
(await conn).getBoxes((_err, _boxes) => {});
} catch (error) {
@@ -271,8 +271,8 @@ export class EmailReadImapV1 implements INodeType {
// Returns the email attachments
const getAttachment = async (
connection: ImapSimple,
imapConnection: ImapSimple,
// tslint:disable-next-line:no-any
parts: any[],
message: Message,
): Promise<IBinaryData[]> => {
@@ -288,13 +288,15 @@ export class EmailReadImapV1 implements INodeType {
const attachmentPromises = [];
let attachmentPromise;
for (const attachmentPart of attachmentParts) {
attachmentPromise = connection.getPartData(message, attachmentPart).then((partData) => {
// Return it in the format n8n expects
return this.helpers.prepareBinaryData(
partData,
attachmentPart.disposition.params.filename,
);
});
attachmentPromise = imapConnection
.getPartData(message, attachmentPart)
.then(async (partData) => {
// Return it in the format n8n expects
return this.helpers.prepareBinaryData(
partData,
attachmentPart.disposition.params.filename,
);
});
attachmentPromises.push(attachmentPromise);
}
@@ -304,7 +306,7 @@ export class EmailReadImapV1 implements INodeType {
// Returns all the new unseen messages
const getNewEmails = async (
connection: ImapSimple,
imapConnection: ImapSimple,
searchCriteria: Array<string | string[]>,
): Promise<INodeExecutionData[]> => {
const format = this.getNodeParameter('format', 0) as string;
@@ -325,7 +327,7 @@ export class EmailReadImapV1 implements INodeType {
};
}
const results = await connection.search(searchCriteria, fetchOptions);
const results = await imapConnection.search(searchCriteria, fetchOptions);
const newEmails: INodeExecutionData[] = [];
let newEmail: INodeExecutionData, messageHeader, messageBody;
@@ -371,7 +373,7 @@ export class EmailReadImapV1 implements INodeType {
const downloadAttachments = this.getNodeParameter('downloadAttachments') as boolean;
let dataPropertyAttachmentsPrefixName = '';
if (downloadAttachments === true) {
if (downloadAttachments) {
dataPropertyAttachmentsPrefixName = this.getNodeParameter(
'dataPropertyAttachmentsPrefixName',
) as string;
@@ -416,9 +418,9 @@ export class EmailReadImapV1 implements INodeType {
}
}
if (downloadAttachments === true) {
if (downloadAttachments) {
// Get attachments and add them if any get found
attachments = await getAttachment(connection, parts, message);
attachments = await getAttachment(imapConnection, parts, message);
if (attachments.length) {
newEmail.binary = {};
for (let i = 0; i < attachments.length; i++) {
@@ -463,15 +465,15 @@ export class EmailReadImapV1 implements INodeType {
if (postProcessAction === 'read') {
const uidList = results.map((e) => e.attributes.uid);
if (uidList.length > 0) {
connection.addFlags(uidList, '\\SEEN');
await imapConnection.addFlags(uidList, '\\SEEN');
}
}
return newEmails;
};
const returnedPromise: IDeferredPromise<void> | undefined = await createDeferredPromise<void>();
const returnedPromise: IDeferredPromise<void> | undefined = await createDeferredPromise();
const establishConnection = (): Promise<ImapSimple> => {
const establishConnection = async (): Promise<ImapSimple> => {
let searchCriteria = ['UNSEEN'] as Array<string | string[]>;
if (options.customEmailConfig !== undefined) {
try {
@@ -520,7 +522,7 @@ export class EmailReadImapV1 implements INodeType {
});
// Wait with resolving till the returnedPromise got resolved, else n8n will be unhappy
// if it receives an error before the workflow got activated
returnedPromise.promise().then(() => {
await returnedPromise.promise().then(() => {
this.emitError(error as Error);
});
}
@@ -575,7 +577,7 @@ export class EmailReadImapV1 implements INodeType {
if (options.forceReconnect !== undefined) {
reconnectionInterval = setInterval(async () => {
Logger.verbose('Forcing reconnection of IMAP node.');
await connection.end();
connection.end();
connection = await establishConnection();
await connection.openBox(mailbox);
}, (options.forceReconnect as number) * 1000 * 60);
@@ -586,7 +588,7 @@ export class EmailReadImapV1 implements INodeType {
if (reconnectionInterval) {
clearInterval(reconnectionInterval);
}
await connection.end();
connection.end();
}
// Resolve returned-promise so that waiting errors can be emitted