refactor(core): Remove linting exceptions in nodes-base (no-changelog) (#4944)

This commit is contained in:
Michael Kret
2023-01-13 19:11:56 +02:00
committed by GitHub
parent d7732ea150
commit 6608e69457
254 changed files with 2687 additions and 2675 deletions

View File

@@ -30,6 +30,42 @@ import { simpleParser, Source as ParserSource } from 'mailparser';
import _ from 'lodash';
export async function parseRawEmail(
this: ITriggerFunctions,
messageEncoded: ParserSource,
dataPropertyNameDownload: string,
): Promise<INodeExecutionData> {
const responseData = await simpleParser(messageEncoded);
const headers: IDataObject = {};
for (const header of responseData.headerLines) {
headers[header.key] = header.line;
}
// @ts-ignore
responseData.headers = headers;
// @ts-ignore
responseData.headerLines = undefined;
const binaryData: IBinaryKeyData = {};
if (responseData.attachments) {
for (let i = 0; i < responseData.attachments.length; i++) {
const attachment = responseData.attachments[i];
binaryData[`${dataPropertyNameDownload}${i}`] = await this.helpers.prepareBinaryData(
attachment.content,
attachment.filename,
attachment.contentType,
);
}
// @ts-ignore
responseData.attachments = undefined;
}
return {
json: responseData as unknown as IDataObject,
binary: Object.keys(binaryData).length ? binaryData : undefined,
} as INodeExecutionData;
}
const versionDescription: INodeTypeDescription = {
displayName: 'Email Trigger (IMAP)',
name: 'emailReadImap',
@@ -272,7 +308,6 @@ export class EmailReadImapV1 implements INodeType {
// Returns the email attachments
const getAttachment = async (
imapConnection: ImapSimple,
// tslint:disable-next-line:no-any
parts: any[],
message: Message,
): Promise<IBinaryData[]> => {
@@ -599,39 +634,3 @@ export class EmailReadImapV1 implements INodeType {
};
}
}
export async function parseRawEmail(
this: ITriggerFunctions,
messageEncoded: ParserSource,
dataPropertyNameDownload: string,
): Promise<INodeExecutionData> {
const responseData = await simpleParser(messageEncoded);
const headers: IDataObject = {};
for (const header of responseData.headerLines) {
headers[header.key] = header.line;
}
// @ts-ignore
responseData.headers = headers;
// @ts-ignore
responseData.headerLines = undefined;
const binaryData: IBinaryKeyData = {};
if (responseData.attachments) {
for (let i = 0; i < responseData.attachments.length; i++) {
const attachment = responseData.attachments[i];
binaryData[`${dataPropertyNameDownload}${i}`] = await this.helpers.prepareBinaryData(
attachment.content,
attachment.filename,
attachment.contentType,
);
}
// @ts-ignore
responseData.attachments = undefined;
}
return {
json: responseData as unknown as IDataObject,
binary: Object.keys(binaryData).length ? binaryData : undefined,
} as INodeExecutionData;
}

View File

@@ -30,6 +30,42 @@ import { simpleParser, Source as ParserSource } from 'mailparser';
import _ from 'lodash';
import { ICredentialsDataImap, isCredentialsDataImap } from '../../../credentials/Imap.credentials';
export async function parseRawEmail(
this: ITriggerFunctions,
messageEncoded: ParserSource,
dataPropertyNameDownload: string,
): Promise<INodeExecutionData> {
const responseData = await simpleParser(messageEncoded);
const headers: IDataObject = {};
for (const header of responseData.headerLines) {
headers[header.key] = header.line;
}
// @ts-ignore
responseData.headers = headers;
// @ts-ignore
responseData.headerLines = undefined;
const binaryData: IBinaryKeyData = {};
if (responseData.attachments) {
for (let i = 0; i < responseData.attachments.length; i++) {
const attachment = responseData.attachments[i];
binaryData[`${dataPropertyNameDownload}${i}`] = await this.helpers.prepareBinaryData(
attachment.content,
attachment.filename,
attachment.contentType,
);
}
// @ts-ignore
responseData.attachments = undefined;
}
return {
json: responseData as unknown as IDataObject,
binary: Object.keys(binaryData).length ? binaryData : undefined,
} as INodeExecutionData;
}
const versionDescription: INodeTypeDescription = {
displayName: 'Email Trigger (IMAP)',
name: 'emailReadImap',
@@ -279,8 +315,6 @@ export class EmailReadImapV2 implements INodeType {
// Returns the email attachments
const getAttachment = async (
imapConnection: ImapSimple,
// tslint:disable-next-line:no-any
parts: any[],
message: Message,
): Promise<IBinaryData[]> => {
@@ -571,6 +605,7 @@ export class EmailReadImapV2 implements INodeType {
conn.on('error', async (error) => {
const errorCode = error.code.toUpperCase();
Logger.verbose(`IMAP connection experienced an error: (${errorCode})`, { error });
// eslint-disable-next-line @typescript-eslint/no-use-before-define
await closeFunction();
this.emitError(error);
});
@@ -619,39 +654,3 @@ export class EmailReadImapV2 implements INodeType {
};
}
}
export async function parseRawEmail(
this: ITriggerFunctions,
messageEncoded: ParserSource,
dataPropertyNameDownload: string,
): Promise<INodeExecutionData> {
const responseData = await simpleParser(messageEncoded);
const headers: IDataObject = {};
for (const header of responseData.headerLines) {
headers[header.key] = header.line;
}
// @ts-ignore
responseData.headers = headers;
// @ts-ignore
responseData.headerLines = undefined;
const binaryData: IBinaryKeyData = {};
if (responseData.attachments) {
for (let i = 0; i < responseData.attachments.length; i++) {
const attachment = responseData.attachments[i];
binaryData[`${dataPropertyNameDownload}${i}`] = await this.helpers.prepareBinaryData(
attachment.content,
attachment.filename,
attachment.contentType,
);
}
// @ts-ignore
responseData.attachments = undefined;
}
return {
json: responseData as unknown as IDataObject,
binary: Object.keys(binaryData).length ? binaryData : undefined,
} as INodeExecutionData;
}