Skip to content

Commit

Permalink
chore: add no-console: error (#2286)
Browse files Browse the repository at this point in the history
* chore: add no-console: error

* fix prettier
  • Loading branch information
wsxiaoys authored May 29, 2024
1 parent 9464431 commit 02d401c
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 32 deletions.
3 changes: 2 additions & 1 deletion ee/tabby-ui/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
}
]
}
]
],
"no-console": "error"
},
"settings": {
"tailwindcss": {
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-ui/app/(dashboard)/profile/components/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import React from 'react'

import { Avatar } from './avatar'
import { ChangeName } from './change-name'
import { ChangePassword } from './change-password'
import { Email } from './email'
import { ProfileCard } from './profile-card'
import { ChangeName } from './change-name'

export default function Profile() {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
'use client'

import React from 'react'
import Link from 'next/link'
import { useParams } from 'next/navigation'
import { useQuery } from 'urql'

import {
RepositoryKind,
RepositoryProviderStatus
} from '@/lib/gql/generates/graphql'
import { QueryResponseData } from '@/lib/tabby/gql'
import {
listGithubRepositoryProviders,
listGithubSelfHostedRepositoryProviders,
Expand All @@ -17,10 +20,6 @@ import { buttonVariants } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import LoadingWrapper from '@/components/loading-wrapper'

import React from 'react'
import { useParams } from 'next/navigation'
import { QueryResponseData } from '@/lib/tabby/gql'

interface GitProvidersListProps {
kind: RepositoryKind
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as React from 'react'
import { zodResolver } from '@hookform/resolvers/zod'
import { useForm } from 'react-hook-form'
import { TypedDocumentNode } from 'urql'
import * as z from 'zod'

import {
Expand Down Expand Up @@ -40,11 +41,10 @@ import {

import {
updateGithubProvidedRepositoryActiveMutation,
updateGitlabProvidedRepositoryActiveMutation,
updateGithubSelfHostedProvidedRepositoryActiveMutation,
updateGitlabProvidedRepositoryActiveMutation,
updateGitlabSelfHostedProvidedRepositoryActiveMutation
} from '../query'
import { TypedDocumentNode } from 'urql'

const formSchema = z.object({
id: z.string()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
import LoadingWrapper from '@/components/loading-wrapper'
import { ListSkeleton } from '@/components/skeleton'

import { useRepositoryKind } from '../../hooks/use-repository-kind'
import {
updateGithubProvidedRepositoryActiveMutation,
updateGithubSelfHostedProvidedRepositoryActiveMutation,
Expand All @@ -65,7 +66,6 @@ import {
} from '../query'
import AddRepositoryForm from './add-repository-form'
import { UpdateProviderForm } from './update-provider-form'
import { useRepositoryKind } from '../../hooks/use-repository-kind'

const PAGE_SIZE = DEFAULT_PAGE_SIZE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import React from 'react'
import { toast } from 'sonner'
import { TypedDocumentNode } from 'urql'

import { graphql } from '@/lib/gql/generates'
import { RepositoryKind } from '@/lib/gql/generates/graphql'
import { QueryResponseData, useMutation } from '@/lib/tabby/gql'

import {
CommonProviderForm,
CreateRepositoryProviderFormValues,
useRepositoryProviderForm
} from '../../components/common-provider-form'
import { RepositoryKind } from '@/lib/gql/generates/graphql'
import { TypedDocumentNode } from 'urql'

const deleteGithubRepositoryProviderMutation = graphql(/* GraphQL */ `
mutation DeleteGithubRepositoryProvider($id: ID!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React from 'react'
import { useRouter } from 'next/navigation'
import { UseFormReturn } from 'react-hook-form'
import { TypedDocumentNode } from 'urql'

import { graphql } from '@/lib/gql/generates'
import { RepositoryKind } from '@/lib/gql/generates/graphql'
Expand All @@ -15,7 +16,6 @@ import {
useRepositoryProviderForm
} from '../../components/common-provider-form'
import { useRepositoryKind } from '../../hooks/use-repository-kind'
import { TypedDocumentNode } from 'urql'

const createGithubRepositoryProvider = graphql(/* GraphQL */ `
mutation CreateGithubRepositoryProvider(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextPage } from 'next'
import { findIndex } from 'lodash-es'

import RepositoryProvidersPage from './components/provider-list'
import { PROVIDER_KIND_METAS } from '../constants'
import RepositoryProvidersPage from './components/provider-list'

type Params = {
kind: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use client'

import React from 'react'
import Link from 'next/link'
import { useParams } from 'next/navigation'

import { RepositoryKind } from '@/lib/gql/generates/graphql'
import { IconGitHub, IconGitLab } from '@/components/ui/icons'
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'

import { PROVIDER_KIND_METAS } from '../constants'
import React from 'react'

export default function GitTabsHeader() {
const params = useParams<{ kind?: RepositoryKind }>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import {
} from '@/lib/gql/generates/graphql'
import { Button, buttonVariants } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { IconGitHub, IconGitLab, IconGoogle } from '@/components/ui/icons'
import { Skeleton } from '@/components/ui/skeleton'
import { LicenseGuard } from '@/components/license-guard'
import LoadingWrapper from '@/components/loading-wrapper'

import { PROVIDER_METAS } from './constant'
import { SSOHeader } from './sso-header'
import { IconGitHub, IconGitLab, IconGoogle } from '@/components/ui/icons'

export const oauthCredential = graphql(/* GraphQL */ `
query OAuthCredential($provider: OAuthProvider!) {
Expand Down
4 changes: 2 additions & 2 deletions ee/tabby-ui/app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
IconMail,
IconRotate,
IconSpinner,
IconVSCode,
IconUser
IconUser,
IconVSCode
} from '@/components/ui/icons'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-ui/app/auth/signin/components/signin-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { useAllowSelfSignup } from '@/lib/hooks/use-server-info'
import { useSession, useSignIn } from '@/lib/tabby/auth'
import fetcher from '@/lib/tabby/fetcher'
import {
IconGitLab,
IconGithub,
IconGitLab,
IconGoogle,
IconSpinner
} from '@/components/ui/icons'
Expand Down
6 changes: 3 additions & 3 deletions ee/tabby-ui/app/chat/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use client'

import { useRef, useState, useEffect } from 'react'
import { useEffect, useRef, useState } from 'react'
import { useSearchParams } from 'next/navigation'
import Color from 'color'
import type { ChatMessage, Context, FetcherOptions } from 'tabby-chat-panel'
import { useServer } from 'tabby-chat-panel/react'
import { useSearchParams } from 'next/navigation'

import { nanoid } from '@/lib/utils'
import { Chat, ChatRef } from '@/components/chat/chat'
import Color from 'color'

import './page.css'

Expand Down
1 change: 1 addition & 0 deletions ee/tabby-ui/app/components/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'

import { usePathname } from 'next/navigation'

import { cn } from '@/lib/utils'
import { DemoBanner } from '@/components/demo-banner'

Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-ui/app/files/components/file-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React from 'react'
import { isEmpty } from 'lodash-es'
import { useInView } from 'react-intersection-observer'
import { SWRResponse } from 'swr'
import useSWRImmutable from 'swr/immutable'

Expand All @@ -27,7 +28,6 @@ import {
resolveFileNameFromPath,
resolveRepositoryInfoFromPath
} from './utils'
import { useInView } from 'react-intersection-observer'

type TFileTreeNode = {
name: string
Expand Down
4 changes: 2 additions & 2 deletions ee/tabby-ui/app/files/components/source-code-browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,6 @@ const SourceCodeBrowserRenderer: React.FC<SourceCodeBrowserProps> = ({
}
}, [chatSideBarVisible])

console.log('repoMap', repoMap, fileTreeData)

return (
<ResizablePanelGroup
direction="horizontal"
Expand Down Expand Up @@ -576,6 +574,7 @@ async function getInitialFileData(path?: string) {

return { patchMap, expandedKeys, repos }
} catch (e) {
// eslint-disable-next-line no-console
console.error(e)
return {}
}
Expand Down Expand Up @@ -609,6 +608,7 @@ async function getInitialFileData(path?: string) {
result = defaultEntries ?? []
}
} catch (e) {
// eslint-disable-next-line no-console
console.error(e)
return result
}
Expand Down
1 change: 1 addition & 0 deletions ee/tabby-ui/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { fontMono, fontSans } from '@/lib/fonts'
import { cn } from '@/lib/utils'
import { Providers } from '@/components/providers'
import { TailwindIndicator } from '@/components/tailwind-indicator'

import Main from './components/main'

export const metadata: Metadata = {
Expand Down
6 changes: 3 additions & 3 deletions ee/tabby-ui/components/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Message } from 'ai'
import { findIndex } from 'lodash-es'
import type { Context } from 'tabby-chat-panel'

import { useDebounceCallback } from '@/lib/hooks/use-debounce'
import { useLatest } from '@/lib/hooks/use-latest'
import { filename2prism } from '@/lib/language-utils'
import {
AnswerRequest,
Expand All @@ -14,14 +16,12 @@ import {
} from '@/lib/types/chat'
import { cn, nanoid } from '@/lib/utils'

import { ListSkeleton } from '../skeleton'
import { ChatPanel } from './chat-panel'
import { ChatScrollAnchor } from './chat-scroll-anchor'
import { EmptyScreen } from './empty-screen'
import { QuestionAnswerList } from './question-answer'
import { useTabbyAnswer } from './use-tabby-answer'
import { useLatest } from '@/lib/hooks/use-latest'
import { useDebounceCallback } from '@/lib/hooks/use-debounce'
import { ListSkeleton } from '../skeleton'

type ChatContextValue = {
isLoading: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function computeDecorations(
try {
lineNumber = state.doc.lineAt(range.start)?.number ?? -1
} catch (e) {
console.log('line parse error')
// eslint-disable-next-line no-console
console.error('line parse error')
}
if (lineNumber > -1) {
temp.push({ line: lineNumber, annotation: ann })
Expand Down
4 changes: 3 additions & 1 deletion ee/tabby-ui/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ function isNewVersionAvailable(version?: string, latestRelease?: ReleaseInfo) {
try {
return version && latestRelease && compare(latestRelease.name, version, '>')
} catch (err) {
// Handle invalid semver
// eslint-disable-next-line no-console
console.warn(err)

// Handle invalid semver
return true
}
}
3 changes: 1 addition & 2 deletions ee/tabby-ui/components/user-avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import React from 'react'
import React, { ReactNode } from 'react'
import NiceAvatar, { genConfig } from 'react-nice-avatar'
import { mutate } from 'swr'
import useSWRImmutable from 'swr/immutable'
Expand All @@ -14,7 +14,6 @@ import {
AvatarImage
} from '@/components/ui/avatar'
import { Skeleton } from '@/components/ui/skeleton'
import { ReactNode } from 'react'

const NOT_FOUND_ERROR = 'not_found'
let shouldFetchAvatar = true
Expand Down
1 change: 1 addition & 0 deletions ee/tabby-ui/lib/tabby/token-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class TokenManager {
async refreshToken(doRefreshToken: () => Promise<AuthData | undefined>) {
try {
if (typeof navigator?.locks === 'undefined') {
// eslint-disable-next-line no-console
console.error(
'The Web Locks API is not supported in your browser. Please upgrade to a newer browser version.'
)
Expand Down
3 changes: 2 additions & 1 deletion ee/tabby-ui/prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('prettier').Config} */
/** @type {import("@ianvs/prettier-plugin-sort-imports").PrettierConfig} */
module.exports = {
endOfLine: 'lf',
semi: false,
Expand All @@ -7,6 +7,7 @@ module.exports = {
arrowParens: 'avoid',
tabWidth: 2,
trailingComma: 'none',
plugins: ['@ianvs/prettier-plugin-sort-imports'],
importOrder: [
'^(react/(.*)$)|^(react$)',
'^(next/(.*)$)|^(next$)',
Expand Down

0 comments on commit 02d401c

Please sign in to comment.