Skip to content

Commit

Permalink
refactor: upgrade config to remove unnecessary react imports
Browse files Browse the repository at this point in the history
  • Loading branch information
juliencrn committed Sep 30, 2022
1 parent 2b088a4 commit 9ad2eeb
Show file tree
Hide file tree
Showing 59 changed files with 79 additions and 115 deletions.
2 changes: 2 additions & 0 deletions packages/eslint-config-custom/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ module.exports = {
rules: {
'prettier/prettier': 'warn',
'react/prop-types': 'off',
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
'sort-imports': 'off',
'import/order': 'off',
'simple-import-sort/exports': 'warn',
Expand Down
2 changes: 0 additions & 2 deletions src/useBoolean/useBoolean.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useBoolean } from '..'

export default function Component() {
Expand Down
2 changes: 1 addition & 1 deletion src/useClickAnyWhere/useClickAnyWhere.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import { useState } from 'react'

import { useClickAnyWhere } from '..'

Expand Down
2 changes: 0 additions & 2 deletions src/useCopyToClipboard/useCopyToClipboard.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useCopyToClipboard } from '..'

export default function Component() {
Expand Down
2 changes: 1 addition & 1 deletion src/useCountdown/useCountdown.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ChangeEvent, useState } from 'react'
import { ChangeEvent, useState } from 'react'

import { useCountdown } from '..'

Expand Down
2 changes: 0 additions & 2 deletions src/useCounter/useCounter.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useCounter } from '..'

export default function Component() {
Expand Down
2 changes: 0 additions & 2 deletions src/useDarkMode/useDarkMode.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useDarkMode } from '..'

export default function Component() {
Expand Down
2 changes: 1 addition & 1 deletion src/useDebounce/useDebounce.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ChangeEvent, useEffect, useState } from 'react'
import { ChangeEvent, useEffect, useState } from 'react'

import { useDebounce } from '..'

Expand Down
2 changes: 0 additions & 2 deletions src/useDocumentTitle/useDocumentTitle.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useDocumentTitle } from '..'

export default function Component() {
Expand Down
2 changes: 1 addition & 1 deletion src/useDocumentTitle/useDocumentTitle.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { act, renderHook } from '@testing-library/react-hooks/dom'
import { renderHook } from '@testing-library/react-hooks/dom'

import useDocumentTitle from './useDocumentTitle'

Expand Down
2 changes: 1 addition & 1 deletion src/useEffectOnce/useEffectOnce.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'
import { useEffect, useState } from 'react'

import { useEffectOnce } from '..'

Expand Down
2 changes: 1 addition & 1 deletion src/useElementSize/useElementSize.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import { useState } from 'react'

import { useElementSize } from '..'

Expand Down
2 changes: 1 addition & 1 deletion src/useEventListener/useEventListener.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react'
import { useRef } from 'react'

import { useEventListener } from '..'

Expand Down
2 changes: 0 additions & 2 deletions src/useFetch/useFetch.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useFetch } from '..'

const url = `http://jsonplaceholder.typicode.com/posts`
Expand Down
2 changes: 1 addition & 1 deletion src/useHover/useHover.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react'
import { useRef } from 'react'

import { useHover } from '..'

Expand Down
2 changes: 1 addition & 1 deletion src/useImageOnLoad/useImageOnLoad.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { CSSProperties } from 'react'
import { CSSProperties } from 'react'

import { useImageOnLoad } from '..'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react'
import { useRef } from 'react'

import { useIntersectionObserver } from '..'

Expand Down
2 changes: 1 addition & 1 deletion src/useInterval/useInterval.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ChangeEvent, useState } from 'react'
import { ChangeEvent, useState } from 'react'

import { useInterval } from '..'

Expand Down
2 changes: 0 additions & 2 deletions src/useIsClient/useIsClient.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useIsClient } from '..'

export default function Component() {
Expand Down
2 changes: 1 addition & 1 deletion src/useIsFirstRender/useIsFirstRender.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'
import { useEffect, useState } from 'react'

import { useIsFirstRender } from '..'

Expand Down
2 changes: 1 addition & 1 deletion src/useIsMounted/useIsMounted.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'
import { useEffect, useState } from 'react'

import { useIsMounted } from '..'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useIsomorphicLayoutEffect } from '..'

export default function Component() {
Expand Down
2 changes: 0 additions & 2 deletions src/useLocalStorage/useLocalStorage.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useLocalStorage } from '..'

// Usage
Expand Down
2 changes: 1 addition & 1 deletion src/useLockedBody/useLockedBody.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { CSSProperties, useState } from 'react'
import { CSSProperties, useState } from 'react'

import { useLockedBody } from '..'

Expand Down
2 changes: 1 addition & 1 deletion src/useMap/useMap.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment } from 'react'
import { Fragment } from 'react'

import { MapOrEntries, useMap } from '..'

Expand Down
2 changes: 0 additions & 2 deletions src/useMediaQuery/useMediaQuery.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useMediaQuery } from '..'

export default function Component() {
Expand Down
2 changes: 1 addition & 1 deletion src/useOnClickOutside/useOnClickOutside.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react'
import { useRef } from 'react'

import { useOnClickOutside } from '..'

Expand Down
2 changes: 0 additions & 2 deletions src/useReadLocalStorage/useReadLocalStorage.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useReadLocalStorage } from '..'

export default function Component() {
Expand Down
2 changes: 0 additions & 2 deletions src/useScreen/useScreen.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useScreen } from '..'

export default function Component() {
Expand Down
2 changes: 1 addition & 1 deletion src/useScript/useScript.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react'
import { useEffect } from 'react'

import { useScript } from '..'

Expand Down
2 changes: 0 additions & 2 deletions src/useSessionStorage/useSessionStorage.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useSessionStorage } from '..'

export default function Component() {
Expand Down
2 changes: 0 additions & 2 deletions src/useSsr/useSsr.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useSsr } from '..'

export default function Component() {
Expand Down
2 changes: 0 additions & 2 deletions src/useStep/useStep.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useStep } from '..'

export default function Component() {
Expand Down
2 changes: 0 additions & 2 deletions src/useTernaryDarkMode/useTernaryDarkMode.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useTernaryDarkMode } from '..'

export default function Component() {
Expand Down
2 changes: 1 addition & 1 deletion src/useTimeout/useTimeout.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import { useState } from 'react'

import { useTimeout } from '..'

Expand Down
2 changes: 1 addition & 1 deletion src/useUpdateEffect/useUpdateEffect.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'
import { useEffect, useState } from 'react'

import { useUpdateEffect } from '..'

Expand Down
2 changes: 0 additions & 2 deletions src/useWindowSize/useWindowSize.demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { useWindowSize } from '..'

export default function Component() {
Expand Down
2 changes: 1 addition & 1 deletion templates/codesandbox/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"module": "commonjs",
"strict": true,
"lib": ["ESNEXT", "DOM"],
"jsx": "react",
"jsx": "react-jsx",
"esModuleInterop": true,
"isolatedModules": true
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"skipLibCheck": true,
"removeComments": true,
"esModuleInterop": true,
"jsx": "react",
"jsx": "react-jsx",
"strict": true,
"lib": ["ESNEXT", "DOM"]
},
Expand Down
15 changes: 15 additions & 0 deletions website/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,20 @@
* See: https://www.gatsbyjs.org/docs/node-apis/
*/

import { GatsbyNode } from 'gatsby'

export { createPages } from './src/gatsby/createPages'
export { onCreateNode } from './src/gatsby/onCreateNode'

// importing React in now not required since React 17 and Gatsby 2.28.1,
// but the ecosystem of plugins doesn't support it all yet
export const onCreateBabelConfig: GatsbyNode['onCreateBabelConfig'] = ({
actions,
}) => {
actions.setBabelPlugin({
name: '@babel/plugin-transform-react-jsx',
options: {
runtime: 'automatic',
},
})
}
2 changes: 1 addition & 1 deletion website/src/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import { useState } from 'react'

import FileCopyIcon from '@mui/icons-material/FileCopy'
import { IconButton } from '@mui/material'
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/backToTop.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useState } from 'react'
import { FC, useState } from 'react'

import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'
import { styled } from '@mui/material'
Expand Down
2 changes: 0 additions & 2 deletions website/src/components/code.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { styled } from '@mui/material'
import Typography from '@mui/material/Typography'
import Highlight, { defaultProps, Language } from 'prism-react-renderer'
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/hero.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import { FC } from 'react'

import { styled } from '@mui/material'
import Container from '@mui/material/Container'
Expand Down
2 changes: 0 additions & 2 deletions website/src/components/layout/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import { styled } from '@mui/material'
import Container from '@mui/material/Container'
import Hidden from '@mui/material/Hidden'
Expand Down
2 changes: 0 additions & 2 deletions website/src/components/layout/header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

import GitHubIcon from '@mui/icons-material/GitHub'
import MenuIcon from '@mui/icons-material/Menu'
import RssFeedIcon from '@mui/icons-material/RssFeed'
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/layout/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import { FC } from 'react'

import { styled, useMediaQuery, useTheme } from '@mui/material'
import CssBaseline from '@mui/material/CssBaseline'
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/layout/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react'
import { useRef } from 'react'

import ChevronLeftIcon from '@mui/icons-material/ChevronLeft'
import { styled } from '@mui/material'
Expand Down
5 changes: 2 additions & 3 deletions website/src/components/mdxRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable react/display-name */
import React, { Fragment, HTMLProps } from 'react'
import { Children, Fragment, HTMLProps } from 'react'

import { MDXProvider } from '@mdx-js/react'
import MuiDivider from '@mui/material/Divider'
Expand Down Expand Up @@ -146,7 +145,7 @@ const childrenToString = (
): string => {
let label = ''

React.Children.map(children, child => {
Children.map(children, child => {
if (typeof child === 'string') {
label += child
}
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/search/SearchModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import { useState } from 'react'

import Box from '@mui/material/Box'
import Divider from '@mui/material/Divider'
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/search/hitComps.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ComponentType } from 'react'
import { ComponentType } from 'react'

import { Divider } from '@mui/material'
import Link from '@mui/material/Link'
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/search/input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import { FC } from 'react'

import SearchIcon from '@mui/icons-material/Search'
import MuiInputBase, { InputBaseProps } from '@mui/material/InputBase'
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/seo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* See: https://www.gatsbyjs.org/docs/use-static-query/
*/

import React, { FC } from 'react'
import { FC } from 'react'

import { useLocation } from '@reach/router'

Expand Down
15 changes: 7 additions & 8 deletions website/src/libs/filterHooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HookNode } from '../models'

export interface ExtendedPost<T extends HookNode = HookNode> {
post: T
hookId: string
Expand All @@ -12,17 +13,15 @@ export function filterHook<T extends HookNode = HookNode>(
demos: HookNode[],
): ExtendedPost<T>[] {
const matchesPosts: ExtendedPost<T>[] = []
posts.forEach(post => {
const { fields } = post

// Check if have the corresponding hook
const hook = hooks.find(({ fields: { name } }) => name === fields.name)

// Check if have the corresponding hook demo
const demo = demos.find(({ fields: { name } }) => name === fields.name)
posts.forEach(post => {
// Check if have the corresponding hook and demo
const hook = hooks.find(({ fields }) => fields.name === post.fields.name)
const demo = demos.find(({ fields }) => fields.name === post.fields.name)

if (hook && demo) {
matchesPosts.push({ post, hookId: hook.id, demoId: demo.id })
const extendedPost = { post, hookId: hook.id, demoId: demo.id }
matchesPosts.push(extendedPost)
}
})

Expand Down
8 changes: 4 additions & 4 deletions website/src/libs/wrapPageElement.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { ReactNode } from 'react'
import { ReactNode } from 'react'

import TopLayout from '~/components/layout/layout'

const wrapPageElement = ({ element }: { element: ReactNode }) => {
return <TopLayout>{element}</TopLayout>
}
const wrapPageElement = ({ element }: { element: ReactNode }) => (
<TopLayout>{element}</TopLayout>
)

export default wrapPageElement
Loading

0 comments on commit 9ad2eeb

Please sign in to comment.