diff --git a/design-system/packages/core/src/components/Link.tsx b/design-system/packages/core/src/components/Link.tsx
index df3321ffb89..d23cc6b032c 100644
--- a/design-system/packages/core/src/components/Link.tsx
+++ b/design-system/packages/core/src/components/Link.tsx
@@ -5,7 +5,7 @@ import { jsx } from '../emotion'
import { useTheme } from '../theme'
import { forwardRefWithAs } from '../utils'
-export const Link = forwardRefWithAs<'a', {}>(({ as: Tag = 'a', ...props }, ref) => {
+export const Link = forwardRefWithAs<'a', unknown>(({ as: Tag = 'a', ...props }, ref) => {
const { typography, colors } = useTheme()
const styles = {
diff --git a/design-system/packages/fields/src/FieldContainer.tsx b/design-system/packages/fields/src/FieldContainer.tsx
index a14e34b4061..6bef2fcf039 100644
--- a/design-system/packages/fields/src/FieldContainer.tsx
+++ b/design-system/packages/fields/src/FieldContainer.tsx
@@ -2,6 +2,6 @@
/** @jsx jsx */
import { jsx, forwardRefWithAs } from '@keystone-ui/core'
-export const FieldContainer = forwardRefWithAs<'div', {}>(({ as: Tag = 'div', ...props }, ref) => {
+export const FieldContainer = forwardRefWithAs<'div', unknown>(({ as: Tag = 'div', ...props }, ref) => {
return
})
diff --git a/eslint.config.js b/eslint.config.mjs
similarity index 85%
rename from eslint.config.js
rename to eslint.config.mjs
index 0f4f6d17b92..9a8b9950840 100644
--- a/eslint.config.js
+++ b/eslint.config.mjs
@@ -1,23 +1,28 @@
// @ts-check
-const eslint = require('@eslint/js')
-const tseslint = require('typescript-eslint')
+import eslint from '@eslint/js'
+import tseslint from 'typescript-eslint'
+import stylisticTs from '@stylistic/eslint-plugin-ts'
-module.exports = tseslint.config(
+export default tseslint.config(
{
ignores: [
'**/.keystone/',
+ '**/.next/',
'**/dist/',
+ '**/__generated__/',
'**/node_modules/',
'**/syntax-error.js',
'**/public/',
- 'examples/extend-graphql-schema-nexus/nexus-types.ts'
+ 'examples/',
],
},
eslint.configs.recommended,
...tseslint.configs.strict,
-// ...tseslint.configs.stylistic,
{
+ plugins: {
+ '@stylistic/ts': stylisticTs,
+ },
rules: {
// TODO: remove
'no-empty': 'off',
@@ -50,7 +55,7 @@ module.exports = tseslint.config(
'space-before-blocks': ['error', 'always'],
'space-before-function-paren': ['error', 'always'],
'space-in-parens': ['error', 'never'],
- '@typescript-eslint/member-delimiter-style': [
+ '@stylistic/ts/member-delimiter-style': [
'error',
{
multiline: { delimiter: 'none' },
@@ -64,7 +69,7 @@ module.exports = tseslint.config(
}],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/prefer-ts-expect-error': 'error',
- '@typescript-eslint/semi': ['error', 'never'],
+ '@stylistic/ts/semi': ['error', 'never'],
}
}
)
diff --git a/package.json b/package.json
index 92cc451adac..df98fba230d 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,8 @@
"test:types": "tsc",
"test:debug": "node --inspect-brk ./node_modules/.bin/jest",
"test:admin-ui": "jest tests/admin-ui-tests",
+ "lint": "eslint",
+ "lint:fix": "eslint --fix",
"build": "preconstruct build",
"prepare": "preconstruct dev"
},
@@ -30,6 +32,7 @@
"@changesets/get-release-plan": "^4.0.0",
"@eslint/js": "^9.2.0",
"@preconstruct/cli": "2.8.8",
+ "@stylistic/eslint-plugin-ts": "^2.9.0",
"@types/jest": "^29.0.0",
"@types/node": "^20.0.0",
"@types/node-fetch": "^2.5.12",
diff --git a/packages/auth/src/components/Icons.tsx b/packages/auth/src/components/Icons.tsx
index e9c48cd737e..19f2891e4bd 100644
--- a/packages/auth/src/components/Icons.tsx
+++ b/packages/auth/src/components/Icons.tsx
@@ -64,7 +64,7 @@ export const IconGithub = (props: any) => (
// Misc
// ==============================
-const A11yText = forwardRefWithAs<'span', {}>(({ as: Tag = 'span', ...props }, ref) => (
+const A11yText = forwardRefWithAs<'span', unknown>(({ as: Tag = 'span', ...props }, ref) => (
graphql: {
names: GraphQLNames
- },
+ }
pageSize: number
initialColumns: Array
diff --git a/packages/core/src/fields/non-null-graphql.ts b/packages/core/src/fields/non-null-graphql.ts
index f2438b7311b..7886569c836 100644
--- a/packages/core/src/fields/non-null-graphql.ts
+++ b/packages/core/src/fields/non-null-graphql.ts
@@ -20,19 +20,19 @@ export function resolveDbNullable (
export function makeValidateHook (
meta: FieldData,
config: {
- label?: string,
+ label?: string
db?: {
isNullable?: boolean
- },
+ }
graphql?: {
isNonNull?: {
read?: boolean
}
- },
+ }
validation?: {
isRequired?: boolean
[key: string]: unknown
- },
+ }
},
f?: ValidateFieldHook
) {
diff --git a/packages/core/src/fields/resolve-hooks.ts b/packages/core/src/fields/resolve-hooks.ts
index e093cfc081f..68b21281498 100644
--- a/packages/core/src/fields/resolve-hooks.ts
+++ b/packages/core/src/fields/resolve-hooks.ts
@@ -26,7 +26,7 @@ function resolveValidateHooks ({
validate,
validateInput,
validateDelete
-}: FieldHooks): Exclude["validate"], Function> | undefined {
+}: FieldHooks): Exclude['validate'], (...args: any) => any> | undefined {
if (!validate && !validateInput && !validateDelete) return
return {
create: merge(validateInput, typeof validate === 'function' ? validate : validate?.create),
diff --git a/packages/core/src/fields/types/calendarDay/index.ts b/packages/core/src/fields/types/calendarDay/index.ts
index 89e37f182c9..4e541516ca5 100644
--- a/packages/core/src/fields/types/calendarDay/index.ts
+++ b/packages/core/src/fields/types/calendarDay/index.ts
@@ -25,7 +25,7 @@ export type CalendarDayFieldConfig =
}
}
-export function calendarDay (config: CalendarDayFieldConfig = {}): FieldTypeFunc {
+export function calendarDay (config: CalendarDayFieldConfig = {}): FieldTypeFunc {
const {
isIndexed,
validation,
diff --git a/packages/core/src/fields/types/float/index.ts b/packages/core/src/fields/types/float/index.ts
index f77048b9051..400d3272cf4 100644
--- a/packages/core/src/fields/types/float/index.ts
+++ b/packages/core/src/fields/types/float/index.ts
@@ -27,7 +27,7 @@ export type FloatFieldConfig =
}
}
-export function float (config: FloatFieldConfig = {}): FieldTypeFunc {
+export function float (config: FloatFieldConfig = {}): FieldTypeFunc {
const {
defaultValue,
isIndexed,
diff --git a/packages/core/src/fields/types/password/index.ts b/packages/core/src/fields/types/password/index.ts
index 1324ca89136..05502888df8 100644
--- a/packages/core/src/fields/types/password/index.ts
+++ b/packages/core/src/fields/types/password/index.ts
@@ -53,7 +53,7 @@ const PasswordFilter = graphql.inputObject({
const bcryptHashRegex = /^\$2[aby]?\$\d{1,2}\$[.\/A-Za-z0-9]{53}$/
-export function password (config: PasswordFieldConfig = {}): FieldTypeFunc {
+export function password (config: PasswordFieldConfig = {}): FieldTypeFunc {
const {
bcrypt = bcryptjs,
workFactor = 10,
diff --git a/packages/core/src/fields/types/select/index.ts b/packages/core/src/fields/types/select/index.ts
index ad10c77c12f..eb3d14543a0 100644
--- a/packages/core/src/fields/types/select/index.ts
+++ b/packages/core/src/fields/types/select/index.ts
@@ -55,7 +55,7 @@ export type SelectFieldConfig =
const MAX_INT = 2147483647
const MIN_INT = -2147483648
-export function select (config: SelectFieldConfig): FieldTypeFunc {
+export function select (config: SelectFieldConfig): FieldTypeFunc {
const {
isIndexed,
ui: { displayMode = 'select', ...ui } = {},
diff --git a/packages/core/src/fields/types/virtual/index.ts b/packages/core/src/fields/types/virtual/index.ts
index d8b11971431..0de17bd1649 100644
--- a/packages/core/src/fields/types/virtual/index.ts
+++ b/packages/core/src/fields/types/virtual/index.ts
@@ -42,7 +42,7 @@ export type VirtualFieldConfig =
}
}
-export function virtual ({
+export function virtual ({
field,
...config
}: VirtualFieldConfig): FieldTypeFunc {
diff --git a/packages/core/src/lib/context/createContext.ts b/packages/core/src/lib/context/createContext.ts
index 138494c3e2d..53a858e5df9 100644
--- a/packages/core/src/lib/context/createContext.ts
+++ b/packages/core/src/lib/context/createContext.ts
@@ -68,7 +68,7 @@ export function createContext ({
}: {
prisma: any
session?: unknown
- sudo: Boolean
+ sudo: boolean
req?: IncomingMessage
res?: ServerResponse
}) => {
diff --git a/packages/core/src/lib/core/initialise-lists.ts b/packages/core/src/lib/core/initialise-lists.ts
index 191e2ff2807..1e0b7fc2043 100644
--- a/packages/core/src/lib/core/initialise-lists.ts
+++ b/packages/core/src/lib/core/initialise-lists.ts
@@ -121,7 +121,7 @@ export type InitialisedList = {
}
prisma: {
- types: GraphQLNames, // TODO: not completely appropriate, but what is used for now
+ types: GraphQLNames // TODO: not completely appropriate, but what is used for now
listKey: string
mapping: string | undefined
extendPrismaSchema: ((schema: string) => string) | undefined
@@ -541,7 +541,7 @@ function getListsWithInitialisedFields (
const findManyArgs: FindManyArgs = {
where: graphql.arg({
type: graphql.nonNull(where),
- defaultValue: listConfig.isSingleton ? ({ id: { equals: '1' } } as {}) : {},
+ defaultValue: listConfig.isSingleton ? ({ id: { equals: '1' } } as object) : {},
}),
orderBy: graphql.arg({
type: graphql.nonNull(graphql.list(graphql.nonNull(orderBy))),
diff --git a/packages/core/src/lib/core/queries/index.ts b/packages/core/src/lib/core/queries/index.ts
index 48b6dba3dfe..1de5e2bf99a 100644
--- a/packages/core/src/lib/core/queries/index.ts
+++ b/packages/core/src/lib/core/queries/index.ts
@@ -31,7 +31,7 @@ export function getQueriesForList (list: InitialisedList) {
args: {
where: graphql.arg({
type: graphql.nonNull(list.graphql.types.where),
- defaultValue: list.isSingleton ? ({ id: { equals: '1' } } as {}) : {},
+ defaultValue: list.isSingleton ? ({ id: { equals: '1' } } as object) : {},
}),
},
async resolve (_rootVal, args, context, info) {
diff --git a/packages/core/src/types/admin-meta.ts b/packages/core/src/types/admin-meta.ts
index 170e0f72a09..f225dbc19c6 100644
--- a/packages/core/src/types/admin-meta.ts
+++ b/packages/core/src/types/admin-meta.ts
@@ -26,7 +26,7 @@ export type CreateViewFieldModes =
export type AdminConfig = {
components?: {
- Logo?: (props: {}) => ReactElement
+ Logo?: (props: object) => ReactElement
Navigation?: (props: NavigationProps) => ReactElement
}
}
diff --git a/packages/core/src/types/json-field-type-polyfill-for-sqlite.ts b/packages/core/src/types/json-field-type-polyfill-for-sqlite.ts
index 641763c76f6..4b7e664604b 100644
--- a/packages/core/src/types/json-field-type-polyfill-for-sqlite.ts
+++ b/packages/core/src/types/json-field-type-polyfill-for-sqlite.ts
@@ -10,9 +10,10 @@ import {
type UpdateFieldInputArg,
fieldType,
} from '.'
+import { type InputType, type Arg } from '@graphql-ts/schema'
function mapOutputFieldToSQLite (
- field: graphql.Field<{ value: JSONValue, item: BaseItem }, {}, any, 'value'>
+ field: graphql.Field<{ value: JSONValue, item: BaseItem }, Record>, any, 'value'>
) {
const innerResolver = field.resolve || (({ value }) => value)
return graphql.fields<{
diff --git a/packages/core/src/types/next-fields.ts b/packages/core/src/types/next-fields.ts
index f5153e42a3f..05149147e5e 100644
--- a/packages/core/src/types/next-fields.ts
+++ b/packages/core/src/types/next-fields.ts
@@ -182,7 +182,7 @@ type DBFieldToInputValue = TDBField extends ScalarDBFi
many: readonly ScalarPrismaTypes[Scalar][] | undefined
}[Mode]
: TDBField extends RelationDBField<'many' | 'one'>
- ? { connect?: {}, disconnect?: boolean } | undefined
+ ? { connect?: object, disconnect?: boolean } | undefined
: TDBField extends EnumDBField
? {
optional: Value | null | undefined
diff --git a/packages/core/src/types/schema/graphql-ts-schema.ts b/packages/core/src/types/schema/graphql-ts-schema.ts
index c77f09103cc..168a2b26088 100644
--- a/packages/core/src/types/schema/graphql-ts-schema.ts
+++ b/packages/core/src/types/schema/graphql-ts-schema.ts
@@ -40,6 +40,7 @@ export { bindGraphQLSchemaAPIToContext } from '@graphql-ts/schema'
export type { BaseSchemaMeta, Extension } from '@graphql-ts/extend'
export { extend, wrap } from '@graphql-ts/extend'
import { field as fieldd } from './schema-api-with-context'
+import { type InputType, type Arg } from '@graphql-ts/schema'
export { fields, interface, interfaceField, object, union } from './schema-api-with-context'
// TODO: remove when we use { graphql } from '.keystone'
@@ -72,7 +73,7 @@ type FieldFuncResolve<
? {
resolve?: graphqlTsSchema.FieldResolver<
Source,
- SomeTypeThatIsntARecordOfArgs extends Args ? {} : Args,
+ SomeTypeThatIsntARecordOfArgs extends Args ? Record> : Args,
Type,
Context
>
@@ -80,7 +81,7 @@ type FieldFuncResolve<
: {
resolve: graphqlTsSchema.FieldResolver<
Source,
- SomeTypeThatIsntARecordOfArgs extends Args ? {} : Args,
+ SomeTypeThatIsntARecordOfArgs extends Args ? Record> : Args,
Type,
Context
>
@@ -88,7 +89,7 @@ type FieldFuncResolve<
: {
resolve: graphqlTsSchema.FieldResolver<
Source,
- SomeTypeThatIsntARecordOfArgs extends Args ? {} : Args,
+ SomeTypeThatIsntARecordOfArgs extends Args ? Record> : Args,
Type,
Context
>
@@ -113,7 +114,7 @@ type FieldFunc = <
Type extends OutputType,
Key extends string,
Context extends KeystoneContext,
- Args extends { [Key in keyof Args]: graphqlTsSchema.Arg } = {}
+ Args extends { [Key in keyof Args]: graphqlTsSchema.Arg } = object
>(
field: FieldFuncArgs