Skip to content

Commit

Permalink
fix(regression): output valid jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Oct 10, 2023
1 parent 770d0ce commit 36a904d
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion demo/components/AnnotatedMap.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'leaflet/dist/leaflet.css'
import React, {useEffect, useState} from 'react'
import {useEffect, useState} from 'react'
import type {ReducedLeafletApi} from './Leaflet'
import {PortableTextTypeComponent} from '../../src'

Expand Down
2 changes: 1 addition & 1 deletion demo/components/CharacterReference.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {MouseEventHandler} from 'react'
import {MouseEventHandler} from 'react'
import {Tooltip, Text, Avatar, Flex, Box, Stack} from '@sanity/ui'
import type {PortableTextMarkComponent} from '../../src'

Expand Down
1 change: 0 additions & 1 deletion demo/components/Code.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import './Code.css'
import React from 'react'
import Refractor from 'react-refractor'
import typescript from 'refractor/lang/typescript'
import {PortableTextComponent} from '../../src'
Expand Down
1 change: 0 additions & 1 deletion demo/components/CurrencyAmount.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import type {PortableTextTypeComponent} from '../../src'

const style = {background: '#eee'}
Expand Down
1 change: 0 additions & 1 deletion demo/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import {PortableTextMarkComponent} from '../../src'

interface LinkMark {
Expand Down
1 change: 0 additions & 1 deletion demo/components/LinkableHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import {PortableTextBlockComponent, toPlainText} from '../../src'

/**
Expand Down
1 change: 0 additions & 1 deletion demo/components/SchnauzerList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import type {PortableTextListComponent} from '../../src'

const size = 14
Expand Down
2 changes: 1 addition & 1 deletion demo/components/SpeechSynthesis.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback} from 'react'
import {useCallback} from 'react'
import type {PortableTextMarkComponent} from '../../src'

interface SpeechSynthesisMark {
Expand Down
2 changes: 1 addition & 1 deletion demo/components/TermDefinition.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useState} from 'react'
import {useCallback, useState} from 'react'
import {Text, Popover} from '@sanity/ui'
import type {PortableTextMarkComponent} from '../../src'

Expand Down
12 changes: 6 additions & 6 deletions demo/demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {render} from 'react-dom'
import {StrictMode} from 'react'
import {createRoot} from 'react-dom/client'
import {studioTheme, ThemeProvider} from '@sanity/ui'
import {PortableTextComponents} from '../src'
import {PortableText} from '../src/react-portable-text'
Expand Down Expand Up @@ -53,11 +53,11 @@ function Demo() {
return <PortableText value={blocks} components={ptComponents} />
}

render(
<React.StrictMode>
const root = createRoot(document.getElementById('demo-root')!)
root.render(
<StrictMode>
<ThemeProvider theme={studioTheme}>
<Demo />
</ThemeProvider>
</React.StrictMode>,
document.getElementById('demo-root'),
</StrictMode>,
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"esbuild-register": "^3.5.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-sanity": "^6.0.0",
"eslint-config-sanity": "^7.0.1",
"eslint-plugin-react": "^7.33.2",
"husky": "^8.0.3",
"leaflet": "^1.9.4",
Expand Down
26 changes: 21 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/components/defaults.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import type {PortableTextBlockStyle} from '@portabletext/types'
import type {PortableTextBlockComponent, PortableTextReactComponents} from '../types'
import {defaultMarks} from './marks'
Expand Down
1 change: 0 additions & 1 deletion src/components/list.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import type {PortableTextListComponent, PortableTextListItemComponent} from '../types'

export const defaultLists: Record<'number' | 'bullet', PortableTextListComponent> = {
Expand Down
1 change: 0 additions & 1 deletion src/components/marks.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type {TypedObject} from '@portabletext/types'
import React from 'react'
import type {PortableTextMarkComponent} from '../types'

interface DefaultLink extends TypedObject {
Expand Down
1 change: 0 additions & 1 deletion src/components/unknown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import type {PortableTextReactComponents} from '../types'
import {unknownTypeWarning} from '../warnings'

Expand Down
2 changes: 1 addition & 1 deletion src/react-portable-text.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {type ReactNode, useMemo} from 'react'
import {type ReactNode, useMemo} from 'react'
import type {ToolkitNestedPortableTextSpan, ToolkitTextNode} from '@portabletext/toolkit'
import type {
MissingComponentHandler,
Expand Down
1 change: 0 additions & 1 deletion test/components.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import ReactDOM from 'react-dom/server'
import tap from 'tap'
import {PortableTextProps} from '../src'
Expand Down
1 change: 0 additions & 1 deletion test/mutations.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import ReactDOM from 'react-dom/server'
import tap from 'tap'
import {PortableText} from '../src/react-portable-text'
Expand Down
6 changes: 3 additions & 3 deletions test/portable-text.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import {Fragment} from 'react'
import ReactDOM from 'react-dom/server'
import tap from 'tap'
import {PortableText} from '../src/react-portable-text'
Expand Down Expand Up @@ -333,8 +333,8 @@ tap.test('can specify custom component for custom block types with children', (t

return (
<p style={{background: props.value.background}}>
{props.value.children.map(({text}) => (
<React.Fragment key={text}>Customers say: {text}</React.Fragment>
{props.value.children.map(({text}: any) => (
<Fragment key={text}>Customers say: {text}</Fragment>
))}
</p>
)
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

"lib": ["ES2016", "DOM"],
"noUncheckedIndexedAccess": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
"forceConsistentCasingInFileNames": true
}
}
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"extends": "./tsconfig.settings",
"include": ["./demo", "./package.config.ts", "./package.json", "./src"],
"include": ["./demo", "./package.config.ts", "./package.json", "./src", "./test"],
"compilerOptions": {
"rootDir": ".",
"outDir": "./dist",

"lib": ["ES2016", "DOM"],
"noUncheckedIndexedAccess": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"resolveJsonModule": true
}
}
1 change: 1 addition & 0 deletions tsconfig.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"jsx": "react-jsx",

// Strict type-checking
"strict": true,
Expand Down

0 comments on commit 36a904d

Please sign in to comment.