From e987f2dadfdeb0369efaf769ebc19d6d66a77eb5 Mon Sep 17 00:00:00 2001 From: Andrei Luca <1881266+iamandrewluca@users.noreply.github.com> Date: Thu, 17 Oct 2024 08:13:02 +0300 Subject: [PATCH] chore(lint): make eslint run, fix errors (#9361) Co-authored-by: Daniel Cousens --- .../packages/core/src/components/Box.tsx | 24 +++++----- .../packages/core/src/components/Link.tsx | 2 +- .../packages/fields/src/FieldContainer.tsx | 2 +- design-system/packages/fields/src/Switch.tsx | 10 ++-- design-system/packages/icons/src/Icon.tsx | 2 +- .../packages/modals/src/DrawerBase.tsx | 8 ++-- .../packages/modals/src/DrawerController.tsx | 2 +- .../packages/modals/src/drawer-context.tsx | 6 +-- .../packages/popover/src/Popover.tsx | 8 ++-- .../src/SegmentedControl.tsx | 4 +- design-system/packages/toast/src/Toast.tsx | 4 +- .../website/pages/components/fields.tsx | 2 +- .../website/pages/components/modals.tsx | 6 +-- .../website/pages/components/options.tsx | 2 +- docs/components/ContactForm.tsx | 7 ++- docs/components/Header.tsx | 4 +- docs/components/docs/DocumentEditorDemo.tsx | 2 +- docs/components/docs/TableOfContents.tsx | 10 ++-- docs/components/primitives/Code.tsx | 18 +++---- docs/markdoc/index.ts | 8 ++-- eslint.config.js => eslint.config.mjs | 29 +++++------ package.json | 5 +- packages/auth/src/components/Icons.tsx | 2 +- packages/auth/src/lib/emailHeuristics.ts | 2 +- packages/auth/src/pages/InitPage.tsx | 2 +- packages/auth/src/schema.ts | 4 +- packages/cloudinary/src/views/Field.tsx | 4 +- .../admin-ui/id-field-view.tsx | 2 +- .../admin-ui/pages/HomePage/index.tsx | 2 +- .../admin-ui/pages/ItemPage/index.tsx | 2 +- .../admin-ui/pages/ListPage/FilterAdd.tsx | 4 +- .../admin-ui/pages/ListPage/index.tsx | 6 +-- .../admin-ui/pages/ListPage/useFilters.tsx | 2 +- .../pages/ListPage/useSelectedFields.tsx | 4 +- .../admin-ui/pages/ListPage/useSort.tsx | 2 +- .../core/src/admin-ui/admin-meta-graphql.ts | 2 +- packages/core/src/admin-ui/templates/app.ts | 2 +- packages/core/src/admin-ui/utils/item-form.ts | 2 +- .../core/src/admin-ui/utils/useAdminMeta.tsx | 4 +- packages/core/src/fields/non-null-graphql.ts | 8 ++-- packages/core/src/fields/resolve-hooks.ts | 2 +- .../src/fields/types/bigInt/views/index.tsx | 2 +- .../src/fields/types/calendarDay/index.ts | 2 +- .../fields/types/calendarDay/views/index.tsx | 2 +- .../src/fields/types/decimal/views/index.tsx | 2 +- packages/core/src/fields/types/float/index.ts | 2 +- .../src/fields/types/float/views/index.tsx | 8 ++-- .../src/fields/types/image/views/Field.tsx | 4 +- .../src/fields/types/integer/views/index.tsx | 4 +- .../src/fields/types/integer/views/utils.tsx | 2 +- .../src/fields/types/json/views/index.tsx | 2 +- .../core/src/fields/types/password/index.ts | 4 +- .../relationship/views/RelationshipSelect.tsx | 4 +- .../types/relationship/views/cards/index.tsx | 6 +-- .../relationship/views/cards/useItemState.tsx | 10 ++-- .../fields/types/relationship/views/index.tsx | 16 +++---- .../core/src/fields/types/select/index.ts | 2 +- .../src/fields/types/select/views/index.tsx | 4 +- .../src/fields/types/text/views/index.tsx | 4 +- .../fields/types/timestamp/views/index.tsx | 4 +- .../core/src/fields/types/virtual/index.ts | 2 +- packages/core/src/lib/assets/utils.ts | 2 +- .../core/src/lib/context/createContext.ts | 2 +- .../core/src/lib/core/initialise-lists.ts | 4 +- packages/core/src/lib/core/queries/index.ts | 2 +- packages/core/src/lib/utils.ts | 2 +- packages/core/src/scripts/dev.ts | 6 +-- packages/core/src/session.ts | 4 +- packages/core/src/types/admin-meta.ts | 2 +- .../json-field-type-polyfill-for-sqlite.ts | 3 +- packages/core/src/types/next-fields.ts | 2 +- .../src/types/schema/graphql-ts-schema.ts | 15 +++--- packages/document-renderer/src/index.tsx | 2 +- .../src/DocumentEditor/Toolbar.tsx | 4 +- .../block-markdown-shortcuts.ts | 2 +- .../src/DocumentEditor/blockquote.test.tsx | 8 ++-- .../src/DocumentEditor/code-block.test.tsx | 10 ++-- .../src/DocumentEditor/code-block.tsx | 2 +- .../document-features-normalization.test.tsx | 2 +- .../insert-break-and-delete.test.tsx | 10 ++-- .../insertion-and-preview-props.test.tsx | 32 ++++++------- .../component-blocks/normalization.test.tsx | 18 +++---- .../component-blocks/preview-props.test.ts | 4 +- .../component-blocks/utils.test.ts | 2 +- .../with-component-blocks.tsx | 2 +- .../src/DocumentEditor/divider.test.tsx | 2 +- .../src/DocumentEditor/heading.test.tsx | 8 ++-- .../src/DocumentEditor/index.tsx | 2 +- .../src/DocumentEditor/insert-menu-shared.ts | 2 +- .../src/DocumentEditor/insert-menu.test.tsx | 24 +++++----- .../src/DocumentEditor/insert-menu.tsx | 2 +- .../src/DocumentEditor/layouts.test.tsx | 14 +++--- .../src/DocumentEditor/link.tsx | 4 +- .../src/DocumentEditor/lists.test.tsx | 48 +++++++++---------- .../markdown-link-shortcut.test.tsx | 22 ++++----- .../src/DocumentEditor/marks.test.tsx | 38 +++++++-------- .../src/DocumentEditor/marks.tsx | 2 +- .../src/DocumentEditor/paragraphs.ts | 2 +- .../src/DocumentEditor/pasting/index.ts | 2 +- .../DocumentEditor/pasting/markdown.test.tsx | 2 +- .../src/DocumentEditor/pasting/test-utils.tsx | 2 +- .../primitives/inline-dialog.tsx | 2 +- .../src/DocumentEditor/shortcuts.test.tsx | 4 +- .../src/DocumentEditor/soft-breaks.test.tsx | 4 +- .../DocumentEditor/tests/jsx/namespace.d.ts | 6 +-- .../DocumentEditor/tests/test-utils.test.tsx | 10 ++-- .../src/DocumentEditor/tests/utils.tsx | 9 ++-- .../DocumentEditor/toolbar-state-shared.ts | 8 ++-- .../src/structure-graphql-output.ts | 2 +- packages/fields-document/src/validation.ts | 2 +- pnpm-lock.yaml | 21 +++++++- tests/api-tests/db-enable-logging.test.ts | 4 +- tests/api-tests/fields/files.test.ts | 2 +- .../fields/images.crud.test.disabled.ts | 4 +- tests/api-tests/fields/types/utils.ts | 4 +- tests/api-tests/omit.test.ts | 2 +- tests/api-tests/queries/filters.test.ts | 8 ++-- tests/api-tests/queries/singletons.test.ts | 2 +- .../many-to-many-one-sided.test.ts | 2 +- .../crud-self-ref/many-to-many.test.ts | 2 +- .../one-to-many-one-sided.test.ts | 2 +- .../crud-self-ref/one-to-many.test.ts | 2 +- .../crud-self-ref/one-to-one.test.ts | 2 +- .../crud/many-to-many-one-sided.test.ts | 2 +- .../relationships/crud/many-to-many.test.ts | 2 +- .../crud/one-to-many-one-sided.test.ts | 2 +- .../relationships/crud/one-to-many.test.ts | 2 +- .../relationships/crud/one-to-one.test.ts | 8 ++-- .../nested-mutations/disconnect-many.test.ts | 2 +- .../disconnect-singular.test.ts | 2 +- .../two-way-backreference/to-many.test.ts | 4 +- .../to-one-query-batching.test.ts | 2 +- .../custom-prisma-project/keystone.ts | 4 +- tests/cli-tests/prisma.test.ts | 4 +- tests/cli-tests/utils.ts | 2 +- 135 files changed, 394 insertions(+), 373 deletions(-) rename eslint.config.js => eslint.config.mjs (71%) diff --git a/design-system/packages/core/src/components/Box.tsx b/design-system/packages/core/src/components/Box.tsx index 68abdc3c192..998cc699523 100644 --- a/design-system/packages/core/src/components/Box.tsx +++ b/design-system/packages/core/src/components/Box.tsx @@ -181,10 +181,10 @@ function useRadii ( { rounding, roundingTop, roundingRight, roundingBottom, roundingLeft }: RadiiProps, { radii }: Theme ) { - let borderBottomLeftRadius = roundingBottom || roundingLeft || rounding - let borderBottomRightRadius = roundingBottom || roundingRight || rounding - let borderTopLeftRadius = roundingTop || roundingLeft || rounding - let borderTopRightRadius = roundingTop || roundingRight || rounding + const borderBottomLeftRadius = roundingBottom || roundingLeft || rounding + const borderBottomRightRadius = roundingBottom || roundingRight || rounding + const borderTopLeftRadius = roundingTop || roundingLeft || rounding + const borderTopRightRadius = roundingTop || roundingRight || rounding return { borderBottomLeftRadius: @@ -208,10 +208,10 @@ function usePadding ( }: PaddingProps, { spacing }: Theme ) { - let pb = paddingBottom || paddingY || padding - let pt = paddingTop || paddingY || padding - let pl = paddingLeft || paddingX || padding - let pr = paddingRight || paddingX || padding + const pb = paddingBottom || paddingY || padding + const pt = paddingTop || paddingY || padding + const pl = paddingLeft || paddingX || padding + const pr = paddingRight || paddingX || padding return { paddingBottom: pb && mapResponsiveProp(pb, spacing), @@ -225,10 +225,10 @@ function useMargin ( { margin, marginTop, marginRight, marginBottom, marginLeft, marginY, marginX }: MarginProps, { spacing }: Theme ) { - let mb = marginBottom || marginY || margin - let mt = marginTop || marginY || margin - let ml = marginLeft || marginX || margin - let mr = marginRight || marginX || margin + const mb = marginBottom || marginY || margin + const mt = marginTop || marginY || margin + const ml = marginLeft || marginX || margin + const mr = marginRight || marginX || margin return { marginBottom: mb && mapResponsiveProp(mb, spacing), 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/design-system/packages/fields/src/Switch.tsx b/design-system/packages/fields/src/Switch.tsx index 290c331c8d9..ec790764768 100644 --- a/design-system/packages/fields/src/Switch.tsx +++ b/design-system/packages/fields/src/Switch.tsx @@ -47,7 +47,7 @@ type SwitchControlProps = { export const SwitchControl = forwardRef( ({ a11yLabels = { on: 'On', off: 'Off' }, checked = false, onChange, ...props }, ref) => { - let onClick = () => { + const onClick = () => { if (onChange) { onChange(!checked) } @@ -64,10 +64,10 @@ export const SwitchControl = forwardRef( const Button = forwardRef((props, ref) => { const { animation, fields, sizing } = useTheme() - let gutter = 3 - let trackHeight = sizing.xsmall + gutter - let trackWidth = trackHeight * 2 - 2 * gutter - let handleSize = trackHeight - gutter * 2 + const gutter = 3 + const trackHeight = sizing.xsmall + gutter + const trackWidth = trackHeight * 2 - 2 * gutter + const handleSize = trackHeight - gutter * 2 return (