Skip to content

Commit

Permalink
chore(eslint): add no-duplicates, consistent-type-imports (#219)
Browse files Browse the repository at this point in the history
* chore(eslint): add no-duplicates, consistent-type-imports

* chore(.vscode): add editor.codeActionsOnSave.source.fixAll.eslint: true

Co-authored-by: minsoo kim <[email protected]>

* chore(eslint): update to all error

* chore: update all source as eslint rule

* Create good-ads-wait.md

---------

Co-authored-by: minsoo kim <[email protected]>
  • Loading branch information
manudeli and minsoo-web authored Oct 15, 2023
1 parent 13282b6 commit 431ecb0
Show file tree
Hide file tree
Showing 33 changed files with 68 additions and 61 deletions.
6 changes: 6 additions & 0 deletions .changeset/good-ads-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@suspensive/react-query": patch
"@suspensive/react": patch
---

chore(eslint): add no-duplicates, consistent-type-imports
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"typescript.tsdk": "node_modules/typescript/lib",
"cSpell.words": ["packlint", "codecov", "tsup"]
Expand Down
3 changes: 2 additions & 1 deletion configs/eslint-config-js/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ module.exports = {
extends: ['plugin:import/recommended', './noimport.js'],
plugins: ['import'],
rules: {
'sort-imports': ['error', { ignoreDeclarationSort: true }],
'import/no-duplicates': 'error',
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling'], 'index'],
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
'sort-imports': ['error', { ignoreDeclarationSort: true }],
},
}
1 change: 1 addition & 0 deletions configs/eslint-config-ts/noimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
rules: {
'@typescript-eslint/no-empty-function': ['off'],
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'jsdoc/require-description': 'warn',
'jsdoc/require-returns': 'off',
'jsdoc/require-jsdoc': 'off',
Expand Down
1 change: 1 addition & 0 deletions configs/eslint-config-ts/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
],
rules: {
'sort-imports': ['error', { ignoreDeclarationSort: true }],
'import/no-duplicates': 'error',
'import/order': [
'error',
{
Expand Down
2 changes: 1 addition & 1 deletion configs/tsup/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from 'tsup'
import type { Options } from 'tsup'

export const options: Options = {
banner: { js: '"use client"' },
Expand Down
2 changes: 1 addition & 1 deletion configs/vitest/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path, { dirname } from 'path'
import { UserConfig } from 'vitest/config'
import type { UserConfig } from 'vitest/config'

export const forPackage = (userConfig?: UserConfig): UserConfig => {
const packageJsonPath = path.resolve(dirname('.'), 'package.json')
Expand Down
3 changes: 2 additions & 1 deletion packages/react-query/src/QueryAsyncBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AsyncBoundary } from '@suspensive/react'
import { useQueryErrorResetBoundary } from '@tanstack/react-query'
import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from 'react'
import type { ComponentPropsWithoutRef, ComponentRef } from 'react'
import { forwardRef } from 'react'

const BaseQueryAsyncBoundary = forwardRef<
ComponentRef<typeof AsyncBoundary>,
Expand Down
3 changes: 2 additions & 1 deletion packages/react-query/src/QueryErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ErrorBoundary } from '@suspensive/react'
import { useQueryErrorResetBoundary } from '@tanstack/react-query'
import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from 'react'
import type { ComponentPropsWithoutRef, ComponentRef } from 'react'
import { forwardRef } from 'react'

/**
* This component wrapping QueryErrorResetBoundary of @tanstack/react-query with @suspensive/react's ErrorBoundary.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react-hooks/rules-of-hooks */
import { InfiniteData } from '@tanstack/react-query'
import type { InfiniteData } from '@tanstack/react-query'
import { expectError, expectType } from 'tsd'
import { useSuspenseInfiniteQuery } from '../dist'

Expand Down
5 changes: 2 additions & 3 deletions packages/react-query/src/useSuspenseInfiniteQuery.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {
import type {
InfiniteData,
QueryFunction,
QueryKey,
UseInfiniteQueryOptions,
UseInfiniteQueryResult,
parseQueryArgs,
useInfiniteQuery,
} from '@tanstack/react-query'
import { parseQueryArgs, useInfiniteQuery } from '@tanstack/react-query'

export type BaseUseSuspenseInfiniteQueryResult<TData = unknown> = Omit<
UseInfiniteQueryResult<TData>,
Expand Down
5 changes: 3 additions & 2 deletions packages/react-query/src/useSuspenseQueries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult, useQueries } from '@tanstack/react-query'
import { UseSuspenseQueryResultOnLoading, UseSuspenseQueryResultOnSuccess } from './useSuspenseQuery'
import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query'
import { useQueries } from '@tanstack/react-query'
import type { UseSuspenseQueryResultOnLoading, UseSuspenseQueryResultOnSuccess } from './useSuspenseQuery'

// Avoid TS depth-limit error in case of large array literal
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down
10 changes: 2 additions & 8 deletions packages/react-query/src/useSuspenseQuery.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {
QueryFunction,
QueryKey,
UseQueryOptions,
UseQueryResult,
parseQueryArgs,
useQuery,
} from '@tanstack/react-query'
import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query'
import { parseQueryArgs, useQuery } from '@tanstack/react-query'

export interface BaseUseSuspenseQueryResult<TData = unknown>
extends Omit<UseQueryResult<TData>, 'error' | 'isError' | 'isFetching'> {
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/AsyncBoundary.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { act, render, waitFor } from '@testing-library/react'
import { ComponentProps, createElement } from 'react'
import type { ComponentProps } from 'react'
import { createElement } from 'react'
import { createRoot } from 'react-dom/client'
import { vi } from 'vitest'
import { ERROR_MESSAGE, FALLBACK, MS_100, Suspend, TEXT, ThrowError } from './utils/toTest'
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/AsyncBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ComponentProps, ComponentRef, ComponentType, SuspenseProps, forwardRef } from 'react'
import type { ComponentProps, ComponentRef, ComponentType, SuspenseProps } from 'react'
import { forwardRef } from 'react'
import { ErrorBoundary } from './ErrorBoundary'
import { Suspense } from './Suspense'
import { PropsWithoutChildren } from './types'
import type { PropsWithoutChildren } from './types'

type ErrorBoundaryProps = ComponentProps<typeof ErrorBoundary>
type AsyncBoundaryProps = Omit<SuspenseProps, 'fallback'> &
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/Delay.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ComponentProps, ComponentType, PropsWithChildren, createContext, useContext, useState } from 'react'
import type { ComponentProps, ComponentType, PropsWithChildren } from 'react'
import { createContext, useContext, useState } from 'react'
import { useSetTimeout } from './hooks'
import { PropsWithoutChildren } from './types'
import type { PropsWithoutChildren } from './types'

type DelayProps = PropsWithChildren<{
ms?: number
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/ErrorBoundary.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { act, render } from '@testing-library/react'
import { ComponentProps, ComponentRef, createElement, createRef, useEffect } from 'react'
import type { ComponentProps, ComponentRef } from 'react'
import { createElement, createRef, useEffect } from 'react'
import { createRoot } from 'react-dom/client'
import { vi } from 'vitest'
import { useSetTimeout } from './hooks'
Expand Down
12 changes: 3 additions & 9 deletions packages/react/src/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import type { ComponentProps, ComponentType, ErrorInfo, FunctionComponent, PropsWithChildren, ReactNode } from 'react'
import {
Component,
ComponentProps,
ComponentType,
ErrorInfo,
FunctionComponent,
PropsWithChildren,
ReactNode,
createContext,
createElement,
forwardRef,
Expand All @@ -16,9 +11,8 @@ import {
useState,
} from 'react'
import { ErrorBoundaryGroupContext } from './ErrorBoundaryGroup'
import { PropsWithoutChildren } from './types'
import { hasResetKeysChanged } from './utils'
import { assert } from './utils'
import type { PropsWithoutChildren } from './types'
import { assert, hasResetKeysChanged } from './utils'

export type ErrorBoundaryFallbackProps = {
/**
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/ErrorBoundaryGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ComponentProps, ComponentType, PropsWithChildren, createContext, useContext, useEffect, useMemo } from 'react'
import type { ComponentProps, ComponentType, PropsWithChildren } from 'react'
import { createContext, useContext, useEffect, useMemo } from 'react'
import { useIsChanged, useKey } from './hooks'
import { PropsWithoutChildren } from './types'
import type { PropsWithoutChildren } from './types'
import { assert } from './utils'

export const ErrorBoundaryGroupContext = createContext<{ reset: () => void; resetKey: number } | undefined>(undefined)
Expand Down
13 changes: 3 additions & 10 deletions packages/react/src/Suspense.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import {
ComponentProps,
ComponentType,
ReactNode,
Suspense as ReactSuspense,
SuspenseProps,
createContext,
useContext,
} from 'react'
import type { ComponentProps, ComponentType, ReactNode, SuspenseProps } from 'react'
import { Suspense as ReactSuspense, createContext, useContext } from 'react'
import { useIsMounted } from './hooks'
import { PropsWithoutChildren } from './types'
import type { PropsWithoutChildren } from './types'

export const SuspenseContext = createContext<PropsWithoutChildren<SuspenseProps>>({ fallback: undefined })
const useFallbackWithContext = (fallback: ReactNode) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/SuspensiveProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ContextType, PropsWithChildren, useMemo } from 'react'
import type { ContextType, PropsWithChildren } from 'react'
import { useMemo } from 'react'
import { DelayContext } from './Delay'
import { SuspenseContext } from './Suspense'

Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/experimental/Await.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FunctionComponent, createElement, useMemo } from 'react'
import type { FunctionComponent } from 'react'
import { createElement, useMemo } from 'react'
import { useSyncExternalStore } from 'use-sync-external-store/shim'
import { Tuple } from '../types'
import type { Tuple } from '../types'
import { hashKey } from '../utils'

export type Key = Tuple
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/types/PropsWithoutChildren.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { ComponentProps, ComponentType } from 'react'
import type { ComponentProps, ComponentType } from 'react'

export type PropsWithoutChildren<TProps extends ComponentProps<ComponentType>> = Omit<TProps, 'children'>
5 changes: 3 additions & 2 deletions packages/react/src/utils/hashKey.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Key } from '../experimental/Await'
import { PlainObject, isPlainObject } from './isPlainObject'
import type { Key } from '../experimental/Await'
import type { PlainObject } from './isPlainObject'
import { isPlainObject } from './isPlainObject'

export const hashKey = (key: Key) =>
JSON.stringify(key, (_, val) =>
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/utils/toTest.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PropsWithChildren, ReactNode, useState } from 'react'
import type { PropsWithChildren, ReactNode } from 'react'
import { useState } from 'react'
import { useSetTimeout } from '../hooks'

const suspendIsNeed = { current: true }
Expand Down
2 changes: 1 addition & 1 deletion websites/visualization/src/app/CommonLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Flex } from '@jsxcss/emotion'
import Image from 'next/image'
import Link from 'next/link'
import { PropsWithChildren } from 'react'
import type { PropsWithChildren } from 'react'

export const CommonLayout = ({ children }: PropsWithChildren) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion websites/visualization/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './global.css'
import { Metadata } from 'next'
import type { Metadata } from 'next'
import { CommonLayout } from './CommonLayout'
import { Providers } from './providers'

Expand Down
2 changes: 1 addition & 1 deletion websites/visualization/src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MediaQueryProvider } from '@jsxcss/emotion'
import { Suspensive, SuspensiveProvider } from '@suspensive/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import { PropsWithChildren } from 'react'
import type { PropsWithChildren } from 'react'
import { Spinner } from '~/components/uis'

const queryClient = new QueryClient({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Suspense } from '@suspensive/react'
import { useSuspenseQueries, useSuspenseQuery } from '@suspensive/react-query'
import { useEffect, useRef, useState } from 'react'
import { Post, albums, posts, todos } from './api'
import type { Post } from './api'
import { albums, posts, todos } from './api'
import { useIntersectionObserver } from './useIntersectionObserver'

export const PostListSuspensive = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Delay } from '@suspensive/react'
import { useQueries, useQuery } from '@tanstack/react-query'
import { useEffect, useRef, useState } from 'react'
import { Post, albums, posts, todos } from './api'
import type { Post } from './api'
import { albums, posts, todos } from './api'
import { useIntersectionObserver } from './useIntersectionObserver'
import { Spinner } from '~/components/uis'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use client'

import { ErrorBoundary, useErrorBoundary } from '@suspensive/react'
import { PropsWithChildren, createElement, useEffect, useState } from 'react'
import type { PropsWithChildren } from 'react'
import { createElement, useEffect, useState } from 'react'

export default function Page() {
return (
Expand Down
2 changes: 1 addition & 1 deletion websites/visualization/src/components/RejectedFallback.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { ErrorBoundaryFallbackProps } from '@suspensive/react'
import type { ErrorBoundaryFallbackProps } from '@suspensive/react'
import { Box, Button, Description } from './uis'

export const RejectedFallback = (props: ErrorBoundaryFallbackProps) => (
Expand Down
2 changes: 1 addition & 1 deletion websites/visualization/src/components/uis/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use client'

import styled from '@emotion/styled'
import { PropsWithChildren } from 'react'
import type { PropsWithChildren } from 'react'

export const Button = styled.button`
box-sizing: border-box;
Expand Down

0 comments on commit 431ecb0

Please sign in to comment.