Skip to content

Commit e46f03f

Browse files
committed
Lint
1 parent 754527d commit e46f03f

14 files changed

+132
-84
lines changed

eslint.config.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ export default [
3131
},
3232

3333
parser: tsParser,
34-
ecmaVersion: 5,
34+
ecmaVersion: 2020,
3535
sourceType: 'module',
3636

3737
parserOptions: {
38-
project: 'tsconfig.json',
39-
tsconfigRootDir: '/home/arnold/Projects/letsflow/core',
38+
project: 'tsconfig.json'
4039
},
4140
},
4241

@@ -45,7 +44,10 @@ export default [
4544
'@typescript-eslint/explicit-function-return-type': 'off',
4645
'@typescript-eslint/explicit-module-boundary-types': 'off',
4746
'@typescript-eslint/no-explicit-any': 'off',
48-
'unused-imports/no-unused-vars': ['warn', { vars: 'all', args: 'after-used', argsIgnorePattern: '^_' }],
47+
'@typescript-eslint/no-unused-vars': [
48+
'warn',
49+
{ vars: 'all', args: 'after-used', argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
50+
],
4951
},
5052
},
5153
];

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
"@types/chai": "^4.3.16",
2222
"@types/get-value": "^3.0.5",
2323
"@types/node": "^22.10.5",
24+
"@typescript-eslint/eslint-plugin": "^8.31.1",
25+
"@typescript-eslint/parser": "^8.31.1",
2426
"eslint": "^9.18.0",
25-
"eslint-config-prettier": "^9.1.0",
26-
"eslint-plugin-prettier": "^5.2.1",
27+
"eslint-config-prettier": "^10.1.2",
28+
"eslint-plugin-prettier": "^5.2.6",
29+
"eslint-plugin-unused-imports": "^4.1.4",
2730
"prettier": "^3.4.2",
2831
"ts-loader": "^9.5.2",
2932
"typescript": "^5.7.3"
@@ -36,7 +39,7 @@
3639
"clean": "rm -rf ./lib",
3740
"build": "tsc --project tsconfig.build.json",
3841
"test": "cucumber-js",
39-
"lint": "eslint \"{src,test}/**/*.ts\" --fix"
42+
"lint": "eslint \"src/**/*.ts\" --fix"
4043
},
4144
"packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
4245
}

src/ajv.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ function getSchemaFile(id: string): string {
1414
return join(SCHEMA_DIR, key);
1515
}
1616

17-
const paths = [
18-
join(SCHEMA_DIR, `${key}.yaml`),
19-
join(SCHEMA_DIR, `${key}.yml`),
20-
join(SCHEMA_DIR, `${key}.json`),
21-
];
17+
const paths = [join(SCHEMA_DIR, `${key}.yaml`), join(SCHEMA_DIR, `${key}.yml`), join(SCHEMA_DIR, `${key}.json`)];
2218

2319
const path = paths.find((path) => existsSync(path));
2420
if (!path) throw new Error(`Neither ${key}.yaml nor ${key}.json found in ${SCHEMA_DIR}`);
@@ -66,4 +62,4 @@ async function loadRemoveSchema(uri: string) {
6662

6763
ajv.opts.loadSchema = async (uri) => {
6864
return uri.startsWith('schema:') ? loadLocalSchema(uri) : loadRemoveSchema(uri);
69-
}
65+
};

src/assert-actor.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Then } from "@cucumber/cucumber";
2-
import { expect } from "chai";
1+
import { Then } from '@cucumber/cucumber';
2+
import { expect } from 'chai';
33
import getValue from 'get-value';
4-
import { world } from "./world"
5-
import { parseData } from "./utils"
4+
import { world } from './world';
5+
import { parseData } from './utils';
66
import { applyFn } from '@letsflow/core/process';
77

88
function assertActorExists(processName: string, actorKey: string) {
@@ -27,6 +27,12 @@ function assertActorProp(actorKey: string, processName: string, propName: string
2727
expect(actualValue).to.eq(value, `Actor '${actorKey}' does not have the expected value for '${propName}'`);
2828
}
2929
Then('actor {string} in the {string} process has {string} is {scalar}', assertActorProp);
30-
Then('actor {string} has {string} is {scalar}', (actorKey, propName, propValue) => assertActorProp(actorKey, 'main', propName, propValue));
31-
Then('actor {string} in the {string} process has {string} is:', (actorKey, process, propName, expected) => assertActorProp(actorKey, process, propName, parseData(expected)));
32-
Then('actor {string} has {string} is:', (actorKey, propName, expected) => assertActorProp(actorKey, 'main', propName, parseData(expected)));
30+
Then('actor {string} has {string} is {scalar}', (actorKey, propName, propValue) =>
31+
assertActorProp(actorKey, 'main', propName, propValue),
32+
);
33+
Then('actor {string} in the {string} process has {string} is:', (actorKey, process, propName, expected) =>
34+
assertActorProp(actorKey, process, propName, parseData(expected)),
35+
);
36+
Then('actor {string} has {string} is:', (actorKey, propName, expected) =>
37+
assertActorProp(actorKey, 'main', propName, parseData(expected)),
38+
);

src/assert-current.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import getValue from 'get-value';
77

88
function assertStateVar(property: string, processName: string, expectedRaw: any) {
99
const process = world.getProcess(processName);
10-
const expected = typeof expectedRaw === 'string'
11-
? (applyFn({ '<tpl>': expectedRaw }, process) as string).trim()
12-
: applyFn(expectedRaw, process);
10+
const expected =
11+
typeof expectedRaw === 'string'
12+
? (applyFn({ '<tpl>': expectedRaw }, process) as string).trim()
13+
: applyFn(expectedRaw, process);
1314

1415
let actualValue = getValue(process.current, property);
1516
if (typeof actualValue === 'string') actualValue = actualValue.trim();
@@ -18,7 +19,9 @@ function assertStateVar(property: string, processName: string, expectedRaw: any)
1819
}
1920
Then('the state {property} of the {string} process has {string} is/are {string}', assertStateVar);
2021
Then('the state {property} is/are {string}', (property, expected) => assertStateVar(property, 'main', expected));
21-
Then('the state {property} of the {string} process is:/are:', (property, process, expected) => assertStateVar(property, process, parseData(expected)));
22+
Then('the state {property} of the {string} process is:/are:', (property, process, expected) =>
23+
assertStateVar(property, process, parseData(expected)),
24+
);
2225
Then('the state {property} is:/are:', (property, expected) => assertStateVar(property, 'main', parseData(expected)));
2326

2427
function assertInstructions(actorKey: string, processName: string, expectedRaw: string) {
@@ -33,6 +36,10 @@ function assertInstructions(actorKey: string, processName: string, expectedRaw:
3336
expect(instructions.trim()).to.eq(expected.trim(), `Actor '${actorKey}' does not have the expected instructions`);
3437
}
3538
Then('actor {string} in the {string} process has (the )instruction(s) {string}', assertInstructions);
36-
Then('actor {string} has (the )instruction(s) {string}', (actorKey, expected) => assertInstructions(actorKey, 'main', expected));
39+
Then('actor {string} has (the )instruction(s) {string}', (actorKey, expected) =>
40+
assertInstructions(actorKey, 'main', expected),
41+
);
3742
Then('actor {string} in the {string} process has (the )instruction(s):', assertInstructions);
38-
Then('actor {string} has (the )instruction(s):', (actorKey, expected) => assertInstructions(actorKey, 'main', expected));
43+
Then('actor {string} has (the )instruction(s):', (actorKey, expected) =>
44+
assertInstructions(actorKey, 'main', expected),
45+
);

src/assert-event.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { ActionEvent, applyFn } from '@letsflow/core/process';
2-
import { expect } from "chai"
3-
import { Then } from "@cucumber/cucumber"
4-
import { world } from "./world"
5-
import { parseData } from "./utils"
2+
import { expect } from 'chai';
3+
import { Then } from '@cucumber/cucumber';
4+
import { world } from './world';
5+
import { parseData } from './utils';
66

77
function lastEventSkipped(processName: string, expectedRaw?: string[]) {
88
const process = world.getProcess(processName);
99
const event = process.events[process.events.length - 1];
1010

11-
1211
if (!('skipped' in event) || !event.skipped) {
1312
expect.fail('The last event is not skipped');
1413
}
@@ -18,8 +17,12 @@ function lastEventSkipped(processName: string, expectedRaw?: string[]) {
1817
expect((event as ActionEvent).errors).to.include.members(expected);
1918
}
2019
}
21-
Then('the last event of the {string} process is skipped with {string}', (process, error) => lastEventSkipped(process, [error]));
22-
Then('the last event of the {string} process is skipped with:', (process, errors) => lastEventSkipped(process, parseData(errors)));
20+
Then('the last event of the {string} process is skipped with {string}', (process, error) =>
21+
lastEventSkipped(process, [error]),
22+
);
23+
Then('the last event of the {string} process is skipped with:', (process, errors) =>
24+
lastEventSkipped(process, parseData(errors)),
25+
);
2326
Then('the last event of the {string} process is skipped', (process) => lastEventSkipped(process));
2427
Then('the last event is skipped with {string}', (error) => lastEventSkipped('main', [error]));
2528
Then('the last event is skipped with:', (errors) => lastEventSkipped('main', parseData(errors)));
@@ -50,10 +53,9 @@ function assertEventIsTimeout(processName: string) {
5053
const process = world.getProcess(processName);
5154
const event = process.events[process.events.length - 1];
5255

53-
if (('scenario' in event) || ('action' in event)) {
56+
if ('scenario' in event || 'action' in event) {
5457
expect.fail(
55-
'The last event is not a timeout event, but ' +
56-
(('scenario' in event) ? 'a scenario event' : 'an action event')
58+
'The last event is not a timeout event, but ' + ('scenario' in event ? 'a scenario event' : 'an action event'),
5759
);
5860
}
5961
}

src/assert-service.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { DataTable, Then } from "@cucumber/cucumber";
2-
import { expect } from "chai";
3-
import { world } from "./world"
4-
import { parseData } from "./utils"
1+
import { DataTable, Then } from '@cucumber/cucumber';
2+
import { expect } from 'chai';
3+
import { world } from './world';
4+
import { parseData } from './utils';
55

66
function assertServiceNotified(service: string, processName: string, expectedRaw?: string | DataTable) {
77
const process = world.getProcess(processName);
@@ -15,7 +15,9 @@ function assertServiceNotified(service: string, processName: string, expectedRaw
1515
expect(notify.message).to.deep.eq(expectedResult, `Service '${service}' was not notified with the expected message`);
1616
}
1717
Then('service {string} in the {string} process is notified with:', assertServiceNotified);
18-
Then('service {string} in the {string} process is notified', (service, process) => assertServiceNotified(service, process));
18+
Then('service {string} in the {string} process is notified', (service, process) =>
19+
assertServiceNotified(service, process),
20+
);
1921
Then('service {string} is notified with:', (service, expected) => assertServiceNotified(service, 'main', expected));
2022
Then('service {string} is notified', (service) => assertServiceNotified(service, 'main'));
2123

src/assert-state.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DataTable, Then } from '@cucumber/cucumber';
2-
import { expect } from "chai";
3-
import { world } from "./world"
4-
import { parseData } from "./utils"
2+
import { expect } from 'chai';
3+
import { world } from './world';
4+
import { parseData } from './utils';
55

66
function assertState(processName: string, state: string) {
77
const process = world.getProcess(processName);
@@ -35,9 +35,13 @@ function assertProcessEnded(processName: string, status?: string, expectedResult
3535
}
3636
Then('the {string} process ended in {string} with:', assertProcessEnded);
3737
Then('the {string} process ended in {string}', (process, status) => assertProcessEnded(process, status));
38-
Then('the {string} process ended with:', (process, expectedResult) => assertProcessEnded(process, undefined, expectedResult));
38+
Then('the {string} process ended with:', (process, expectedResult) =>
39+
assertProcessEnded(process, undefined, expectedResult),
40+
);
3941
Then('the {string} process ended', (process) => assertProcessEnded(process));
40-
Then('the process ended in {string} with:', (status, expectedResult) => assertProcessEnded('main', status, expectedResult));
42+
Then('the process ended in {string} with:', (status, expectedResult) =>
43+
assertProcessEnded('main', status, expectedResult),
44+
);
4145
Then('the process ended in {string}', (status) => assertProcessEnded('main', status));
4246
Then('the process ended with:', (expectedResult) => assertProcessEnded('main', undefined, expectedResult));
4347
Then('the process ended', () => assertProcessEnded('main'));

src/assert-vars.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Then } from "@cucumber/cucumber";
2-
import { expect } from "chai";
1+
import { Then } from '@cucumber/cucumber';
2+
import { expect } from 'chai';
33
import getValue from 'get-value';
4-
import { world } from "./world"
5-
import { parseData } from "./utils"
4+
import { world } from './world';
5+
import { parseData } from './utils';
66
import { applyFn } from '@letsflow/core/process';
77

88
function assertVar(variable: string, processName: string, valueRaw: any) {
@@ -14,7 +14,9 @@ function assertVar(variable: string, processName: string, valueRaw: any) {
1414
}
1515
Then('variable {string} in the {string} process is {scalar}', assertVar);
1616
Then('variable {string} is {scalar}', (variable, value) => assertVar(variable, 'main', value));
17-
Then('variable {string} in the {string} process is:', (variable, process, expected) => assertVar(variable, process, parseData(expected)));
17+
Then('variable {string} in the {string} process is:', (variable, process, expected) =>
18+
assertVar(variable, process, parseData(expected)),
19+
);
1820
Then('variable {string} is:', (variable, expected) => assertVar(variable, 'main', parseData(expected)));
1921

2022
function assertResult(processName: string, valueRaw: any) {
@@ -41,5 +43,5 @@ function assertNotTag(processName: string, tag: string) {
4143

4244
expect(process.tags).to.not.include(tag, `The process does have the tag "${tag}"`);
4345
}
44-
Then('the {string} process doesn\'t have (the )tag {string}', assertNotTag);
45-
Then('the process doesn\'t have (the )tag {string}', (tag) => assertNotTag('main', tag));
46+
Then("the {string} process doesn't have (the )tag {string}", assertNotTag);
47+
Then("the process doesn't have (the )tag {string}", (tag) => assertNotTag('main', tag));

src/create-process.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
import { DataTable, Given } from '@cucumber/cucumber';
2-
import { world } from "./world"
3-
import { yaml } from "@letsflow/core"
2+
import { world } from './world';
3+
import { yaml } from '@letsflow/core';
44

55
async function addProcess(name: string, scenario: string) {
66
await world.addProcess(name, scenario);
77
}
88
Given('the {string} process is created from the {string} scenario', (name, scenario) => addProcess(name, scenario));
99
Given('the process is created from the {string} scenario', (scenario) => addProcess('main', scenario));
1010

11-
function addActor(name: string, actor = "actor", process = "main", propsTable?: string | DataTable) {
11+
function addActor(name: string, actor = 'actor', process = 'main', propsTable?: string | DataTable) {
1212
const props = typeof propsTable === 'string' ? yaml.parse(propsTable) : propsTable?.rowsHash();
1313
world.addActor(process, name, actor, props);
1414
}
1515
Given('{string} is the {string} actor in the {string} process with:', addActor);
16-
Given('{string} is the actor in the {string} process', (name, process) => addActor(name, "actor", process));
17-
Given('{string} is the actor in the {string} process with:', (name, process, propsTable) => addActor(name, process, "actor", propsTable));
18-
Given('{string} is the {string} actor in the {string} process', (name, actor, process) => addActor(name, actor, process));
19-
Given('{string} is the actor', (name) => addActor(name, "actor", "main"));
20-
Given('{string} is the {string} actor', (name, actor) => addActor(name, actor, "main"));
21-
Given('{string} is the actor with:', (name: string, propsTable: string | DataTable) => addActor(name, "main", "actor", propsTable));
22-
Given('{string} is the {string} actor with:', (name: string, actor: string, propsTable: string | DataTable) => addActor(name, actor, "main", propsTable));
16+
Given('{string} is the actor in the {string} process', (name, process) => addActor(name, 'actor', process));
17+
Given('{string} is the actor in the {string} process with:', (name, process, propsTable) =>
18+
addActor(name, process, 'actor', propsTable),
19+
);
20+
Given('{string} is the {string} actor in the {string} process', (name, actor, process) =>
21+
addActor(name, actor, process),
22+
);
23+
Given('{string} is the actor', (name) => addActor(name, 'actor', 'main'));
24+
Given('{string} is the {string} actor', (name, actor) => addActor(name, actor, 'main'));
25+
Given('{string} is the actor with:', (name: string, propsTable: string | DataTable) =>
26+
addActor(name, 'main', 'actor', propsTable),
27+
);
28+
Given('{string} is the {string} actor with:', (name: string, actor: string, propsTable: string | DataTable) =>
29+
addActor(name, actor, 'main', propsTable),
30+
);

0 commit comments

Comments
 (0)