Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update cli and fix linting errors #4

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .eslintrc

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ node_modules
.idea/
.vscode/
.nyc_output
coverage
/coverage
npm-debug.log
dist
.rete-cli
.sonar
12 changes: 12 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tseslint from 'typescript-eslint';
import configs from 'rete-cli/configs/eslint.mjs';

export default tseslint.config(
...configs,
{
files: ['test/**/*.ts'],
rules: {
'@typescript-eslint/no-require-imports': 'off'
}
}
)
4,310 changes: 2,330 additions & 1,980 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"devDependencies": {
"rete": "^2.0.1",
"rete-cli": "^1.0.2",
"rete-cli": "~2.0.1",
"typescript": "4.8.4"
}
}
20 changes: 10 additions & 10 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export type Context<N extends BaseN, C extends BaseC> =
| { getNodes(): N[], getConnections(): C[] }

export type Structures<N extends BaseN, C extends BaseC> =
& Subgraph<N, C>
& Sets<N, C>
& Mapping<N, C>
& Traverse<N, C>
& {
subgraph: Subgraph<N, C>
sets: Sets<N, C>
mapping: Mapping<N, C>
traverse: Traverse<N, C>
}
& Subgraph<N, C>
& Sets<N, C>
& Mapping<N, C>
& Traverse<N, C>
& {
subgraph: Subgraph<N, C>
sets: Sets<N, C>
mapping: Mapping<N, C>
traverse: Traverse<N, C>
}
1 change: 0 additions & 1 deletion test/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const nodeCrypto = require('crypto')

Check warning on line 1 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe assignment of an `any` value

Check warning on line 1 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe assignment of an `any` value

// eslint-disable-next-line no-undef
Object.defineProperty(globalThis, 'crypto', {
value: {
getRandomValues: function (buffer: any) {

Check warning on line 5 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 5 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type
return nodeCrypto.randomFillSync(buffer)

Check warning on line 6 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe return of a value of type `any`

Check warning on line 6 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe call of an `any` typed value

Check warning on line 6 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe member access .randomFillSync on an `any` value

Check warning on line 6 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe return of a value of type `any`

Check warning on line 6 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe call of an `any` typed value

Check warning on line 6 in test/setupTests.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe member access .randomFillSync on an `any` value
}
}
})
33 changes: 24 additions & 9 deletions test/subgraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,53 @@ describe('Subgraph', () => {
const graph = structures(editor)

expect(graph.children().nodes()).toHaveLength(2)
expect(graph.children().nodes().map(n => n.id).sort()).toEqual([a.id, b.id].sort())
expect(graph.children().nodes()
.map(n => n.id)
.sort()).toEqual([a.id, b.id].sort())
})

it('parents', async () => {
const { a, b, editor } = await createCompound()
const graph = structures(editor)

expect(graph.parents(n => n.id === a.id).nodes()).toHaveLength(1)
expect(graph.parents(n => n.id === a.id).nodes().map(n => n.id).sort()).toEqual([b.id].sort())
expect(graph.parents(n => n.id === a.id).nodes()
.map(n => n.id)
.sort()).toEqual([b.id].sort())
})

it('ancestors', async () => {
const { a, b, c, editor } = await createCompound()
const graph = structures(editor)

expect(graph.ancestors().nodes()).toHaveLength(2)
expect(graph.ancestors(n => n.id === a.id).nodes().map(n => n.id)).toEqual([b.id, c.id])
expect(graph.ancestors(n => n.id === b.id).nodes().map(n => n.id)).toEqual([c.id])
expect(graph.ancestors(n => n.id === a.id).nodes()
.map(n => n.id)).toEqual([b.id, c.id])
expect(graph.ancestors(n => n.id === b.id).nodes()
.map(n => n.id)).toEqual([c.id])
})

it('orphans', async () => {
const { c, d, editor } = await createCompound()
const graph = structures(editor)

expect(graph.orphans().nodes()).toHaveLength(2)
expect(graph.orphans().nodes().map(n => n.id).sort()).toEqual([c.id, d.id].sort())
expect(graph.orphans().nodes()
.map(n => n.id)
.sort()).toEqual([c.id, d.id].sort())
})

it('descendants', async () => {
const { a, b, c, d, editor } = await createCompound()
const graph = structures(editor)

expect(graph.descendants(n => n.id === c.id).nodes()).toHaveLength(2)
expect(graph.descendants(n => n.id === c.id).nodes().map(n => n.id).sort()).toEqual([a.id, b.id].sort())
expect(graph.descendants(n => n.id === c.id).nodes()
.map(n => n.id)
.sort()).toEqual([a.id, b.id].sort())
expect(graph.descendants(n => n.id === b.id).nodes()).toHaveLength(1)
expect(graph.descendants(n => n.id === b.id).nodes().map(n => n.id)).toEqual([a.id])
expect(graph.descendants(n => n.id === b.id).nodes()
.map(n => n.id)).toEqual([a.id])
expect(graph.descendants(n => n.id === d.id).nodes()).toHaveLength(0)
})

Expand All @@ -55,7 +66,9 @@ describe('Subgraph', () => {
const graph = structures(editor)

expect(graph.siblings(n => n.id === c.id).nodes()).toHaveLength(2)
expect(graph.siblings(n => n.id === c.id).nodes().map(n => n.id).sort()).toEqual([c.id, d.id].sort())
expect(graph.siblings(n => n.id === c.id).nodes()
.map(n => n.id)
.sort()).toEqual([c.id, d.id].sort())

const e = new Node('a')

Expand All @@ -64,6 +77,8 @@ describe('Subgraph', () => {
await editor.addNode(e)

expect(graph.siblings(n => n.id === e.id).nodes()).toHaveLength(2)
expect(graph.siblings(n => n.id === e.id).nodes().map(n => n.id).sort()).toEqual([b.id, e.id].sort())
expect(graph.siblings(n => n.id === e.id).nodes()
.map(n => n.id)
.sort()).toEqual([b.id, e.id].sort())
})
})
20 changes: 14 additions & 6 deletions test/traverse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,30 @@ describe('Traverse', () => {
const graph = structures(editor)

expect(graph.roots().nodes()).toHaveLength(1)
expect(graph.roots().nodes().map(n => n.id)).toEqual([a.id])
expect(graph.roots().nodes()
.map(n => n.id)).toEqual([a.id])
})

it('leaves', async () => {
const { c, editor } = await createSequentABC()
const graph = structures(editor)

expect(graph.leaves().nodes()).toHaveLength(1)
expect(graph.leaves().nodes().map(n => n.id)).toEqual([c.id])
expect(graph.leaves().nodes()
.map(n => n.id)).toEqual([c.id])
})

it('successors', async () => {
const { a, b, c, editor } = await createSequentABC()
const graph = structures(editor)

expect(graph.successors(a.id).nodes()).toHaveLength(2)
expect(graph.successors(a.id).nodes().map(n => n.id).sort()).toEqual([b.id, c.id].sort())
expect(graph.successors(a.id).nodes()
.map(n => n.id)
.sort()).toEqual([b.id, c.id].sort())
expect(graph.successors(b.id).nodes()).toHaveLength(1)
expect(graph.successors(b.id).nodes().map(n => n.id)).toEqual([c.id])
expect(graph.successors(b.id).nodes()
.map(n => n.id)).toEqual([c.id])
expect(graph.successors(c.id).nodes()).toHaveLength(0)
})

Expand All @@ -54,9 +59,12 @@ describe('Traverse', () => {
const graph = structures(editor)

expect(graph.predecessors(c.id).nodes()).toHaveLength(2)
expect(graph.predecessors(c.id).nodes().map(n => n.id).sort()).toEqual([a.id, b.id].sort())
expect(graph.predecessors(c.id).nodes()
.map(n => n.id)
.sort()).toEqual([a.id, b.id].sort())
expect(graph.predecessors(b.id).nodes()).toHaveLength(1)
expect(graph.predecessors(b.id).nodes().map(n => n.id)).toEqual([a.id])
expect(graph.predecessors(b.id).nodes()
.map(n => n.id)).toEqual([a.id])
expect(graph.predecessors(a.id).nodes()).toHaveLength(0)
})
})
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "rete-cli/configs/tsconfig.json",
"compilerOptions": {
"strict": true,
"esModuleInterop": true
},
"include": [
"src"
"src",
"test"
]
}
Loading