Skip to content

Commit

Permalink
chore(lint): make eslint run, fix errors
Browse files Browse the repository at this point in the history
Closes #9316
  • Loading branch information
iamandrewluca committed Oct 11, 2024
1 parent dac5d5d commit 937535b
Show file tree
Hide file tree
Showing 28 changed files with 152 additions and 63 deletions.
2 changes: 1 addition & 1 deletion design-system/packages/core/src/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion design-system/packages/fields/src/FieldContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Tag ref={ref} {...props} />
})
19 changes: 12 additions & 7 deletions eslint.config.js → eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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' },
Expand All @@ -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'],
}
}
)
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
<Tag
ref={ref}
css={{
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const getSchemaExtension = ({
try {
ast = parse(query)
} catch (err) {
throw new Error( `The query to get session data has a syntax error, the sessionData option in your createAuth usage is likely incorrect\n${err}`)
throw new Error(`The query to get session data has a syntax error, the sessionData option in your createAuth usage is likely incorrect\n${err}`)
}

const errors = validate(base.schema, ast)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/admin-ui/admin-meta-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export type StaticAdminMetaQuery = {
}>
graphql: {
names: GraphQLNames
},
}

pageSize: number
initialColumns: Array<string>
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/fields/non-null-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ export function resolveDbNullable (
export function makeValidateHook <ListTypeInfo extends BaseListTypeInfo> (
meta: FieldData,
config: {
label?: string,
label?: string
db?: {
isNullable?: boolean
},
}
graphql?: {
isNonNull?: {
read?: boolean
}
},
}
validation?: {
isRequired?: boolean
[key: string]: unknown
},
}
},
f?: ValidateFieldHook<ListTypeInfo, 'create' | 'update' | 'delete', ListTypeInfo['fields']>
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/resolve-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function resolveValidateHooks <ListTypeInfo extends BaseListTypeInfo> ({
validate,
validateInput,
validateDelete
}: FieldHooks<ListTypeInfo>): Exclude<FieldHooks<ListTypeInfo>["validate"], Function> | undefined {
}: FieldHooks<ListTypeInfo>): Exclude<FieldHooks<ListTypeInfo>['validate'], (...args: any) => any> | undefined {
if (!validate && !validateInput && !validateDelete) return
return {
create: merge(validateInput, typeof validate === 'function' ? validate : validate?.create),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/calendarDay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type CalendarDayFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
}
}

export function calendarDay <ListTypeInfo extends BaseListTypeInfo>(config: CalendarDayFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
export function calendarDay <ListTypeInfo extends BaseListTypeInfo> (config: CalendarDayFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
const {
isIndexed,
validation,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/float/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type FloatFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
}
}

export function float <ListTypeInfo extends BaseListTypeInfo>(config: FloatFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
export function float <ListTypeInfo extends BaseListTypeInfo> (config: FloatFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
const {
defaultValue,
isIndexed,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/password/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const PasswordFilter = graphql.inputObject({

const bcryptHashRegex = /^\$2[aby]?\$\d{1,2}\$[.\/A-Za-z0-9]{53}$/

export function password <ListTypeInfo extends BaseListTypeInfo>(config: PasswordFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
export function password <ListTypeInfo extends BaseListTypeInfo> (config: PasswordFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> {
const {
bcrypt = bcryptjs,
workFactor = 10,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type SelectFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
const MAX_INT = 2147483647
const MIN_INT = -2147483648

export function select <ListTypeInfo extends BaseListTypeInfo>(config: SelectFieldConfig<ListTypeInfo>): FieldTypeFunc<ListTypeInfo> {
export function select <ListTypeInfo extends BaseListTypeInfo> (config: SelectFieldConfig<ListTypeInfo>): FieldTypeFunc<ListTypeInfo> {
const {
isIndexed,
ui: { displayMode = 'select', ...ui } = {},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/fields/types/virtual/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type VirtualFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
}
}

export function virtual <ListTypeInfo extends BaseListTypeInfo>({
export function virtual <ListTypeInfo extends BaseListTypeInfo> ({
field,
...config
}: VirtualFieldConfig<ListTypeInfo>): FieldTypeFunc<ListTypeInfo> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/context/createContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function createContext ({
}: {
prisma: any
session?: unknown
sudo: Boolean
sudo: boolean
req?: IncomingMessage
res?: ServerResponse
}) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/core/initialise-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/core/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/admin-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type CreateViewFieldModes =

export type AdminConfig = {
components?: {
Logo?: (props: {}) => ReactElement
Logo?: (props: object) => ReactElement
Navigation?: (props: NavigationProps) => ReactElement
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Arg<InputType>>, any, 'value'>
) {
const innerResolver = field.resolve || (({ value }) => value)
return graphql.fields<{
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/next-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ type DBFieldToInputValue<TDBField extends DBField> = 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<infer Value, infer Mode>
? {
optional: Value | null | undefined
Expand Down
11 changes: 6 additions & 5 deletions packages/core/src/types/schema/graphql-ts-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -72,23 +73,23 @@ type FieldFuncResolve<
? {
resolve?: graphqlTsSchema.FieldResolver<
Source,
SomeTypeThatIsntARecordOfArgs extends Args ? {} : Args,
SomeTypeThatIsntARecordOfArgs extends Args ? Record<string, Arg<InputType>> : Args,
Type,
Context
>
}
: {
resolve: graphqlTsSchema.FieldResolver<
Source,
SomeTypeThatIsntARecordOfArgs extends Args ? {} : Args,
SomeTypeThatIsntARecordOfArgs extends Args ? Record<string, Arg<InputType>> : Args,
Type,
Context
>
}
: {
resolve: graphqlTsSchema.FieldResolver<
Source,
SomeTypeThatIsntARecordOfArgs extends Args ? {} : Args,
SomeTypeThatIsntARecordOfArgs extends Args ? Record<string, Arg<InputType>> : Args,
Type,
Context
>
Expand All @@ -113,7 +114,7 @@ type FieldFunc = <
Type extends OutputType,
Key extends string,
Context extends KeystoneContext<any>,
Args extends { [Key in keyof Args]: graphqlTsSchema.Arg<graphqlTsSchema.InputType> } = {}
Args extends { [Key in keyof Args]: graphqlTsSchema.Arg<graphqlTsSchema.InputType> } = object
>(
field: FieldFuncArgs<Source, Args, Type, Key, Context>
) => graphqlTsSchema.Field<Source, Args, Type, Key, Context>
Expand Down Expand Up @@ -282,7 +283,7 @@ export const CalendarDay = graphqlTsSchema.graphql.scalar<string>(
})
)

export const Empty = graphqlTsSchema.graphql.scalar<{}>(
export const Empty = graphqlTsSchema.graphql.scalar(
new GraphQLScalarType({
name: 'Empty',
serialize (value) { return null },
Expand Down
2 changes: 1 addition & 1 deletion packages/document-renderer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface Renderers {
blockquote: OnlyChildrenComponent
code: Component<{ children: string }> | keyof JSX.IntrinsicElements
layout: Component<{ layout: [number, ...number[]], children: ReactElement[] }>
divider: Component<{}> | keyof JSX.IntrinsicElements
divider: Component<unknown> | keyof JSX.IntrinsicElements
heading: Component<{
level: 1 | 2 | 3 | 4 | 5 | 6
children: ReactNode
Expand Down
2 changes: 1 addition & 1 deletion packages/fields-document/src/DocumentEditor/code-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useToolbarState } from './toolbar-state'

export * from './code-block-shared'

function CodeButton ({ attrs }: { attrs: {} }) {
function CodeButton ({ attrs }: { attrs: object }) {
const {
editor,
code: { isDisabled, isSelected },
Expand Down
2 changes: 1 addition & 1 deletion packages/fields-document/src/DocumentEditor/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const UnlinkButton = memo(function UnlinkButton ({ onUnlink }: { onUnlink: () =>

let linkIcon = <LinkIcon size="small" />

const LinkButton = forwardRef<HTMLButtonElement, {}>(function LinkButton (props, ref) {
const LinkButton = forwardRef<HTMLButtonElement>(function LinkButton (props, ref) {
const {
editor,
links: { isDisabled, isSelected },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ declare namespace __jsx {
data: {
id: string
label: string
data: {}
data: object
}

children: Children
}
}
type Element = Node
interface ElementAttributesProperty {
props: {}
props: object
}
interface ElementChildrenAttribute {
children: {}
children: object
}
}
}
2 changes: 1 addition & 1 deletion packages/fields-document/src/structure-graphql-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function getOutputGraphQLFieldInner (
fields: () =>
Object.fromEntries(
Object.entries(schema.fields).map(
([key, val]): [string, graphql.Field<unknown, {}, graphql.OutputType, string>] => {
([key, val]): [string, graphql.Field<unknown, Record<string, graphql.Arg<graphql.InputType>>, graphql.OutputType, string>] => {
const field = getOutputGraphQLField(
`${name}${key[0].toUpperCase()}${key.slice(1)}`,
val,
Expand Down
Loading

0 comments on commit 937535b

Please sign in to comment.