🎨 Set up linting and formatting (#2120)

* ⬆️ Upgrade TS to 4.3.5

* 👕 Add ESLint configs

* 🎨 Add Prettier config

* 📦 Add deps and commands

*  Adjust global .editorconfig to new ruleset

* 🔥 Remove unneeded local .editorconfig

* 📦 Update deps in editor-ui

* 🔨 Limit Prettier to only TS files

*  Add recommended VSCode extensions

* 👕 Fix build

* 🔥 Remove Vue setting from global config

*  Disable prefer-default-export per feedback

* ✏️ Add forgotten divider

* 👕 Disable no-plusplus

* 👕 Disable class-methods-use-this

* ✏️ Alphabetize overrides

* 👕 Add one-var consecutive override

*  Revert one-var consecutive override

This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc.

* 🎨 👕 Lint and format workflow package (#2121)

* 🎨 Format /workflow package

* 👕 Lint /workflow package

* 🎨 Re-format /workflow package

* 👕 Re-lint /workflow package

* ✏️ Fix typo

*  Consolidate if-checks

* 🔥 Remove prefer-default-export exceptions

* 🔥 Remove no-plusplus exceptions

* 🔥 Remove class-methods-use-this exceptions

* 🎨 👕 Lint and format node-dev package (#2122)

* 🎨 Format /node-dev package

*  Exclude templates from ESLint config

This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates.

* 👕 Lint /node-dev package

* 🔥 Remove prefer-default-export exceptions

* 🔥 Remove no-plusplus exceptions

* 🎨 👕 Lint and format core package (#2123)

* 🎨 Format /core package

* 👕 Lint /core package

* 🎨 Re-format /core package

* 👕 Re-lint /core package

* 🔥 Remove prefer-default-export exceptions

* 🔥 Remove no-plusplus exceptions

* 🔥 Remove class-methods-use-this exceptions

* 🎨 👕 Lint and format cli package (#2124)

* 🎨 Format /cli package

* 👕 Exclude migrations from linting

* 👕 Lint /cli package

* 🎨 Re-format /cli package

* 👕 Re-lint /cli package

* 👕 Fix build

* 🔥 Remove prefer-default-export exceptions

*  Update exceptions in ActiveExecutions

* 🔥 Remove no-plusplus exceptions

* 🔥 Remove class-methods-use-this exceptions

* 👕 fix lint issues

* 🔧 use package specific linter, remove tslint command

* 🔨 resolve build issue, sync dependencies

* 🔧 change lint command

Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
This commit is contained in:
Iván Ovejero
2021-08-29 20:58:11 +02:00
committed by GitHub
parent 223cd75685
commit 56c4c6991f
108 changed files with 11832 additions and 8416 deletions

View File

@@ -16,11 +16,8 @@ interface StubNode {
parameters: INodeParameters;
}
describe('Workflow', () => {
describe('renameNodeInExpressions', () => {
const tests = [
{
description: 'do nothing if there is no expression',
@@ -43,13 +40,13 @@ describe('Workflow', () => {
currentName: 'Node1',
newName: 'NewName',
parameters: {
value1: '={{$node.Node1.data.value1 + \'Node1\'}}',
value2: '={{$node.Node1.data.value2 + \' - \' + $node.Node1.data.value2}}',
value1: "={{$node.Node1.data.value1 + 'Node1'}}",
value2: "={{$node.Node1.data.value2 + ' - ' + $node.Node1.data.value2}}",
},
},
output: {
value1: '={{$node.NewName.data.value1 + \'Node1\'}}',
value2: '={{$node.NewName.data.value2 + \' - \' + $node.NewName.data.value2}}',
value1: "={{$node.NewName.data.value1 + 'Node1'}}",
value2: "={{$node.NewName.data.value2 + ' - ' + $node.NewName.data.value2}}",
},
},
{
@@ -59,27 +56,31 @@ describe('Workflow', () => {
newName: 'NewName',
parameters: {
value1: '={{$node["Node1"]["data"]["value1"] + \'Node1\'}}',
value2: '={{$node["Node1"]["data"]["value2"] + \' - \' + $node["Node1"]["data"]["value2"]}}',
value2:
'={{$node["Node1"]["data"]["value2"] + \' - \' + $node["Node1"]["data"]["value2"]}}',
},
},
output: {
value1: '={{$node["NewName"]["data"]["value1"] + \'Node1\'}}',
value2: '={{$node["NewName"]["data"]["value2"] + \' - \' + $node["NewName"]["data"]["value2"]}}',
value2:
'={{$node["NewName"]["data"]["value2"] + \' - \' + $node["NewName"]["data"]["value2"]}}',
},
},
{
description: 'should work with [\'nodeName\']',
description: "should work with ['nodeName']",
input: {
currentName: 'Node1',
newName: 'NewName',
parameters: {
value1: '={{$node[\'Node1\'][\'data\'][\'value1\'] + \'Node1\'}}',
value2: '={{$node[\'Node1\'][\'data\'][\'value2\'] + \' - \' + $node[\'Node1\'][\'data\'][\'value2\']}}',
value1: "={{$node['Node1']['data']['value1'] + 'Node1'}}",
value2:
"={{$node['Node1']['data']['value2'] + ' - ' + $node['Node1']['data']['value2']}}",
},
},
output: {
value1: '={{$node[\'NewName\'][\'data\'][\'value1\'] + \'Node1\'}}',
value2: '={{$node[\'NewName\'][\'data\'][\'value2\'] + \' - \' + $node[\'NewName\'][\'data\'][\'value2\']}}',
value1: "={{$node['NewName']['data']['value1'] + 'Node1'}}",
value2:
"={{$node['NewName']['data']['value2'] + ' - ' + $node['NewName']['data']['value2']}}",
},
},
{
@@ -88,22 +89,22 @@ describe('Workflow', () => {
currentName: 'Node1',
newName: 'NewName',
parameters: {
level1a: '={{$node.Node1.data.value1 + \'Node1\'}}',
level1a: "={{$node.Node1.data.value1 + 'Node1'}}",
level1b: [
{
value2a: '={{$node.Node1.data.value1 + \'Node1\'}}',
value2b: '={{$node.Node1.data.value1 + \'Node1\'}}',
value2a: "={{$node.Node1.data.value1 + 'Node1'}}",
value2b: "={{$node.Node1.data.value1 + 'Node1'}}",
},
],
level1c: {
value2a: {
value3a: '={{$node.Node1.data.value1 + \'Node1\'}}',
value3a: "={{$node.Node1.data.value1 + 'Node1'}}",
value3b: [
{
value4a: '={{$node.Node1.data.value1 + \'Node1\'}}',
value4a: "={{$node.Node1.data.value1 + 'Node1'}}",
value4b: {
value5a: '={{$node.Node1.data.value1 + \'Node1\'}}',
value5b: '={{$node.Node1.data.value1 + \'Node1\'}}',
value5a: "={{$node.Node1.data.value1 + 'Node1'}}",
value5b: "={{$node.Node1.data.value1 + 'Node1'}}",
},
},
],
@@ -112,22 +113,22 @@ describe('Workflow', () => {
} as INodeParameters,
},
output: {
level1a: '={{$node.NewName.data.value1 + \'Node1\'}}',
level1a: "={{$node.NewName.data.value1 + 'Node1'}}",
level1b: [
{
value2a: '={{$node.NewName.data.value1 + \'Node1\'}}',
value2b: '={{$node.NewName.data.value1 + \'Node1\'}}',
value2a: "={{$node.NewName.data.value1 + 'Node1'}}",
value2b: "={{$node.NewName.data.value1 + 'Node1'}}",
},
],
level1c: {
value2a: {
value3a: '={{$node.NewName.data.value1 + \'Node1\'}}',
value3a: "={{$node.NewName.data.value1 + 'Node1'}}",
value3b: [
{
value4a: '={{$node.NewName.data.value1 + \'Node1\'}}',
value4a: "={{$node.NewName.data.value1 + 'Node1'}}",
value4b: {
value5a: '={{$node.NewName.data.value1 + \'Node1\'}}',
value5b: '={{$node.NewName.data.value1 + \'Node1\'}}',
value5a: "={{$node.NewName.data.value1 + 'Node1'}}",
value5b: "={{$node.NewName.data.value1 + 'Node1'}}",
},
},
],
@@ -142,15 +143,17 @@ describe('Workflow', () => {
for (const testData of tests) {
test(testData.description, () => {
const result = workflow.renameNodeInExpressions(testData.input.parameters, testData.input.currentName, testData.input.newName);
const result = workflow.renameNodeInExpressions(
testData.input.parameters,
testData.input.currentName,
testData.input.newName,
);
expect(result).toEqual(testData.output);
});
}
});
describe('renameNode', () => {
const tests = [
{
description: 'rename node without connections',
@@ -507,8 +510,8 @@ describe('Workflow', () => {
{
name: 'Node2',
parameters: {
value1: '={{$node.Node1.data.value1 + \'Node1\'}}',
value2: '={{$node.Node1.data.value2 + \' - \' + $node.Node1.data.value2}}',
value1: "={{$node.Node1.data.value1 + 'Node1'}}",
value2: "={{$node.Node1.data.value2 + ' - ' + $node.Node1.data.value2}}",
},
},
],
@@ -526,8 +529,8 @@ describe('Workflow', () => {
{
name: 'Node2',
parameters: {
value1: '={{$node.Node1New.data.value1 + \'Node1\'}}',
value2: '={{$node.Node1New.data.value2 + \' - \' + $node.Node1New.data.value2}}',
value1: "={{$node.Node1New.data.value1 + 'Node1'}}",
value2: "={{$node.Node1New.data.value2 + ' - ' + $node.Node1New.data.value2}}",
},
},
],
@@ -545,10 +548,7 @@ describe('Workflow', () => {
parameters: stubData.parameters,
type: 'test.set',
typeVersion: 1,
position: [
100,
100,
],
position: [100, 100],
};
}
@@ -559,13 +559,17 @@ describe('Workflow', () => {
for (const testData of tests) {
test(testData.description, () => {
executeNodes = [];
for (const node of testData.input.nodes) {
executeNodes.push(createNodeData(node));
}
workflow = new Workflow({ nodes: executeNodes, connections: testData.input.connections as IConnections, active: false, nodeTypes });
workflow = new Workflow({
nodes: executeNodes,
connections: testData.input.connections as IConnections,
active: false,
nodeTypes,
});
workflow.renameNode(testData.input.currentName, testData.input.newName);
resultNodes = {};
@@ -577,12 +581,9 @@ describe('Workflow', () => {
expect(workflow.connectionsBySourceNode).toEqual(testData.output.connections);
});
}
});
describe('getParameterValue', () => {
const tests = [
{
description: 'read simple not expression value',
@@ -639,7 +640,8 @@ describe('Workflow', () => {
},
},
{
description: 'read data from node-output-data with with long "$node.{NODE}.data" syntax add value and append text',
description:
'read data from node-output-data with with long "$node.{NODE}.data" syntax add value and append text',
input: {
Node1: {
parameters: {
@@ -657,7 +659,8 @@ describe('Workflow', () => {
},
},
{
description: 'read deep-data from node-output-data with with long "$node.{NODE}.data" syntax with JavaScript Code',
description:
'read deep-data from node-output-data with with long "$node.{NODE}.data" syntax with JavaScript Code',
input: {
Node1: {
parameters: {
@@ -727,7 +730,8 @@ describe('Workflow', () => {
},
},
{
description: 'read deep-data from node-output-data with with long "$node.{NODE}.data" syntax',
description:
'read deep-data from node-output-data with with long "$node.{NODE}.data" syntax',
input: {
Node1: {
parameters: {
@@ -753,7 +757,8 @@ describe('Workflow', () => {
},
},
{
description: 'read binary-string-data from incoming-node-data with with short "$binary" syntax',
description:
'read binary-string-data from incoming-node-data with with short "$binary" syntax',
input: {
Node1: {
parameters: {
@@ -779,7 +784,8 @@ describe('Workflow', () => {
},
},
{
description: 'read binary-string-data from node-output-data with with long "$node.{NODE}.binary" syntax',
description:
'read binary-string-data from node-output-data with with long "$node.{NODE}.binary" syntax',
input: {
Node1: {
parameters: {
@@ -879,7 +885,8 @@ describe('Workflow', () => {
},
},
{
description: 'return resolved value when referencing another property with expression (long "$node.{NODE}.data" syntax)',
description:
'return resolved value when referencing another property with expression (long "$node.{NODE}.data" syntax)',
input: {
Node1: {
parameters: {
@@ -899,7 +906,8 @@ describe('Workflow', () => {
},
},
{
description: 'return resolved value when referencing another property with expression (short "data" syntax)',
description:
'return resolved value when referencing another property with expression (short "data" syntax)',
input: {
Node1: {
parameters: {
@@ -919,7 +927,8 @@ describe('Workflow', () => {
},
},
{
description: 'return resolved value when referencing another property with expression when a node has spaces (long "$node["{NODE}"].parameter" syntax)',
description:
'return resolved value when referencing another property with expression when a node has spaces (long "$node["{NODE}"].parameter" syntax)',
input: {
Node1: {
parameters: {
@@ -937,7 +946,8 @@ describe('Workflow', () => {
},
},
{
description: 'return resolved value when referencing another property with expression on another node (long "$node["{NODE}"].parameter" syntax)',
description:
'return resolved value when referencing another property with expression on another node (long "$node["{NODE}"].parameter" syntax)',
input: {
Node1: {
parameters: {
@@ -987,75 +997,67 @@ describe('Workflow', () => {
// },
];
const nodeTypes = Helpers.NodeTypes();
for (const testData of tests) {
test(testData.description, () => {
const nodes: INode[] = [
{
"name": "Node1",
"parameters": testData.input.Node1.parameters,
"type": "test.set",
"typeVersion": 1,
"position": [
100,
100,
],
name: 'Node1',
parameters: testData.input.Node1.parameters,
type: 'test.set',
typeVersion: 1,
position: [100, 100],
},
{
"name": "Node2",
"parameters": testData.input.Node2.parameters,
"type": "test.set",
"typeVersion": 1,
"position": [
100,
200,
],
name: 'Node2',
parameters: testData.input.Node2.parameters,
type: 'test.set',
typeVersion: 1,
position: [100, 200],
},
{
"name": "Node3",
name: 'Node3',
// @ts-ignore
"parameters": testData.input.hasOwnProperty('Node3') ? testData.input.Node3.parameters : {},
"type": "test.set",
"typeVersion": 1,
"position": [
100,
300,
],
parameters: testData.input.hasOwnProperty('Node3')
? // @ts-ignore
testData.input.Node3.parameters
: {},
type: 'test.set',
typeVersion: 1,
position: [100, 300],
},
{
"name": "Node 4 with spaces",
name: 'Node 4 with spaces',
// @ts-ignore
"parameters": testData.input.hasOwnProperty('Node4') ? testData.input.Node4.parameters : {},
"type": "test.set",
"typeVersion": 1,
"position": [
100,
400,
],
parameters: testData.input.hasOwnProperty('Node4')
? // @ts-ignore
testData.input.Node4.parameters
: {},
type: 'test.set',
typeVersion: 1,
position: [100, 400],
},
];
const connections: IConnections = {
"Node1": {
"main": [
Node1: {
main: [
[
{
"node": "Node2",
"type": "main",
"index": 0,
node: 'Node2',
type: 'main',
index: 0,
},
],
],
},
"Node2": {
"main": [
Node2: {
main: [
[
{
"node": "Node3",
"type": "main",
"index": 0,
node: 'Node3',
type: 'main',
index: 0,
},
],
],
@@ -1093,19 +1095,29 @@ describe('Workflow', () => {
const itemIndex = 0;
const runIndex = 0;
const connectionInputData: INodeExecutionData[] = runExecutionData.resultData.runData!['Node1']![0]!.data!.main[0]!;
const connectionInputData: INodeExecutionData[] =
runExecutionData.resultData.runData!['Node1']![0]!.data!.main[0]!;
for (const parameterName of Object.keys(testData.output)) {
const parameterValue = nodes.find((node) => node.name === activeNodeName)!.parameters[parameterName];
const result = workflow.expression.getParameterValue(parameterValue, runExecutionData, runIndex, itemIndex, activeNodeName, connectionInputData, 'manual', {});
const parameterValue = nodes.find((node) => node.name === activeNodeName)!.parameters[
parameterName
];
const result = workflow.expression.getParameterValue(
parameterValue,
runExecutionData,
runIndex,
itemIndex,
activeNodeName,
connectionInputData,
'manual',
{},
);
// @ts-ignore
expect(result).toEqual(testData.output[parameterName]);
}
});
}
// test('should be able to set and read key data without initial data set', () => {
// const nodes: Node[] = [
@@ -1175,7 +1187,6 @@ describe('Workflow', () => {
// ]
// };
// const itemIndex = 0;
// const connectionInputData: NodeExecutionData[] = runData!['Node1']![0]!.data!.main[0]!;
@@ -1184,34 +1195,29 @@ describe('Workflow', () => {
// expect(result).toEqual('outputSet1');
// });
test('should also resolve all child parameters when the parent get requested', () => {
const nodeTypes = Helpers.NodeTypes();
const nodes: INode[] = [
{
"name": "Node1",
"parameters": {
"values": {
"string": [
name: 'Node1',
parameters: {
values: {
string: [
{
"name": "name1",
"value": "value1",
name: 'name1',
value: 'value1',
},
{
"name": "name2",
"value": "={{$parameter.values.string[0].value}}A",
name: 'name2',
value: '={{$parameter.values.string[0].value}}A',
},
],
},
},
"type": "test.setMulti",
"typeVersion": 1,
"position": [
100,
100,
],
type: 'test.setMulti',
typeVersion: 1,
position: [100, 100],
},
];
const connections: IConnections = {};
@@ -1243,11 +1249,23 @@ describe('Workflow', () => {
const itemIndex = 0;
const runIndex = 0;
const connectionInputData: INodeExecutionData[] = runExecutionData.resultData.runData!['Node1']![0]!.data!.main[0]!;
const connectionInputData: INodeExecutionData[] =
runExecutionData.resultData.runData!['Node1']![0]!.data!.main[0]!;
const parameterName = 'values';
const parameterValue = nodes.find((node) => node.name === activeNodeName)!.parameters[parameterName];
const result = workflow.expression.getParameterValue(parameterValue, runExecutionData, runIndex, itemIndex, activeNodeName, connectionInputData, 'manual', {});
const parameterValue = nodes.find((node) => node.name === activeNodeName)!.parameters[
parameterName
];
const result = workflow.expression.getParameterValue(
parameterValue,
runExecutionData,
runIndex,
itemIndex,
activeNodeName,
connectionInputData,
'manual',
{},
);
expect(result).toEqual({
string: [
@@ -1261,9 +1279,6 @@ describe('Workflow', () => {
},
],
});
});
});
});