Skip to content

Commit c917513

Browse files
Merge pull request #976 from devoxa/renovate/devoxa-eslint-config-4.x
chore(deps): update dependency @devoxa/eslint-config from 3.0.11 to 4.0.0
2 parents 3bf24e2 + 85f5609 commit c917513

File tree

6 files changed

+1039
-591
lines changed

6 files changed

+1039
-591
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"editor.defaultFormatter": "esbenp.prettier-vscode",
3-
"editor.codeActionsOnSave": { "source.organizeImports": true },
3+
"editor.codeActionsOnSave": {
4+
"source.organizeImports": "explicit"
5+
},
46
"[typescript]": { "editor.formatOnSave": true },
57
"[json]": { "editor.formatOnSave": true },
68
"[prisma]": { "editor.formatOnSave": true, "editor.defaultFormatter": "Prisma.prisma" },

eslint.config.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const config = require('@devoxa/eslint-config')
2+
3+
module.exports = config({
4+
ignoreFiles: ['.gitignore'],
5+
})

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
"test": "jest",
1313
"format": "prettier --ignore-path='.gitignore' --list-different --write .",
1414
"format:check": "prettier --ignore-path='.gitignore' --check .",
15-
"lint": "eslint --ignore-path='.gitignore' '{src,tests}/**/*.ts'",
15+
"lint": "eslint '{src,tests}/**/*.ts'",
1616
"build": "rm -rf dist/ && tsc",
1717
"preversion": "yarn build"
1818
},
19-
"eslintConfig": {
20-
"extends": "@devoxa"
21-
},
2219
"prettier": "@devoxa/prettier-config",
2320
"dependencies": {
2421
"graphql-fields": "2.0.3"
@@ -27,15 +24,15 @@
2724
"@prisma/client": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
2825
},
2926
"devDependencies": {
30-
"@devoxa/eslint-config": "3.0.11",
27+
"@devoxa/eslint-config": "4.0.0",
3128
"@devoxa/prettier-config": "2.0.3",
3229
"@prisma/client": "6.0.1",
3330
"@swc/core": "1.10.0",
3431
"@swc/jest": "0.2.37",
3532
"@types/graphql-fields": "1.3.9",
3633
"@types/jest": "29.5.14",
3734
"@types/node": "20.9.5",
38-
"eslint": "8.57.1",
35+
"eslint": "9.16.0",
3936
"jest": "29.7.0",
4037
"prettier": "3.4.2",
4138
"prisma": "6.0.1",

src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ export async function findManyCursorConnection<
2727
}
2828

2929
const options = mergeDefaultOptions(pOptions)
30-
const requestedFields = options.resolveInfo && Object.keys(graphqlFields(options.resolveInfo))
31-
const hasRequestedField = (key: string) => !requestedFields || requestedFields.includes(key)
30+
31+
let requestedFields: Array<string> | undefined = undefined
32+
if (options.resolveInfo) {
33+
const _graphqlFields = graphqlFields(options.resolveInfo) as { [key: string]: unknown }
34+
requestedFields = Object.keys(_graphqlFields)
35+
}
36+
const hasRequestedField = (key: string): boolean =>
37+
!requestedFields || requestedFields.includes(key)
3238

3339
let records: Array<Record>
3440
let totalCount: number

tests/index.spec.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { mocked } from 'jest-mock'
55
import { ConnectionArguments, findManyCursorConnection } from '../src'
66
import { PROFILE_FIXTURES, TODO_FIXTURES, USER_FIXTURES } from './fixtures'
77

8-
function encodeCursor<Cursor>(prismaCursor: Cursor) {
8+
function encodeCursor<Cursor>(prismaCursor: Cursor): string {
99
return Buffer.from(JSON.stringify(prismaCursor)).toString('base64')
1010
}
1111

12-
function decodeCursor(cursor: string) {
12+
function decodeCursor<Cursor>(cursor: string): Cursor {
1313
return JSON.parse(Buffer.from(cursor, 'base64').toString('ascii'))
1414
}
1515

@@ -21,7 +21,7 @@ describe('prisma-relay-cursor-connection', () => {
2121
jest.setTimeout(10000)
2222
let client: PrismaClient
2323

24-
beforeAll(async () => {
24+
beforeAll(() => {
2525
client = new PrismaClient()
2626
})
2727

@@ -89,22 +89,22 @@ describe('prisma-relay-cursor-connection', () => {
8989
expect(result).toMatchSnapshot()
9090

9191
// Test that the return types work via TS
92-
result.edges[0].node.isCompleted
92+
expect(result.edges[0].node.isCompleted)
9393

9494
// @ts-expect-error Typo in selected field
95-
result.edges[0].node.isCompletedd
95+
expect(result.edges[0].node.isCompletedd)
9696

9797
// @ts-expect-error Not selected field
98-
result.edges[0].node.text
98+
expect(result.edges[0].node.text)
9999

100100
// Test that the return types work via TS
101-
result.nodes[0].isCompleted
101+
expect(result.nodes[0].isCompleted)
102102

103103
// @ts-expect-error Typo in selected field
104-
result.nodes[0].isCompletedd
104+
expect(result.nodes[0].isCompletedd)
105105

106106
// @ts-expect-error Not selected field
107-
result.nodes[0].text
107+
expect(result.nodes[0].text)
108108
})
109109
})
110110

@@ -200,22 +200,22 @@ describe('prisma-relay-cursor-connection', () => {
200200
expect(result).toMatchSnapshot()
201201

202202
// Test that the return types work via TS
203-
result.edges[0].node.email
203+
expect(result.edges[0].node.email)
204204

205205
// @ts-expect-error Typo in selected field
206-
result.edges[0].node.emmail
206+
expect(result.edges[0].node.emmail)
207207

208208
// @ts-expect-error Not selected field
209-
result.edges[0].node.text
209+
expect(result.edges[0].node.text)
210210

211211
// Test that the return types work via TS
212-
result.nodes[0].email
212+
expect(result.nodes[0].email)
213213

214214
// @ts-expect-error Typo in selected field
215-
result.nodes[0].emmail
215+
expect(result.nodes[0].emmail)
216216

217217
// @ts-expect-error Not selected field
218-
result.nodes[0].text
218+
expect(result.nodes[0].text)
219219
})
220220
})
221221

@@ -469,13 +469,13 @@ describe('prisma-relay-cursor-connection', () => {
469469
expect(result).toMatchSnapshot()
470470

471471
// Test that the node.extraNodeField return types work via TS
472-
result.edges[0]?.node.extraNodeField
472+
expect(result.edges[0]?.node.extraNodeField)
473473

474474
// Test that the extraEdgeField return type work via TS
475-
result.edges[0]?.extraEdgeField
475+
expect(result.edges[0]?.extraEdgeField)
476476

477477
// Test that the node.extraNodeField return types work via TS
478-
result.nodes[0]?.extraNodeField
478+
expect(result.nodes[0]?.extraNodeField)
479479
})
480480
})
481481

@@ -564,8 +564,7 @@ describe('prisma-relay-cursor-connection', () => {
564564
})
565565

566566
// These are not real tests which run, but rather a way to ensure that the types are correct
567-
// when tsc runs
568-
const typecheckForInferredTypes = async () => {
567+
export const typecheckForInferredTypes = async (): Promise<void> => {
569568
const client = new PrismaClient()
570569

571570
// Default will get the inferred types from prisma
@@ -610,5 +609,3 @@ const typecheckForInferredTypes = async () => {
610609
}[]
611610
}
612611
}
613-
614-
typecheckForInferredTypes

0 commit comments

Comments
 (0)