Skip to content

Commit

Permalink
fix: react hook linter supressions in SearchFilterAssetInput
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Jul 23, 2024
1 parent ea827e8 commit 1087f55
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"check:deps": "pnpm --recursive --parallel exec depcheck",
"check:format": "prettier . --check",
"check:lint": "turbo run lint --continue -- --quiet",
"check:react-compiler": "eslint --no-inline-config --no-eslintrc --ext .cjs,.mjs,.js,.jsx,.ts,.tsx --parser @typescript-eslint/parser --plugin react-compiler --rule 'react-compiler/react-compiler: [warn]' --ignore-path .eslintignore.react-compiler --max-warnings 27 .",
"check:react-compiler": "eslint --no-inline-config --no-eslintrc --ext .cjs,.mjs,.js,.jsx,.ts,.tsx --parser @typescript-eslint/parser --plugin react-compiler --rule 'react-compiler/react-compiler: [warn]' --ignore-path .eslintignore.react-compiler --max-warnings 14 .",
"check:test": "run-s test -- --silent",
"check:types": "tsc && turbo run check:types --filter='./packages/*' --filter='./packages/@sanity/*'",
"chore:format:fix": "prettier --cache --write .",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {useClient} from '../../../../../../../../../hooks'
import {useTranslation} from '../../../../../../../../../i18n'
import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../../../../../../../../../studioClient'
import {useSource} from '../../../../../../../../source'
import {useSearchState} from '../../../../../contexts/search/useSearchState'
import {type OperatorInputComponentProps} from '../../../../../definitions/operators/operatorTypes'
import {AssetSourceError} from './AssetSourceError'
import {AssetPreview} from './preview/AssetPreview'
Expand All @@ -28,7 +27,7 @@ const ContainerBox = styled(Box)`
width: min(calc(100vw - 40px), 320px);
`

export function SearchFilterAssetInput(type?: AssetType) {
export function renderSearchFilterAssetInput(type?: AssetType) {
return function FieldInputAssetWithType({
onChange,
value,
Expand All @@ -38,10 +37,6 @@ export function SearchFilterAssetInput(type?: AssetType) {
null,
)

const {
state: {fullscreen},
} = useSearchState()

const {file, image} = useSource().form
const {t} = useTranslation()

Expand Down Expand Up @@ -102,8 +97,6 @@ export function SearchFilterAssetInput(type?: AssetType) {

const AssetSourceComponent = selectedAssetSource?.component

const fontSize = fullscreen ? 2 : 1

const buttonText = t(value ? 'search.filter-asset-change' : 'search.filter-asset-select', {
context: type,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {type ReferenceValue} from '@sanity/types'

import {SearchButtonValueReference} from '../../components/filters/common/ButtonValue'
import {SearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset'
import {renderSearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset'
import {defineSearchOperator, type SearchOperatorButtonValue} from './operatorTypes'
import {toJSON} from './operatorUtils'

Expand All @@ -15,7 +15,7 @@ export const assetOperators = {
groqFilter: ({fieldPath, value}) =>
value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null,
initialValue: null,
inputComponent: SearchFilterAssetInput('file'),
inputComponent: renderSearchFilterAssetInput('file'),
label: 'is',
type: 'assetFileEqual',
}),
Expand All @@ -26,7 +26,7 @@ export const assetOperators = {
groqFilter: ({fieldPath, value}) =>
value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null,
initialValue: null,
inputComponent: SearchFilterAssetInput('file'),
inputComponent: renderSearchFilterAssetInput('file'),
label: 'is not',
type: 'assetFileNotEqual',
}),
Expand All @@ -37,7 +37,7 @@ export const assetOperators = {
groqFilter: ({fieldPath, value}) =>
value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null,
initialValue: null,
inputComponent: SearchFilterAssetInput('image'),
inputComponent: renderSearchFilterAssetInput('image'),
label: 'is',
type: 'assetImageEqual',
}),
Expand All @@ -48,7 +48,7 @@ export const assetOperators = {
groqFilter: ({fieldPath, value}) =>
value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null,
initialValue: null,
inputComponent: SearchFilterAssetInput('image'),
inputComponent: renderSearchFilterAssetInput('image'),
label: 'is not',
type: 'assetImageNotEqual',
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {type ReferenceValue} from '@sanity/types'

import {SearchButtonValueReference} from '../../components/filters/common/ButtonValue'
import {SearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset'
import {renderSearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset'
import {SearchFilterReferenceInput} from '../../components/filters/filter/inputs/reference/Reference'
import {
defineSearchOperator,
Expand Down Expand Up @@ -39,7 +39,7 @@ export const referenceOperators = {
buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue<ReferenceValue>,
groqFilter: ({value}) => (value?._ref ? `references(${toJSON(value._ref)})` : null),
initialValue: null,
inputComponent: SearchFilterAssetInput('file'),
inputComponent: renderSearchFilterAssetInput('file'),
type: 'referencesAssetFile',
}),
referencesAssetImage: defineSearchOperator({
Expand All @@ -48,7 +48,7 @@ export const referenceOperators = {
buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue<ReferenceValue>,
groqFilter: ({value}) => (value?._ref ? `references(${toJSON(value._ref)})` : null),
initialValue: null,
inputComponent: SearchFilterAssetInput('image'),
inputComponent: renderSearchFilterAssetInput('image'),
type: 'referencesAssetImage',
}),
referencesDocument: defineSearchOperator({
Expand Down

0 comments on commit 1087f55

Please sign in to comment.