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

@@ -777,20 +777,14 @@ export class EditImage implements INodeType {
},
...nodeOperations,
].sort((a, b) => {
if (
(a as INodePropertyOptions).name.toLowerCase() <
(b as INodePropertyOptions).name.toLowerCase()
) {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return -1;
}
if (
(a as INodePropertyOptions).name.toLowerCase() >
(b as INodePropertyOptions).name.toLowerCase()
) {
if (a.name.toLowerCase() > b.name.toLowerCase()) {
return 1;
}
return 0;
}) as INodePropertyOptions[],
}),
default: 'border',
},
{
@@ -948,15 +942,15 @@ export class EditImage implements INodeType {
const files = await getSystemFonts();
const returnData: INodePropertyOptions[] = [];
files.forEach((file: string) => {
const pathParts = pathParse(file);
files.forEach((entry: string) => {
const pathParts = pathParse(entry);
if (!pathParts.ext) {
return;
}
returnData.push({
name: pathParts.name,
value: file,
value: entry,
});
});
@@ -991,10 +985,10 @@ export class EditImage implements INodeType {
try {
item = items[itemIndex];
const operation = this.getNodeParameter('operation', itemIndex) as string;
const operation = this.getNodeParameter('operation', itemIndex);
const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string;
const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject;
const options = this.getNodeParameter('options', itemIndex, {});
const cleanupFunctions: Array<() => void> = [];
@@ -1056,7 +1050,7 @@ export class EditImage implements INodeType {
});
}
if (item.binary[dataPropertyName as string] === undefined) {
if (item.binary[dataPropertyName] === undefined) {
throw new NodeOperationError(
this.getNode(),
`Item does not contain any binary data with the name "${dataPropertyName}".`,
@@ -1083,12 +1077,12 @@ export class EditImage implements INodeType {
if (operation === 'information') {
// Just return the information
const imageData = await new Promise<IDataObject>((resolve, reject) => {
gmInstance = gmInstance.identify((error, imageData) => {
gmInstance = gmInstance.identify((error, data) => {
if (error) {
reject(error);
return;
}
resolve(imageData as unknown as IDataObject);
resolve(data as unknown as IDataObject);
});
});
@@ -1269,15 +1263,13 @@ export class EditImage implements INodeType {
// but the incoming data does not get changed.
Object.assign(newItem.binary, item.binary);
// Make a deep copy of the binary data we change
if (newItem.binary![dataPropertyName as string]) {
newItem.binary![dataPropertyName as string] = deepCopy(
newItem.binary![dataPropertyName as string],
);
if (newItem.binary[dataPropertyName]) {
newItem.binary[dataPropertyName] = deepCopy(newItem.binary[dataPropertyName]);
}
}
if (newItem.binary![dataPropertyName as string] === undefined) {
newItem.binary![dataPropertyName as string] = {
if (newItem.binary![dataPropertyName] === undefined) {
newItem.binary![dataPropertyName] = {
data: '',
mimeType: '',
};
@@ -1289,31 +1281,31 @@ export class EditImage implements INodeType {
if (options.format !== undefined) {
gmInstance = gmInstance!.setFormat(options.format as string);
newItem.binary![dataPropertyName as string].fileExtension = options.format as string;
newItem.binary![dataPropertyName as string].mimeType = `image/${options.format}`;
const fileName = newItem.binary![dataPropertyName as string].fileName;
if (fileName && fileName.includes('.')) {
newItem.binary![dataPropertyName as string].fileName =
newItem.binary![dataPropertyName].fileExtension = options.format as string;
newItem.binary![dataPropertyName].mimeType = `image/${options.format}`;
const fileName = newItem.binary![dataPropertyName].fileName;
if (fileName?.includes('.')) {
newItem.binary![dataPropertyName].fileName =
fileName.split('.').slice(0, -1).join('.') + '.' + options.format;
}
}
if (options.fileName !== undefined) {
newItem.binary![dataPropertyName as string].fileName = options.fileName as string;
newItem.binary![dataPropertyName].fileName = options.fileName as string;
}
returnData.push(
await new Promise<INodeExecutionData>((resolve, reject) => {
gmInstance.toBuffer(async (error: Error | null, buffer: Buffer) => {
cleanupFunctions.forEach(async (cleanup) => await cleanup());
cleanupFunctions.forEach(async (cleanup) => cleanup());
if (error) {
return reject(error);
}
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(buffer));
newItem.binary![dataPropertyName as string] = {
...newItem.binary![dataPropertyName as string],
newItem.binary![dataPropertyName] = {
...newItem.binary![dataPropertyName],
...binaryData,
};