Skip to content

style: force import type usage and add jsx-runtime rules #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ module.exports = {
env: {
browser: true, es6: true
},
extends: ['eslint:recommended', 'plugin:react/recommended', 'standard'],
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'standard'
],
globals: {
Atomics: 'readonly', SharedArrayBuffer: 'readonly'
},
Expand Down Expand Up @@ -75,6 +80,7 @@ module.exports = {
delimiter: 'semi', requireLast: false
}
}],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports', disallowTypeAnnotations: false }],
'@typescript-eslint/explicit-function-return-type': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
Expand Down
5 changes: 3 additions & 2 deletions docs/components/JsonViewerPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { JsonViewer, JsonViewerProps } from '@textea/json-viewer'
import type React from 'react'
import type { JsonViewerProps } from '@textea/json-viewer'
import { JsonViewer } from '@textea/json-viewer'
import React from 'react'

export const JsonViewerPreview: React.FC<JsonViewerProps> = (props) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'nextra-theme-docs/style.css'

import type { AppProps } from 'next/app'
import type React from 'react'
import React from 'react'

export default function Nextra ({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
Expand Down
13 changes: 7 additions & 6 deletions docs/pages/full/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ import {
Toolbar,
Typography
} from '@mui/material'
import {
applyValue,
createDataType,
JsonViewer,
import type {
JsonViewerKeyRenderer,
JsonViewerOnChange,
JsonViewerTheme
} from '@textea/json-viewer'
import {
applyValue,
createDataType,
JsonViewer
} from '@textea/json-viewer'
import Image from 'next/image'
import type React from 'react'
import { useCallback, useEffect, useState } from 'react'
import React, { useCallback, useEffect, useState } from 'react'

import { ocean } from '../../lib/shared'

Expand Down
3 changes: 2 additions & 1 deletion src/browser.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { createRoot, Root } from 'react-dom/client'
import type { Root } from 'react-dom/client'
import { createRoot } from 'react-dom/client'

import { JsonViewer as JsonViewerComponent } from '.'
import type { JsonViewerProps } from './type'
Expand Down
3 changes: 1 addition & 2 deletions src/components/DataKeyPair.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Box, styled } from '@mui/material'
import type React from 'react'
import { useCallback, useMemo, useState } from 'react'
import React, { useCallback, useMemo, useState } from 'react'

import { useTextColor } from '../hooks/useColor'
import { useClipboard } from '../hooks/useCopyToClipboard'
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataTypeLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type React from 'react'
import React from 'react'

import { DataBox } from './mui/DataBox'

Expand Down
2 changes: 1 addition & 1 deletion src/components/DataTypes/Function.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Because in Next.js SSR, the function will be translated to other type
*/
import { Box, NoSsr } from '@mui/material'
import type React from 'react'
import React from 'react'

import { useJsonViewerStore } from '../../stores/JsonViewerStore'
import type { DataItemProps } from '../../type'
Expand Down
5 changes: 3 additions & 2 deletions src/components/Icons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SvgIcon, SvgIconProps } from '@mui/material'
import type React from 'react'
import type { SvgIconProps } from '@mui/material'
import { SvgIcon } from '@mui/material'
import React from 'react'

const BaseIcon: React.FC<SvgIconProps> = ({ d, ...props }) => {
return (
Expand Down
1 change: 0 additions & 1 deletion src/components/mui/DataBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Box, styled } from '@mui/material'
import type React from 'react'

export const DataBox = styled(props => <Box component='div' {...props}/>)`
display: inline-block;
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/useInspect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
import type {
Dispatch,
SetStateAction,
SetStateAction
} from 'react'
import {
useCallback,
useEffect,
useState
Expand Down
3 changes: 1 addition & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import {
createTheme, Paper,
ThemeProvider
} from '@mui/material'
import type React from 'react'
import { useCallback, useEffect, useMemo, useRef } from 'react'
import React, { useCallback, useEffect, useMemo, useRef } from 'react'

import { DataKeyPair } from './components/DataKeyPair'
import { useThemeDetector } from './hooks/useThemeDetector'
Expand Down
3 changes: 2 additions & 1 deletion src/stores/typeRegistry.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box } from '@mui/material'
import React, { memo, SetStateAction, useMemo, useState } from 'react'
import type { SetStateAction } from 'react'
import React, { memo, useMemo, useState } from 'react'
import create from 'zustand'
import createStore from 'zustand/context'
import { combine } from 'zustand/middleware'
Expand Down
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
"jsxImportSource": "@emotion/react",
"incremental": false,
"declaration": true,
"moduleResolution": "node",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*.ts"
],
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}