Skip to content

Commit

Permalink
chore(sanity): fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard committed Oct 3, 2022
1 parent 8debf98 commit b9db377
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/sanity/src/components/zOffsets/ZIndexContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ZIndexContextValue} from './types'
import {defaults} from './defaults'

/**
* @todo: Rename to `ZOffsetsContext`
* TODO: Rename to `ZOffsetsContext`
*
* @internal
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/components/zOffsets/ZIndexProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {defaults} from './defaults'
import {ZIndexContext} from './ZIndexContext'

/**
* @todo: Rename to `ZOffsetsProvider`
* TODO: Rename to `ZOffsetsProvider`
*
* @internal
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/sanity/src/components/zOffsets/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @todo: Rename to `ZOffsetsContextValue`
* TODO: Rename to `ZOffsetsContextValue`
*
* @internal
*/
Expand All @@ -24,7 +24,7 @@ export interface ZIndexContextValue {
/** Used by: `@sanity/google-maps-input` */
modal: number | number[]

/** @todo this path does not seem to be correct - fix? */
/** TODO this path does not seem to be correct - fix? */
/** Used by: `movingItem` in packages/sanity/src/styles/layout/helpers.css */
movingItem: number | number[]

Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/components/zOffsets/useZIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ZIndexContextValue} from './types'
import {ZIndexContext} from './ZIndexContext'

/**
* @todo: Rename to `useZOffsets`
* TODO: Rename to `useZOffsets`
*
* @internal
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/sanity/src/datastores/history/history/diffValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type AnnotationExtractor = {
}

class ArrayContentWrapper implements ArrayInput<Annotation> {
type: 'array' = 'array'
type = 'array' as const
value: unknown[]
length: number
annotation: Annotation
Expand Down Expand Up @@ -54,7 +54,7 @@ class ArrayContentWrapper implements ArrayInput<Annotation> {
}

class ObjectContentWrapper implements ObjectInput<Annotation> {
type: 'object' = 'object'
type = 'object' as const
value: Record<string, unknown>
keys: string[]
annotation: Annotation
Expand Down Expand Up @@ -88,7 +88,7 @@ class ObjectContentWrapper implements ObjectInput<Annotation> {
}

class StringContentWrapper implements StringInput<Annotation> {
type: 'string' = 'string'
type = 'string' as const
value: string
annotation: Annotation
extractor: AnnotationExtractor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function Debug(props: {documentId: string; documentType: string}) {
footer={actionItem.modal.footer}
header={actionItem.modal.header}
id={`document-action-modal-${idx}`}
key={idx}
// eslint-disable-next-line react/jsx-handler-names
onClose={actionItem.modal.onClose}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/field/__workshop__/DiffFromToStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import {DiffFromTo} from '../diff'

/**
* @todo
* TODO
*/
export default function DiffFromToStory() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import {DiffInspectWrapper} from '../diff/components/DiffInspectWrapper'

/**
* @todo
* TODO
*/
export default function DiffInspectWrapperStory() {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/field/__workshop__/DiffStringStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import {DiffString} from '../diff'

/**
* @todo
* TODO
*/
export default function DiffStringStory() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import {DiffTooltip} from '../diff'

/**
* @todo
* TODO
*/
export default function DiffTooltipStory() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import {FallbackDiff} from '../diff/components/FallbackDiff'

/**
* @todo
* TODO
*/
export default function FallbackDiffStory() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import {FieldChange} from '../diff/components/FieldChange'

/**
* @todo
* TODO
*/
export default function FieldChangeStory() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import {GroupChange} from '../diff/components/GroupChange'

/**
* @todo
* TODO
*/
export default function GroupChangeStory() {
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/sanity/src/field/diff/annotations/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export type DiffVisitor = (diff: Diff | StringDiffSegment, path: Path) => boolea
/**
* Visit all diffs in tree, until visitor returns false
*
* @param diff Diff to visit
* @param visitor Visitor function, return false to stop from going deeper
* @param diff - Diff to visit
* @param visitor - Visitor function, return false to stop from going deeper
*/
export function visitDiff(
diff: Diff | StringDiffSegment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function Block(props: {
return (
<div
onClick={handleClick}
diff-block-action={diff.action}
data-diff-block-action={diff.action}
data-block-note={`changed_from_style_${fromStyle || 'undefined'}`}
>
{returned}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const SCROLL_OPTIONS = {scrollMode: 'if-needed'} as const
/**
* A hook to help make sure the parent element of a value edited in a dialog (or "out of band") stays
visible in the background
* @param elementRef The element to scroll into view when the proivided focusWithin changes from true to false
* @param hasFocusWithin A boolean indicating whether we have has focus within the currently edited value
* @param elementRef - The element to scroll into view when the proivided focusWithin changes from true to false
* @param hasFocusWithin - A boolean indicating whether we have has focus within the currently edited value
*/
export function useScrollIntoViewOnFocusWithin(
elementRef: {current: HTMLElement | null},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {CrossDatasetReferencePreview} from './CrossDatasetReferencePreview'
* Used to preview a referenced type
* Takes as props the referenced document, the reference type and a hook to subscribe to
* in order to listen for the reference info
* @param props
* @constructor
*/
export function OptionPreview(props: {
document: {_id: string; _type: string}
Expand Down
4 changes: 2 additions & 2 deletions packages/sanity/src/form/inputs/Slug/utils/useAsync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export type AsyncState<T> = AsyncPendingState | AsyncCompleteState<T> | AsyncErr
* Takes an async function and returns a [AsyncState<value>, callback] pair.
* Whenever the callback is invoked, a new AsyncState is returned.
* If the returned callback is called again before the previous callback has settled, the resolution of the previous one will be ignored, thus preventing race conditions.
* @param fn an async function that returns a value
* @param dependencies list of dependencies that will return a new [value, callback] pair
* @param fn - an async function that returns a value
* @param dependencies - list of dependencies that will return a new [value, callback] pair
*/
export function useAsync<T, U>(
fn: (arg: U) => Promise<T>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
* Find the index of the nearest element with the same value. Starts at given index and looks incrementally in either direction for the searchElement
* It's *NOT* inclusive: If the element matches the element at the startIdx, startIdx will be returned
* It prefers matches in the first half. If there's a tie it will pick the first element that comes before
* @param array
* @param startIdx
* @param searchElement
*/
export function nearestIndexOf<T>(array: T[], startIdx: number, searchElement: T) {
return nearestIndex(array, startIdx, (element) => element === searchElement)
Expand All @@ -14,9 +11,6 @@ export function nearestIndexOf<T>(array: T[], startIdx: number, searchElement: T
* Find the index of the nearest element matching the predicate. Starts at given index and looks incrementally in either direction
* It's *NOT* inclusive: If the predicate matches the element at the startIdx, startIdx will be returned
* It prefers matches in the first half. If there's a tie it will pick the first element that comes before
* @param array
* @param startIdx
* @param predicate
*/
export function nearestIndex<T>(
array: T[],
Expand Down
4 changes: 2 additions & 2 deletions packages/sanity/src/form/inputs/files/FileInput/FileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ToastParams,
} from '@sanity/ui'
import {SanityClient} from '@sanity/client'
import {isFileSource} from '@sanity/asset-utils'
import {WithReferencedAsset} from '../../../utils/WithReferencedAsset'
import {Uploader, UploaderResolver, UploadOptions} from '../../../studio/uploads/types'
import {FileInfo, FileTarget} from '../common/styles'
Expand All @@ -41,7 +42,6 @@ import {ChangeIndicator} from '../../../../components/changeIndicators'
import {CardOverlay, FlexContainer} from './styles'
import {FileDetails} from './FileDetails'
import {FileSkeleton} from './FileSkeleton'
import {isFileSource} from '@sanity/asset-utils'
import {InvalidFileWarning} from './InvalidFileWarning'

// We alias DOM File type here to distinguish it from the type of the File value
Expand Down Expand Up @@ -636,7 +636,7 @@ export class FileInput extends React.PureComponent<FileInputProps, FileInputStat
)
}
if (member.kind === 'error') {
return <MemberFieldError member={member} />
return <MemberFieldError key={member.key} member={member} />
}
//@ts-expect-error all possible cases should be covered
return <>Unknown member kind: ${member.kind}</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import React, {ReactNode} from 'react'
import deepCompare from 'react-fast-compare'
import {SanityClient} from '@sanity/client'
import {isImageSource} from '@sanity/asset-utils'
import {PatchEvent, setIfMissing, unset} from '../../../patch'
import {FieldMember} from '../../../store'
import {FIXME, InputProps, ObjectInputProps} from '../../../types'
Expand All @@ -52,7 +53,6 @@ import {FormInput} from '../../../FormInput'
import {MemberField, MemberFieldError, MemberFieldSet} from '../../../members'
import {ImageActionsMenu} from './ImageActionsMenu'
import {ImagePreview} from './ImagePreview'
import {isImageSource} from '@sanity/asset-utils'
import {InvalidImageWarning} from './InvalidImageWarning'

export interface Image extends Partial<BaseImage> {
Expand Down Expand Up @@ -794,7 +794,7 @@ export class ImageInput extends React.PureComponent<ImageInputProps, ImageInputS
)
}
if (member.kind === 'error') {
return <MemberFieldError member={member} />
return <MemberFieldError key={member.key} member={member} />
}
//@ts-expect-error all possible cases should be covered
return <>Unknown member kind: ${member.kind}</>
Expand Down
4 changes: 3 additions & 1 deletion packages/sanity/src/form/utils/asserters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
PrimitiveFieldProps,
} from '../types/fieldProps'

export function assertType<T>(v: unknown): asserts v is T {}
export function assertType<T>(v: unknown): asserts v is T {
// intentionally empty
}

export function isObjectInputProps(inputProps: InputProps): inputProps is ObjectInputProps {
return isObjectSchemaType(inputProps.schemaType)
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/module-status/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {CheckModuleVersionsOptions, ModuleStatusResponse} from './types'
* to date and/or supported, and if they are outdated; which versions are is
* the latest available on npm vs which ones are installed locally.
*
* @param options Options to use for resolving module status
* @param options - Options to use for resolving module status
* @internal Not a stable API yet
*/
export function useModuleStatus(
Expand Down

0 comments on commit b9db377

Please sign in to comment.