Skip to content

Commit

Permalink
chore: fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Mar 16, 2024
1 parent 0c924ed commit 07eb391
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 52 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
],
"ignorePatterns": [
"lib/**/"
]
],
"rules": {
"react/prop-types": "off"
}
},
"dependencies": {
"@portabletext/react": "^3.0.11",
Expand All @@ -73,6 +76,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-config-sanity": "^7.1.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.2.5",
"prettier-plugin-packagejson": "^2.4.12",
"react": "^18.2.0",
Expand Down
17 changes: 15 additions & 2 deletions pnpm-lock.yaml

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

5 changes: 3 additions & 2 deletions src/components/block.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import {View, Text} from 'react-native'
import type {PortableTextComponent} from '@portabletext/react'
import type {PortableTextBlock, PortableTextBlockStyle} from '@portabletext/types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import React from 'react'
import {Text,View} from 'react-native'

import {blockStyles, textStyles} from './styles'

Expand Down
13 changes: 7 additions & 6 deletions src/components/defaults.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import type {PortableTextReactComponents} from '@portabletext/react'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import React from 'react'
import {Text} from 'react-native'
import type {PortableTextReactComponents} from '@portabletext/react'

import {defaultMarks} from './marks'
import {defaultBlockStyles} from './block'
import {DefaultList, defaultListItems} from './list'
import {defaultMarks} from './marks'
import {
DefaultUnknownType,
DefaultUnknownMark,
DefaultUnknownBlockStyle,
DefaultUnknownList,
DefaultUnknownListItem,
DefaultUnknownBlockStyle,
DefaultUnknownMark,
DefaultUnknownType,
} from './unknown'

export const DefaultHardBreak = () => <Text>{'\n'}</Text>
export const DefaultHardBreak = ():React.JSX.Element => <Text>{'\n'}</Text>

export const defaultComponents: PortableTextReactComponents = {
types: {},
Expand Down
5 changes: 3 additions & 2 deletions src/components/list.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import {View, Text} from 'react-native'
import type {PortableTextListComponent, PortableTextListItemComponent} from '@portabletext/react'
import type {PortableTextListItemType} from '@portabletext/types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import React from 'react'
import {Text,View} from 'react-native'

import {listStyles} from './styles'

Expand Down
10 changes: 6 additions & 4 deletions src/components/marks.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React, {useCallback} from 'react'
import {Text, Linking} from 'react-native'
import type {PortableTextMarkComponent} from '@portabletext/react'
import type {TypedObject} from '@portabletext/types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import React, {useCallback} from 'react'
import {Linking, Text} from 'react-native'

import {markStyles} from './styles'

interface DefaultLink extends TypedObject {
_type: 'link'
href: string
}

const link: PortableTextMarkComponent<DefaultLink> = ({children, value}) => {
const Link: PortableTextMarkComponent<DefaultLink> = ({children, value}) => {
const href = value?.href
const onPress = useCallback(() => (href ? Linking.openURL(href) : undefined), [href])

Expand All @@ -26,5 +28,5 @@ export const defaultMarks: Record<string, PortableTextMarkComponent | undefined>
code: ({children}) => <Text style={markStyles.code}>{children}</Text>,
underline: ({children}) => <Text style={markStyles.underline}>{children}</Text>,
'strike-through': ({children}) => <Text style={markStyles.strikeThrough}>{children}</Text>,
link,
link: Link,
}
6 changes: 4 additions & 2 deletions src/components/unknown.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type {PortableTextReactComponents} from '@portabletext/react'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import React from 'react'
import {Text, View} from 'react-native'
import type {PortableTextReactComponents} from '@portabletext/react'

import {DefaultBlock} from './block'
import {utilityStyles} from './styles'
import {defaultListItems} from './list'
import {utilityStyles} from './styles'

const DefaultListItem = defaultListItems.bullet || View

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from '@portabletext/react'
export {PortableText} from './react-native-portable-text'
export {defaultComponents} from './components/defaults'
export {PortableText} from './react-native-portable-text'
export * from '@portabletext/react'
9 changes: 5 additions & 4 deletions src/react-native-portable-text.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React from 'react'
import type {PortableTextProps} from '@portabletext/react'
import type {TypedObject, PortableTextBlock} from '@portabletext/types'
import {PortableText as BasePortableText, mergeComponents} from '@portabletext/react'
import {mergeComponents,PortableText as BasePortableText} from '@portabletext/react'
import type {PortableTextBlock,TypedObject} from '@portabletext/types'
import React from 'react'

import {defaultComponents} from './components/defaults'

export * from '@portabletext/react'

export function PortableText<B extends TypedObject = PortableTextBlock>(
props: Omit<PortableTextProps<B>, 'listNestingMode'>,
) {
): React.JSX.Element {
return (
<BasePortableText
{...props}
Expand Down
48 changes: 24 additions & 24 deletions test/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,38 @@ import listIssue from './060-list-issue'
import missingMarkComponent from './061-missing-mark-component'

export {
emptyBlock,
singleSpan,
multipleSpans,
basicMarkSingleSpan,
allBasicMarks,
allDefaultBlockStyles,
basicBulletList,
basicMarkMultipleAdjacentSpans,
basicMarkNestedMarks,
linkMarkDef,
plainHeaderBlock,
messyLinkText,
basicBulletList,
basicMarkSingleSpan,
basicNumberedList,
imageSupport,
materializedImageSupport,
nestedLists,
allBasicMarks,
customBlockType,
customListItemType,
customMarks,
deepWeirdLists,
allDefaultBlockStyles,
marksAllTheWayDown,
keyless,
emptyArray,
listWithoutLevel,
inlineNodes,
emptyBlock,
hardBreaks,
inlineImages,
imageSupport,
imageWithHotspot,
inlineBlockWithText,
styledListItems,
customListItemType,
customBlockType,
overrideDefaults,
customMarks,
overrideDefaultMarks,
inlineImages,
inlineNodes,
keyless,
linkMarkDef,
listIssue,
listWithoutLevel,
marksAllTheWayDown,
materializedImageSupport,
messyLinkText,
missingMarkComponent,
multipleSpans,
nestedLists,
overrideDefaultMarks,
overrideDefaults,
plainHeaderBlock,
singleSpan,
styledListItems,
}
6 changes: 4 additions & 2 deletions test/runthrough.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import React from 'react'
import {test, expect} from 'vitest'
import {View, Text} from 'react-native'
import {Text,View} from 'react-native'
import renderer from 'react-test-renderer'
import {expect,test} from 'vitest'

import {PortableText, PortableTextReactComponents} from '../src'
import * as fixtures from './fixtures'

Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import reactNative from 'vitest-react-native'
// this is needed for react jsx support
import react from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'
import reactNative from 'vitest-react-native'

export default defineConfig({
plugins: [reactNative(), react()],
Expand Down

0 comments on commit 07eb391

Please sign in to comment.