Skip to content

Commit

Permalink
chore: manually fix remaining non-autofixable eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Feb 12, 2024
1 parent 7ca741c commit 5a65b7b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/@sanity/import/src/importFromFolder.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const fs = require('fs')
const path = require('path')
const debug = require('debug')('sanity:import:folder')
const getFileUrl = require('file-url')
const globby = require('globby')
const debug = require('debug')('sanity:import:folder')
const readJson = require('./util/readJson')
const rimraf = require('./util/rimraf')

Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/import/src/references.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {extractWithPath} = require('@sanity/mutator')
const debug = require('debug')('sanity:import')
const {get} = require('lodash')
const pMap = require('p-map')
const {extractWithPath} = require('@sanity/mutator')
const serializePath = require('./serializePath')
const progressStepper = require('./util/progressStepper')
const retryOnFailure = require('./util/retryOnFailure')
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/import/src/uploadAssets.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const basename = require('path').basename
const parseUrl = require('url').parse
const {isSanityImageUrl} = require('@sanity/asset-utils')
const debug = require('debug')('sanity:import')
const pMap = require('p-map')
const {isSanityImageUrl} = require('@sanity/asset-utils')
const getHashedBufferForUri = require('./util/getHashedBufferForUri')
const progressStepper = require('./util/progressStepper')
const retryOnFailure = require('./util/retryOnFailure')
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/import/src/validateAssetDocuments.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const debug = require('debug')('sanity:import:asset-validation')
const {generateHelpUrl} = require('@sanity/generate-help-url')
const debug = require('debug')('sanity:import:asset-validation')
const pMap = require('p-map')
const urlExists = require('./util/urlExists')

Expand Down
9 changes: 0 additions & 9 deletions packages/sanity/playwright-ct/tests/utils/testHelpers.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import {type ComponentFixtures} from '@playwright/experimental-ct-react'
import {type Locator, type PlaywrightTestArgs} from '@playwright/test'

export const DEFAULT_TYPE_DELAY = 20

/**
* The delay between key presses in milliseconds for fast typing. This is usually used for typing in the PTE.
* The PTE normally need some time to process the input and sync its internal state with the document
*/
export const TYPE_DELAY_HIGH = 150

export type MountResult = Awaited<ReturnType<ComponentFixtures['mount']>>

export function testHelpers({page}: {page: PlaywrightTestArgs['page']}) {
const activatePTInputOverlay = async ($pteField: Locator) => {
const $overlay = $pteField.getByTestId('activate-overlay')
Expand Down
4 changes: 2 additions & 2 deletions packages/sanity/src/core/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
type SchemaTypeDefinition,
} from '@sanity/types'
import {type i18n} from 'i18next'
import {type ComponentType, type ReactElement, type ReactNode} from 'react'
import {type ComponentType, type ReactNode} from 'react'
import {type Observable} from 'rxjs'
import {type Router, type RouterState} from 'sanity/router'

Expand Down Expand Up @@ -521,7 +521,7 @@ export interface DocumentLayoutProps {
* The type of the document. This is a read-only property and changing it will have no effect.
*/
documentType: string
renderDefault: (props: DocumentLayoutProps) => ReactElement
renderDefault: (props: DocumentLayoutProps) => React.ReactElement
}

interface DocumentComponents {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import {Stack, Text, useToast} from '@sanity/ui'
import {uuid} from '@sanity/uuid'
import {type FocusEvent, type KeyboardEvent, useCallback, useMemo, useRef, useState} from 'react'
import {
type FocusEvent,
forwardRef,
type KeyboardEvent,
useCallback,
useMemo,
useRef,
useState,
} from 'react'
import {useObservableCallback} from 'react-rx'
import {concat, type Observable, of} from 'rxjs'
import {catchError, filter, map, scan, switchMap, tap} from 'rxjs/operators'
Expand Down Expand Up @@ -28,11 +36,21 @@ import {useReferenceInfo} from './useReferenceInfo'
import {useReferenceInput} from './useReferenceInput'
import {useReferenceItemRef} from './useReferenceItemRef'

const StyledPreviewCard = styled(PreviewCard)`
/* this is a hack to avoid layout jumps while previews are loading
there's probably better ways of solving this */
min-height: 36px;
`
// This is a workaround for a circular import issue.
// Calling `styled(PreviewCard)` at program load time triggered a build error with the commonjs bundle because it tried
// to access the PreviewCard variable/symbol before it was initialized.
// The workaround is to defer creating StyledPreviewCard until react render time
let StyledPreviewCardImpl: undefined | typeof PreviewCard
const StyledPreviewCard: typeof PreviewCard = forwardRef(function StyledPreviewCard(props, ref) {
if (!StyledPreviewCardImpl) {
StyledPreviewCardImpl = styled(PreviewCard)`
/* this is a hack to avoid layout jumps while previews are loading
there's probably better ways of solving this */
min-height: 36px;
`
}
return <StyledPreviewCardImpl ref={ref} {...props} />
})

const INITIAL_SEARCH_STATE: ReferenceSearchState = {
hits: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@sanity/types'
import {Box, Card, Menu, type ThemeColorToneKey, type ToastParams} from '@sanity/ui'
import {get, startCase} from 'lodash'
import React, {type FocusEvent, PureComponent, type ReactNode} from 'react'
import {PureComponent, type ReactNode} from 'react'
import {type Observable, type Subscription} from 'rxjs'

import {Button, MenuButton, MenuItem} from '../../../../../ui-components'
Expand Down Expand Up @@ -48,7 +48,7 @@ export interface BaseFileInputValue extends Partial<BaseFile> {
_upload?: UploadState
}

function passThrough({children}: {children?: ReactNode}) {
function passThrough({children}: {children?: React.ReactNode}) {
return children
}

Expand Down Expand Up @@ -298,7 +298,7 @@ export class BaseFileInput extends PureComponent<BaseFileInputProps, BaseFileInp
this.setState({selectedAssetSource: null})
}

handleFileTargetFocus = (event: FocusEvent) => {
handleFileTargetFocus = (event: React.FocusEvent) => {
// We want to handle focus when the file target element *itself* receives
// focus, not when an interactive child element receives focus. Since React has decided
// to let focus bubble, so this workaround is needed
Expand Down

0 comments on commit 5a65b7b

Please sign in to comment.