ci: Expand ESLint to tests in BE packages (no-changelog) (#6147)
* 🔧 Adjust base ESLint config * 🔧 Adjust `lint` and `lintfix` in `nodes-base` * 🔧 Include `test` and `utils` in `nodes-base` * 📘 Convert JS tests to TS * 👕 Apply lintfixes
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import set from 'lodash.set';
|
||||
|
||||
import {
|
||||
import type {
|
||||
ICredentialDataDecryptedObject,
|
||||
ICredentialsHelper,
|
||||
IDataObject,
|
||||
IDeferredPromise,
|
||||
IExecuteWorkflowInfo,
|
||||
IHttpRequestHelper,
|
||||
@@ -20,12 +18,12 @@ import {
|
||||
IVersionedNodeType,
|
||||
IWorkflowBase,
|
||||
IWorkflowExecuteAdditionalData,
|
||||
NodeHelpers,
|
||||
NodeParameterValue,
|
||||
WorkflowHooks,
|
||||
} from 'n8n-workflow';
|
||||
import { deepCopy } from 'n8n-workflow';
|
||||
import { ICredentialsHelper, NodeHelpers, WorkflowHooks } from 'n8n-workflow';
|
||||
import { Credentials } from '@/Credentials';
|
||||
import { IExecuteFunctions } from '@/Interfaces';
|
||||
import type { IExecuteFunctions } from '@/Interfaces';
|
||||
|
||||
export class CredentialsHelper extends ICredentialsHelper {
|
||||
async authenticate(
|
||||
@@ -381,12 +379,12 @@ class NodeTypesClass implements INodeTypes {
|
||||
compareData.value2 as NodeParameterValue,
|
||||
);
|
||||
|
||||
if (compareOperationResult === true && combineOperation === 'any') {
|
||||
if (compareOperationResult && combineOperation === 'any') {
|
||||
// If it passes and the operation is "any" we do not have to check any
|
||||
// other ones as it should pass anyway. So go on with the next item.
|
||||
returnDataTrue.push(item);
|
||||
continue itemLoop;
|
||||
} else if (compareOperationResult === false && combineOperation === 'all') {
|
||||
} else if (!compareOperationResult && combineOperation === 'all') {
|
||||
// If it fails and the operation is "all" we do not have to check any
|
||||
// other ones as it should be not pass anyway. So go on with the next item.
|
||||
returnDataFalse.push(item);
|
||||
@@ -524,7 +522,7 @@ class NodeTypesClass implements INodeTypes {
|
||||
outputs: ['main'],
|
||||
properties: [],
|
||||
},
|
||||
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
return this.prepareOutputData(items);
|
||||
},
|
||||
@@ -570,7 +568,7 @@ class NodeTypesClass implements INodeTypes {
|
||||
},
|
||||
],
|
||||
},
|
||||
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
@@ -702,13 +700,14 @@ class NodeTypesClass implements INodeTypes {
|
||||
name: 'dotNotation',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: `<p>By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.</p><p>If that is not intended this can be deactivated, it will then set { "a.b": value } instead.</p>`,
|
||||
description:
|
||||
'<p>By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.</p><p>If that is not intended this can be deactivated, it will then set { "a.b": value } instead.</p>',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
if (items.length === 0) {
|
||||
@@ -722,13 +721,13 @@ class NodeTypesClass implements INodeTypes {
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
keepOnlySet = this.getNodeParameter('keepOnlySet', itemIndex, false) as boolean;
|
||||
item = items[itemIndex];
|
||||
const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject;
|
||||
const options = this.getNodeParameter('options', itemIndex, {});
|
||||
|
||||
const newItem: INodeExecutionData = {
|
||||
json: {},
|
||||
};
|
||||
|
||||
if (keepOnlySet !== true) {
|
||||
if (!keepOnlySet) {
|
||||
if (item.binary !== undefined) {
|
||||
// Create a shallow copy of the binary data so that the old
|
||||
// data references which do not get changed still stay behind
|
||||
@@ -737,7 +736,7 @@ class NodeTypesClass implements INodeTypes {
|
||||
Object.assign(newItem.binary, item.binary);
|
||||
}
|
||||
|
||||
newItem.json = JSON.parse(JSON.stringify(item.json));
|
||||
newItem.json = deepCopy(item.json);
|
||||
}
|
||||
|
||||
// Add boolean values
|
||||
@@ -797,7 +796,7 @@ class NodeTypesClass implements INodeTypes {
|
||||
outputs: ['main'],
|
||||
properties: [],
|
||||
},
|
||||
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
return this.prepareOutputData(items);
|
||||
@@ -851,6 +850,8 @@ export function WorkflowExecuteAdditionalData(
|
||||
connections: {},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
return {
|
||||
credentialsHelper: new CredentialsHelper(''),
|
||||
hooks: new WorkflowHooks(hookFunctions, 'trigger', '1', workflowData),
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('NodeExecuteFunctions', () => {
|
||||
BinaryDataManager.instance = undefined;
|
||||
});
|
||||
|
||||
test(`test getBinaryDataBuffer(...) & setBinaryDataBuffer(...) methods in 'default' mode`, async () => {
|
||||
test("test getBinaryDataBuffer(...) & setBinaryDataBuffer(...) methods in 'default' mode", async () => {
|
||||
// Setup a 'default' binary data manager instance
|
||||
await BinaryDataManager.init({
|
||||
mode: 'default',
|
||||
@@ -39,8 +39,8 @@ describe('NodeExecuteFunctions', () => {
|
||||
});
|
||||
|
||||
// Set our binary data buffer
|
||||
let inputData: Buffer = Buffer.from('This is some binary data', 'utf8');
|
||||
let setBinaryDataBufferResponse: IBinaryData = await setBinaryDataBuffer(
|
||||
const inputData: Buffer = Buffer.from('This is some binary data', 'utf8');
|
||||
const setBinaryDataBufferResponse: IBinaryData = await setBinaryDataBuffer(
|
||||
{
|
||||
mimeType: 'txt',
|
||||
data: 'This should be overwritten by the actual payload in the response',
|
||||
@@ -54,7 +54,7 @@ describe('NodeExecuteFunctions', () => {
|
||||
|
||||
// Now, re-fetch our data.
|
||||
// An ITaskDataConnections object is used to share data between nodes. The top level property, 'main', represents the successful output object from a previous node.
|
||||
let taskDataConnectionsInput: ITaskDataConnections = {
|
||||
const taskDataConnectionsInput: ITaskDataConnections = {
|
||||
main: [],
|
||||
};
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('NodeExecuteFunctions', () => {
|
||||
]);
|
||||
|
||||
// Now, lets fetch our data! The item will be item index 0.
|
||||
let getBinaryDataBufferResponse: Buffer = await getBinaryDataBuffer(
|
||||
const getBinaryDataBufferResponse: Buffer = await getBinaryDataBuffer(
|
||||
taskDataConnectionsInput,
|
||||
0,
|
||||
'data',
|
||||
@@ -79,7 +79,7 @@ describe('NodeExecuteFunctions', () => {
|
||||
expect(getBinaryDataBufferResponse).toEqual(inputData);
|
||||
});
|
||||
|
||||
test(`test getBinaryDataBuffer(...) & setBinaryDataBuffer(...) methods in 'filesystem' mode`, async () => {
|
||||
test("test getBinaryDataBuffer(...) & setBinaryDataBuffer(...) methods in 'filesystem' mode", async () => {
|
||||
// Setup a 'filesystem' binary data manager instance
|
||||
await BinaryDataManager.init({
|
||||
mode: 'filesystem',
|
||||
@@ -90,8 +90,8 @@ describe('NodeExecuteFunctions', () => {
|
||||
});
|
||||
|
||||
// Set our binary data buffer
|
||||
let inputData: Buffer = Buffer.from('This is some binary data', 'utf8');
|
||||
let setBinaryDataBufferResponse: IBinaryData = await setBinaryDataBuffer(
|
||||
const inputData: Buffer = Buffer.from('This is some binary data', 'utf8');
|
||||
const setBinaryDataBufferResponse: IBinaryData = await setBinaryDataBuffer(
|
||||
{
|
||||
mimeType: 'txt',
|
||||
data: 'This should be overwritten with the name of the configured data manager',
|
||||
@@ -112,7 +112,7 @@ describe('NodeExecuteFunctions', () => {
|
||||
|
||||
// Now, re-fetch our data.
|
||||
// An ITaskDataConnections object is used to share data between nodes. The top level property, 'main', represents the successful output object from a previous node.
|
||||
let taskDataConnectionsInput: ITaskDataConnections = {
|
||||
const taskDataConnectionsInput: ITaskDataConnections = {
|
||||
main: [],
|
||||
};
|
||||
|
||||
@@ -127,7 +127,7 @@ describe('NodeExecuteFunctions', () => {
|
||||
]);
|
||||
|
||||
// Now, lets fetch our data! The item will be item index 0.
|
||||
let getBinaryDataBufferResponse: Buffer = await getBinaryDataBuffer(
|
||||
const getBinaryDataBufferResponse: Buffer = await getBinaryDataBuffer(
|
||||
taskDataConnectionsInput,
|
||||
0,
|
||||
'data',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createDeferredPromise, IConnections, INode, IRun, Workflow } from 'n8n-workflow';
|
||||
import type { IConnections, INode, IRun } from 'n8n-workflow';
|
||||
import { createDeferredPromise, Workflow } from 'n8n-workflow';
|
||||
import { WorkflowExecute } from '@/WorkflowExecute';
|
||||
|
||||
import * as Helpers from './Helpers';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ILogger, LoggerProxy } from 'n8n-workflow';
|
||||
import type { ILogger } from 'n8n-workflow';
|
||||
import { LoggerProxy } from 'n8n-workflow';
|
||||
|
||||
const fakeLogger = {
|
||||
log: () => {},
|
||||
|
||||
Reference in New Issue
Block a user