Skip to content

Commit d15decc

Browse files
Copilotstipsan
andauthored
Enable typescript/no-deprecated oxlint rule and fix violations (#310)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stipsan <81981+stipsan@users.noreply.github.com>
1 parent d487bb9 commit d15decc

4 files changed

Lines changed: 29 additions & 27 deletions

File tree

.oxlintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"no-array-sort": "off",
1818
"rules-of-hooks": "error",
1919
"react-in-jsx-scope": "off",
20+
"no-deprecated": "error",
2021
// @TODO these rules should be enabled, and the violations fixed
2122
"no-unsafe-type-assertion": "off",
2223
"no-underscore-dangle": "off"

demo/components/CharacterReference.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function CharacterCard({name, image, description}: CharacterDefinition) {
3131
<Avatar alt={name} color="magenta" src={image} size={2} />
3232
</Box>
3333
<Box flex={1}>
34-
<Stack padding={2} space={2}>
34+
<Stack padding={2} gap={2}>
3535
<Text weight="bold">{name}</Text>
3636
<Text size={1}>{description}</Text>
3737
</Stack>

demo/demo.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {type PortableTextComponents, PortableText} from '@portabletext/react'
2-
import {studioTheme, ThemeProvider} from '@sanity/ui'
2+
import {ThemeProvider} from '@sanity/ui'
3+
import {buildTheme} from '@sanity/ui/theme'
34
import {StrictMode} from 'react'
45
import {createRoot} from 'react-dom/client'
56

@@ -55,7 +56,7 @@ function Demo() {
5556
const root = createRoot(document.getElementById('demo-root')!)
5657
root.render(
5758
<StrictMode>
58-
<ThemeProvider theme={studioTheme}>
59+
<ThemeProvider theme={buildTheme()}>
5960
<Demo />
6061
</ThemeProvider>
6162
</StrictMode>,

test/typegen/typegen.test-d.tsx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -192,27 +192,27 @@ describe('PortableText component with TypeGen types', () => {
192192
block: {
193193
normal: ({value}) => {
194194
expectTypeOf(value.style).toEqualTypeOf<'normal' | undefined>()
195-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
195+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
196196
return null
197197
},
198198
h2: ({value}) => {
199199
expectTypeOf(value.style).toEqualTypeOf<'h2' | undefined>()
200-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
200+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
201201
return null
202202
},
203203
h3: ({value}) => {
204204
expectTypeOf(value.style).toEqualTypeOf<'h3' | undefined>()
205-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
205+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
206206
return null
207207
},
208208
blockquote: ({value}) => {
209209
expectTypeOf(value.style).toEqualTypeOf<'blockquote' | undefined>()
210-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
210+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
211211
return null
212212
},
213213
lead: ({value}) => {
214214
expectTypeOf(value.style).toEqualTypeOf<'lead' | undefined>()
215-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
215+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
216216
return null
217217
},
218218
},
@@ -229,8 +229,8 @@ describe('PortableText component with TypeGen types', () => {
229229
type BlockType = Extract<PostContentBlock, {_type: 'block'}>
230230
type ListItemType = NonNullable<BlockType['listItem']>
231231

232-
expectTypeOf<'checklist'>().toMatchTypeOf<ListItemType>()
233-
expectTypeOf<'steps'>().toMatchTypeOf<ListItemType>()
232+
expectTypeOf<'checklist'>().toExtend<ListItemType>()
233+
expectTypeOf<'steps'>().toExtend<ListItemType>()
234234

235235
// When passing TypeGen content to PortableText, `components.list` and
236236
// `components.listItem` should autocomplete with the block listItem union.
@@ -254,12 +254,12 @@ describe('PortableText component with TypeGen types', () => {
254254
listItem: {
255255
checklist: ({value}) => {
256256
expectTypeOf(value.listItem).toEqualTypeOf<'checklist'>()
257-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
257+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
258258
return null
259259
},
260260
steps: ({value}) => {
261261
expectTypeOf(value.listItem).toEqualTypeOf<'steps'>()
262-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
262+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
263263
return null
264264
},
265265
legacyList: ({value}) => {
@@ -346,7 +346,7 @@ describe('PortableText component with TypeGen types', () => {
346346
block: {
347347
normal: ({value}) => {
348348
expectTypeOf(value.style).toEqualTypeOf<'normal' | undefined>()
349-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
349+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
350350
return null
351351
},
352352
h2: ({value}) => {
@@ -472,7 +472,7 @@ describe('InferStrictComponents utility type', () => {
472472
// Default block styles are handled by default, so only `lead` is required.
473473
lead: ({value}) => {
474474
expectTypeOf(value.style).toEqualTypeOf<'lead' | undefined>()
475-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
475+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
476476
return null
477477
},
478478
},
@@ -758,7 +758,7 @@ describe('InferStrictComponents utility type', () => {
758758
block: {
759759
normal: ({value}) => {
760760
expectTypeOf(value.style).toEqualTypeOf<'normal' | undefined>()
761-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
761+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
762762
return null
763763
},
764764
// @ts-expect-error `h1` is not in the content type union
@@ -790,29 +790,29 @@ describe('InferValue utility type', () => {
790790
type PortableTextItem = PortableTextValue[number]
791791
type TypeNames = PortableTextItem['_type']
792792

793-
expectTypeOf<'block'>().toMatchTypeOf<TypeNames>()
794-
expectTypeOf<'image'>().toMatchTypeOf<TypeNames>()
795-
expectTypeOf<'quote'>().toMatchTypeOf<TypeNames>()
796-
expectTypeOf<'code'>().toMatchTypeOf<TypeNames>()
797-
expectTypeOf<'featuredPost'>().toMatchTypeOf<TypeNames>()
793+
expectTypeOf<'block'>().toExtend<TypeNames>()
794+
expectTypeOf<'image'>().toExtend<TypeNames>()
795+
expectTypeOf<'quote'>().toExtend<TypeNames>()
796+
expectTypeOf<'code'>().toExtend<TypeNames>()
797+
expectTypeOf<'featuredPost'>().toExtend<TypeNames>()
798798

799799
type CustomTypes = Exclude<PortableTextItem, {_type: 'block'}>
800800
expectTypeOf<Extract<CustomTypes, {_type: 'featuredPost'}>>().toHaveProperty('post')
801801

802802
type BlockType = Extract<PortableTextItem, {_type: 'block'}>
803803
type StyleType = NonNullable<BlockType['style']>
804-
expectTypeOf<'normal'>().toMatchTypeOf<StyleType>()
805-
expectTypeOf<'lead'>().toMatchTypeOf<StyleType>()
804+
expectTypeOf<'normal'>().toExtend<StyleType>()
805+
expectTypeOf<'lead'>().toExtend<StyleType>()
806806

807807
type ListItemType = NonNullable<BlockType['listItem']>
808-
expectTypeOf<'checklist'>().toMatchTypeOf<ListItemType>()
809-
expectTypeOf<'steps'>().toMatchTypeOf<ListItemType>()
808+
expectTypeOf<'checklist'>().toExtend<ListItemType>()
809+
expectTypeOf<'steps'>().toExtend<ListItemType>()
810810

811811
type MarkDefs = NonNullable<BlockType['markDefs']>
812812
type MarkType = MarkDefs[number]
813813
type MarkTypeNames = MarkType['_type']
814-
expectTypeOf<'link'>().toMatchTypeOf<MarkTypeNames>()
815-
expectTypeOf<'glossaryTerm'>().toMatchTypeOf<MarkTypeNames>()
814+
expectTypeOf<'link'>().toExtend<MarkTypeNames>()
815+
expectTypeOf<'glossaryTerm'>().toExtend<MarkTypeNames>()
816816
})
817817

818818
test('works as input to InferStrictComponents and PortableText', () => {
@@ -867,7 +867,7 @@ describe('InferValue utility type', () => {
867867
block: {
868868
lead: ({value}) => {
869869
expectTypeOf(value.style).toEqualTypeOf<'lead' | undefined>()
870-
expectTypeOf(value).toMatchTypeOf<PortableTextComponentProps<BlockType>['value']>()
870+
expectTypeOf(value).toExtend<PortableTextComponentProps<BlockType>['value']>()
871871
return null
872872
},
873873
},

0 commit comments

Comments
 (0)