Skip to content

Commit dc1b5bb

Browse files
authored
Merge pull request #22 from Exabyte-io/feat/SOF-6398-2
SOF-6398-2: prettier reformat
2 parents fa83d7e + 9115b2d commit dc1b5bb

14 files changed

+297
-228
lines changed

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": false,
3+
"printWidth": 100,
4+
"trailingComma": "all",
5+
"tabWidth": 4
6+
}
7+

package-lock.json

+34-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"description": "WOrkflow DEfinitions",
55
"scripts": {
66
"test": "nyc --reporter=text mocha --recursive --bail --require @babel/register/lib --require tests/setup.js tests",
7-
"lint": "eslint src tests",
8-
"lint:fix": "eslint --fix --cache src tests",
7+
"lint": "eslint src tests && prettier --write src tests",
8+
"lint:fix": "eslint --fix --cache src tests && prettier --write src tests",
99
"transpile": "babel --out-dir dist src; node build_workflows.js",
1010
"postinstall": "npm run transpile",
11+
"prettier": "prettier --check src tests",
1112
"prepare": "husky install || exit 0"
1213
},
1314
"repository": {
@@ -37,7 +38,6 @@
3738
"@babel/preset-react": "7.16.7",
3839
"@babel/register": "^7.16.0",
3940
"@babel/runtime-corejs3": "7.16.8",
40-
"@exabyte-io/eslint-config": "^2022.11.16-0",
4141
"js-yaml": "^4.1.0",
4242
"lodash": "^4.17.21",
4343
"mixwith": "^0.1.1",
@@ -47,16 +47,19 @@
4747
"devDependencies": {
4848
"@exabyte-io/ade.js": "2022.11.16-0",
4949
"@exabyte-io/code.js": "2022.11.11-0",
50+
"@exabyte-io/eslint-config": "^2022.11.17-0",
5051
"@exabyte-io/ide.js": "2022.7.28-1",
5152
"@exabyte-io/made.js": "2022.6.15-0",
5253
"@exabyte-io/mode.js": "2022.10.11-0",
5354
"chai": "^4.3.4",
5455
"eslint": "7.32.0",
5556
"eslint-config-airbnb": "19.0.2",
57+
"eslint-config-prettier": "^8.5.0",
5658
"eslint-import-resolver-exports": "^1.0.0-beta.2",
5759
"eslint-plugin-import": "2.25.3",
5860
"eslint-plugin-jsdoc": "37.1.0",
5961
"eslint-plugin-jsx-a11y": "6.5.1",
62+
"eslint-plugin-prettier": "^4.2.1",
6063
"eslint-plugin-react": "7.30.0",
6164
"eslint-plugin-simple-import-sort": "7.0.0",
6265
"husky": "^7.0.4",
@@ -75,6 +78,7 @@
7578
"node": ">=12.0.0"
7679
},
7780
"lint-staged": {
78-
"*.js": "eslint --cache --fix"
81+
"*.js": "eslint --cache --fix",
82+
"*.{js,css}": "prettier --write"
7983
}
8084
}

src/subworkflows/convergence.js

+109-106
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,125 @@
11
import { UNIT_TYPES } from "../enums";
22

3-
export const ConvergenceMixin = (superclass) => class extends superclass {
4-
addConvergence({
5-
parameter,
6-
parameterInitial,
7-
result,
8-
resultInitial,
9-
condition,
10-
operator,
11-
tolerance,
12-
maxOccurrences,
13-
}) {
14-
// RF: added TODO comments for future improvements
3+
export const ConvergenceMixin = (superclass) =>
4+
class extends superclass {
5+
addConvergence({
6+
parameter,
7+
parameterInitial,
8+
result,
9+
resultInitial,
10+
condition,
11+
operator,
12+
tolerance,
13+
maxOccurrences,
14+
}) {
15+
// RF: added TODO comments for future improvements
1516

16-
const { units } = this;
17-
// Find unit to converge: should contain passed result in its results list
18-
// TODO: make user to select unit for convergence explicitly
19-
const unitForConvergence = units.find((x) => x.resultNames.find((name) => name === result));
17+
const { units } = this;
18+
// Find unit to converge: should contain passed result in its results list
19+
// TODO: make user to select unit for convergence explicitly
20+
const unitForConvergence = units.find((x) =>
21+
x.resultNames.find((name) => name === result),
22+
);
2023

21-
if (!unitForConvergence) {
22-
// eslint-disable-next-line no-undef
23-
sAlert.error(
24+
if (!unitForConvergence) {
25+
// eslint-disable-next-line no-undef
26+
sAlert.error(
2427
`Subworkflow does not contain unit with '${result}' as extracted property.`,
25-
);
26-
throw new Error("There is no result to converge");
27-
}
28+
);
29+
throw new Error("There is no result to converge");
30+
}
2831

29-
// Replace kgrid to be ready for convergence
30-
// TODO: kgrid should be abstracted and selected by user
31-
unitForConvergence.updateContext({
32-
kgrid: {
33-
dimensions: [`{{${parameter}}}`, `{{${parameter}}}`, `{{${parameter}}}`],
34-
shifts: [0, 0, 0],
35-
},
36-
isKgridEdited: true,
37-
isUsingJinjaVariables: true,
38-
});
32+
// Replace kgrid to be ready for convergence
33+
// TODO: kgrid should be abstracted and selected by user
34+
unitForConvergence.updateContext({
35+
kgrid: {
36+
dimensions: [`{{${parameter}}}`, `{{${parameter}}}`, `{{${parameter}}}`],
37+
shifts: [0, 0, 0],
38+
},
39+
isKgridEdited: true,
40+
isUsingJinjaVariables: true,
41+
});
3942

40-
const prevResult = "prev_result";
43+
const prevResult = "prev_result";
4144

42-
// Assignment with result's initial value
43-
const prevResultInit = this._UnitFactory.create({
44-
type: UNIT_TYPES.assignment,
45-
head: true,
46-
operand: prevResult,
47-
value: resultInitial,
48-
});
45+
// Assignment with result's initial value
46+
const prevResultInit = this._UnitFactory.create({
47+
type: UNIT_TYPES.assignment,
48+
head: true,
49+
operand: prevResult,
50+
value: resultInitial,
51+
});
4952

50-
// Assignment with initial value of convergence parameter
51-
const paramInit = this._UnitFactory.create({
52-
type: UNIT_TYPES.assignment,
53-
operand: parameter,
54-
value: parameterInitial,
55-
});
53+
// Assignment with initial value of convergence parameter
54+
const paramInit = this._UnitFactory.create({
55+
type: UNIT_TYPES.assignment,
56+
operand: parameter,
57+
value: parameterInitial,
58+
});
5659

57-
// Assignment for storing iteration result: extracts 'result' from convergence unit scope
58-
const storePrevResult = this._UnitFactory.create({
59-
type: UNIT_TYPES.assignment,
60-
input: [
61-
{
62-
scope: unitForConvergence.flowchartId,
63-
name: result,
64-
},
65-
],
66-
operand: prevResult,
67-
value: result,
68-
});
60+
// Assignment for storing iteration result: extracts 'result' from convergence unit scope
61+
const storePrevResult = this._UnitFactory.create({
62+
type: UNIT_TYPES.assignment,
63+
input: [
64+
{
65+
scope: unitForConvergence.flowchartId,
66+
name: result,
67+
},
68+
],
69+
operand: prevResult,
70+
value: result,
71+
});
6972

70-
// Assignment for convergence param increase
71-
const nextStep = this._UnitFactory.create({
72-
type: UNIT_TYPES.assignment,
73-
input: [],
74-
operand: parameter,
75-
value: `${parameter} + 1`,
76-
next: unitForConvergence.flowchartId,
77-
});
73+
// Assignment for convergence param increase
74+
const nextStep = this._UnitFactory.create({
75+
type: UNIT_TYPES.assignment,
76+
input: [],
77+
operand: parameter,
78+
value: `${parameter} + 1`,
79+
next: unitForConvergence.flowchartId,
80+
});
7881

79-
// Final step of convergence
80-
const exit = this._UnitFactory.create({
81-
type: UNIT_TYPES.assignment,
82-
name: "exit",
83-
input: [],
84-
operand: parameter,
85-
value: `${parameter} + 0`,
86-
});
82+
// Final step of convergence
83+
const exit = this._UnitFactory.create({
84+
type: UNIT_TYPES.assignment,
85+
name: "exit",
86+
input: [],
87+
operand: parameter,
88+
value: `${parameter} + 0`,
89+
});
8790

88-
// Final step of convergence
89-
const storeResult = this._UnitFactory.create({
90-
type: UNIT_TYPES.assignment,
91-
input: [
92-
{
93-
scope: unitForConvergence.flowchartId,
94-
name: result,
95-
},
96-
],
97-
operand: result,
98-
value: result,
99-
});
91+
// Final step of convergence
92+
const storeResult = this._UnitFactory.create({
93+
type: UNIT_TYPES.assignment,
94+
input: [
95+
{
96+
scope: unitForConvergence.flowchartId,
97+
name: result,
98+
},
99+
],
100+
operand: result,
101+
value: result,
102+
});
100103

101-
// Convergence condition unit
102-
const conditionUnit = this._UnitFactory.create({
103-
type: UNIT_TYPES.condition,
104-
statement: `${condition} ${operator} ${tolerance}`,
105-
then: exit.flowchartId,
106-
else: storePrevResult.flowchartId,
107-
maxOccurrences,
108-
next: storePrevResult.flowchartId,
109-
});
104+
// Convergence condition unit
105+
const conditionUnit = this._UnitFactory.create({
106+
type: UNIT_TYPES.condition,
107+
statement: `${condition} ${operator} ${tolerance}`,
108+
then: exit.flowchartId,
109+
else: storePrevResult.flowchartId,
110+
maxOccurrences,
111+
next: storePrevResult.flowchartId,
112+
});
110113

111-
this.addUnit(prevResultInit, true);
112-
this.addUnit(paramInit, true);
113-
this.addUnit(storeResult);
114-
this.addUnit(conditionUnit);
115-
this.addUnit(storePrevResult);
116-
this.addUnit(nextStep);
117-
this.addUnit(exit);
114+
this.addUnit(prevResultInit, true);
115+
this.addUnit(paramInit, true);
116+
this.addUnit(storeResult);
117+
this.addUnit(conditionUnit);
118+
this.addUnit(storePrevResult);
119+
this.addUnit(nextStep);
120+
this.addUnit(exit);
118121

119-
// `addUnit` adjusts the `next` field, hence the below.
120-
nextStep.next = unitForConvergence.flowchartId;
121-
}
122-
};
122+
// `addUnit` adjusts the `next` field, hence the below.
123+
nextStep.next = unitForConvergence.flowchartId;
124+
}
125+
};

0 commit comments

Comments
 (0)