mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
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:
@@ -361,8 +361,7 @@ export class Ftp implements INodeType {
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
const credentials = credential.data as ICredentialDataDecryptedObject;
|
||||
try {
|
||||
let ftp: ftpClient;
|
||||
ftp = new ftpClient();
|
||||
const ftp = new ftpClient();
|
||||
await ftp.connect({
|
||||
host: credentials.host as string,
|
||||
port: credentials.port as number,
|
||||
@@ -386,8 +385,7 @@ export class Ftp implements INodeType {
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
const credentials = credential.data as ICredentialDataDecryptedObject;
|
||||
try {
|
||||
let sftp: sftpClient;
|
||||
sftp = new sftpClient();
|
||||
const sftp = new sftpClient();
|
||||
await sftp.connect({
|
||||
host: credentials.host as string,
|
||||
port: credentials.port as number,
|
||||
@@ -478,7 +476,7 @@ export class Ftp implements INodeType {
|
||||
);
|
||||
} else {
|
||||
responseData = await sftp!.list(path);
|
||||
responseData.forEach((item) => normalizeSFtpItem(item as sftpClient.FileInfo, path));
|
||||
responseData.forEach((item) => normalizeSFtpItem(item, path));
|
||||
returnItems.push.apply(
|
||||
returnItems,
|
||||
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
|
||||
@@ -538,7 +536,7 @@ export class Ftp implements INodeType {
|
||||
const remotePath = this.getNodeParameter('path', i) as string;
|
||||
await recursivelyCreateSftpDirs(sftp!, remotePath);
|
||||
|
||||
if (this.getNodeParameter('binaryData', i) === true) {
|
||||
if (this.getNodeParameter('binaryData', i)) {
|
||||
// Is binary file to upload
|
||||
const item = items[i];
|
||||
|
||||
@@ -562,10 +560,7 @@ export class Ftp implements INodeType {
|
||||
await sftp!.put(buffer, remotePath);
|
||||
} else {
|
||||
// Is text file
|
||||
const buffer = Buffer.from(
|
||||
this.getNodeParameter('fileContent', i) as string,
|
||||
'utf8',
|
||||
) as Buffer;
|
||||
const buffer = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
|
||||
await sftp!.put(buffer, remotePath);
|
||||
}
|
||||
|
||||
@@ -653,7 +648,7 @@ export class Ftp implements INodeType {
|
||||
const fileName = basename(remotePath);
|
||||
const dirPath = remotePath.replace(fileName, '');
|
||||
|
||||
if (this.getNodeParameter('binaryData', i) === true) {
|
||||
if (this.getNodeParameter('binaryData', i)) {
|
||||
// Is binary file to upload
|
||||
const item = items[i];
|
||||
|
||||
@@ -688,10 +683,7 @@ export class Ftp implements INodeType {
|
||||
}
|
||||
} else {
|
||||
// Is text file
|
||||
const buffer = Buffer.from(
|
||||
this.getNodeParameter('fileContent', i) as string,
|
||||
'utf8',
|
||||
) as Buffer;
|
||||
const buffer = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
|
||||
try {
|
||||
await ftp!.put(buffer, remotePath);
|
||||
} catch (error) {
|
||||
@@ -754,26 +746,29 @@ async function callRecursiveList(
|
||||
const directoryItems: sftpClient.FileInfo[] = [];
|
||||
let index = 0;
|
||||
|
||||
const prepareAndNormalize = (item: sftpClient.FileInfo) => {
|
||||
if (pathArray[index].endsWith('/')) {
|
||||
currentPath = `${pathArray[index]}${item.name}`;
|
||||
} else {
|
||||
currentPath = `${pathArray[index]}/${item.name}`;
|
||||
}
|
||||
|
||||
// Is directory
|
||||
if (item.type === 'd') {
|
||||
pathArray.push(currentPath);
|
||||
}
|
||||
|
||||
normalizeFunction(item as ftpClient.ListingElement & sftpClient.FileInfo, currentPath, true);
|
||||
directoryItems.push(item);
|
||||
};
|
||||
|
||||
do {
|
||||
const returnData: sftpClient.FileInfo[] | (string | ftpClient.ListingElement)[] =
|
||||
// tslint:disable-next-line: array-type
|
||||
const returnData: sftpClient.FileInfo[] | Array<string | ftpClient.ListingElement> =
|
||||
await client.list(pathArray[index]);
|
||||
|
||||
// @ts-ignore
|
||||
returnData.map((item: sftpClient.FileInfo) => {
|
||||
if ((pathArray[index] as string).endsWith('/')) {
|
||||
currentPath = `${pathArray[index]}${item.name}`;
|
||||
} else {
|
||||
currentPath = `${pathArray[index]}/${item.name}`;
|
||||
}
|
||||
|
||||
// Is directory
|
||||
if (item.type === 'd') {
|
||||
pathArray.push(currentPath);
|
||||
}
|
||||
|
||||
normalizeFunction(item as ftpClient.ListingElement & sftpClient.FileInfo, currentPath, true);
|
||||
directoryItems.push(item);
|
||||
});
|
||||
returnData.map(prepareAndNormalize);
|
||||
index++;
|
||||
} while (index <= pathArray.length - 1);
|
||||
|
||||
@@ -782,9 +777,9 @@ async function callRecursiveList(
|
||||
|
||||
async function recursivelyCreateSftpDirs(sftp: sftpClient, path: string) {
|
||||
const dirPath = dirname(path);
|
||||
const dirExists = await sftp!.exists(dirPath);
|
||||
const dirExists = await sftp.exists(dirPath);
|
||||
|
||||
if (!dirExists) {
|
||||
await sftp!.mkdir(dirPath, true);
|
||||
await sftp.mkdir(dirPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user