mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
style: add prettier
This commit is contained in:
parent
306e2c1f3b
commit
289953703e
19 changed files with 37 additions and 42 deletions
|
|
@ -1,2 +1,3 @@
|
|||
*-profile/
|
||||
dist/
|
||||
vscode-icons/
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {
|
|||
patientClick,
|
||||
selectFileTreeItem,
|
||||
sleep,
|
||||
waitForLegacyPJAXRedirect
|
||||
waitForLegacyPJAXRedirect,
|
||||
} from '../../utils'
|
||||
|
||||
describe(`in Gitako project page`, () => {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
patientClick,
|
||||
selectFileTreeItem,
|
||||
sleep,
|
||||
waitForLegacyPJAXRedirect
|
||||
waitForLegacyPJAXRedirect,
|
||||
} from '../../utils'
|
||||
|
||||
describe(`in Gitako project page`, () => {
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ import {
|
|||
expectToFind,
|
||||
expectToNotFind,
|
||||
scroll,
|
||||
selectFileTreeItem
|
||||
selectFileTreeItem,
|
||||
} from '../../utils'
|
||||
|
||||
describe(`in Gitako project page`, () => {
|
||||
beforeAll(() => page.goto('https://github.com/EnixCoda/Gitako/tree/test/200-changed-files-200-lines-each'))
|
||||
beforeAll(() =>
|
||||
page.goto('https://github.com/EnixCoda/Gitako/tree/test/200-changed-files-200-lines-each'),
|
||||
)
|
||||
|
||||
it('should render Gitako', async () => {
|
||||
await expectToFind('.gitako-side-bar .gitako-side-bar-body-wrapper')
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
import {
|
||||
expectToFind,
|
||||
selectFileTreeItem,
|
||||
sleep,
|
||||
waitForLegacyPJAXRedirect
|
||||
} from '../../utils'
|
||||
import { expectToFind, selectFileTreeItem, sleep, waitForLegacyPJAXRedirect } from '../../utils'
|
||||
|
||||
describe(`in Gitako project page`, () => {
|
||||
beforeAll(() => page.goto('https://github.com/EnixCoda/Gitako/tree/develop/src'))
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ export async function listenTo<Args extends any[] = any[]>(
|
|||
(event, target, callbackName, oneTime) => {
|
||||
const t = target === 'document' ? document : window
|
||||
const onEvent = (...args: any[]): void => {
|
||||
;((window[callbackName as any] as any) as (...args: any[]) => void)(...args)
|
||||
;(window[callbackName as any] as any as (...args: any[]) => void)(...args)
|
||||
if (oneTime) t.removeEventListener(event, onEvent)
|
||||
}
|
||||
t.addEventListener(event, onEvent)
|
||||
|
|
@ -81,7 +81,9 @@ export async function patientClick(selector: string) {
|
|||
}
|
||||
|
||||
export async function expandFloatModeSidebar() {
|
||||
const rect = await (await page.$('.gitako-toggle-show-button'))?.evaluate(button => {
|
||||
const rect = await (
|
||||
await page.$('.gitako-toggle-show-button')
|
||||
)?.evaluate(button => {
|
||||
const { x, y, width, height } = button.getBoundingClientRect()
|
||||
// pass required properties to avoid serialization issues
|
||||
return { x, y, width, height }
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@ module.exports = {
|
|||
maxWorkers: 8,
|
||||
|
||||
// An array of directory names to be searched recursively up from the requiring module's location
|
||||
moduleDirectories: [
|
||||
"src",
|
||||
"node_modules"
|
||||
],
|
||||
moduleDirectories: ['src', 'node_modules'],
|
||||
|
||||
// An array of file extensions your modules use
|
||||
// moduleFileExtensions: [
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@
|
|||
"roll": "make release",
|
||||
"test": "yarn run test:parallel && yarn run test:non-parallel",
|
||||
"test:parallel": "NODE_ENV=test jest --config __tests__/jest.parallel.config.js",
|
||||
"test:non-parallel": "NODE_ENV=test jest --config __tests__/jest.non-parallel.config.js"
|
||||
"test:non-parallel": "NODE_ENV=test jest --config __tests__/jest.non-parallel.config.js",
|
||||
"format": "prettier --write '**/*.{js,jsx,ts,tsx}'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@primer/components": "^22.0.2",
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import {
|
|||
ReplyIcon as Reply,
|
||||
SearchIcon as Search,
|
||||
TabIcon as Tab,
|
||||
XIcon as X
|
||||
XIcon as X,
|
||||
} from '@primer/octicons-react'
|
||||
import * as React from 'react'
|
||||
import { cx } from 'utils/cx'
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { BranchName, Breadcrumb, Flex, Text } from '@primer/components'
|
|||
import { GitBranchIcon } from '@primer/octicons-react'
|
||||
import { platform } from 'platforms'
|
||||
import * as React from 'react'
|
||||
import { createAnchorClickHandler } from "utils/createAnchorClickHandler"
|
||||
import { createAnchorClickHandler } from 'utils/createAnchorClickHandler'
|
||||
|
||||
type Props = {
|
||||
metaData: MetaData
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ export function SideBarBodyWrapper({
|
|||
|
||||
const dummySize: [number, number] = React.useMemo(() => [size, size], [size])
|
||||
|
||||
const defaultSideBarWidth = React.useMemo(() => getDefaultConfigs().sideBarWidth, []);
|
||||
const defaultSideBarWidth = React.useMemo(() => getDefaultConfigs().sideBarWidth, [])
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import * as ReactDOM from 'react-dom'
|
|||
import {
|
||||
insertLogoMountPoint,
|
||||
insertSideBarMountPoint,
|
||||
persistGitakoElements
|
||||
persistGitakoElements,
|
||||
} from 'utils/DOMHelper'
|
||||
import './content.scss'
|
||||
|
||||
|
|
|
|||
4
src/global.d.ts
vendored
4
src/global.d.ts
vendored
|
|
@ -17,8 +17,8 @@ type TreeNode = {
|
|||
sha?: string
|
||||
accessDenied?: boolean
|
||||
comments?: {
|
||||
active: number,
|
||||
resolved: number,
|
||||
active: number
|
||||
resolved: number
|
||||
}
|
||||
diff?: {
|
||||
status: 'modified' | 'added' | 'removed' | 'renamed'
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ export function getCurrentBranch(passive = false) {
|
|||
if (title !== defaultTitle && !title.includes(' ')) return title
|
||||
}
|
||||
|
||||
const findFileButtonSelector =
|
||||
'main .file-navigation a[data-hotkey="t"]'
|
||||
const findFileButtonSelector = 'main .file-navigation a[data-hotkey="t"]'
|
||||
const urlFromFindFileButton: string | null = $(
|
||||
findFileButtonSelector,
|
||||
element => (element as HTMLAnchorElement).href,
|
||||
|
|
|
|||
|
|
@ -77,8 +77,7 @@ export async function getTreeData(
|
|||
): Promise<GiteaAPI.TreeData> {
|
||||
const search = new URLSearchParams()
|
||||
if (recursive) search.set('recursive', '1')
|
||||
const url =
|
||||
`${API_ENDPOINT}/repos/${userName}/${repoName}/git/trees/${branchName}?` + search
|
||||
const url = `${API_ENDPOINT}/repos/${userName}/${repoName}/git/trees/${branchName}?` + search
|
||||
return await request(url, { accessToken })
|
||||
}
|
||||
|
||||
|
|
@ -94,14 +93,14 @@ export async function getBlobData(
|
|||
|
||||
export async function OAuth(code: string): Promise<string | null> {
|
||||
const endpoint = `https://gitako.enix.one/oauth/gitea?`
|
||||
const res = await fetch(endpoint + new URLSearchParams({ code }).toString(), {
|
||||
method: 'post',
|
||||
})
|
||||
const res = await fetch(endpoint + new URLSearchParams({ code }).toString(), {
|
||||
method: 'post',
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
const body = await res.json()
|
||||
const accessToken = body?.accessToken
|
||||
if (typeof accessToken === 'string') return accessToken
|
||||
}
|
||||
return null
|
||||
if (res.ok) {
|
||||
const body = await res.json()
|
||||
const accessToken = body?.accessToken
|
||||
if (typeof accessToken === 'string') return accessToken
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,4 +67,4 @@ export function getCurrentPath(branchName = '') {
|
|||
return path.map(decodeURIComponent)
|
||||
}
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export class EventSubscription<Data, Listener extends VoidFN<Data> = VoidFN<Data
|
|||
export class EventHub<
|
||||
Shape extends {
|
||||
[event: string]: any
|
||||
}
|
||||
},
|
||||
> {
|
||||
ports: {
|
||||
[key in keyof Shape]: EventSubscription<Shape[key]>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ export function useResizeHandler(
|
|||
if (!pointerDown.current) return
|
||||
const [x0, y0] = initialSizeRef.current
|
||||
// Allow minor movement, this happened unintentionally for few times when I use track pad
|
||||
pointerMoved.current = pointerMoved.current || (clientX - x0) ** 2 + (clientY - y0) ** 2 > distanceTolerance ** 2
|
||||
pointerMoved.current =
|
||||
pointerMoved.current || (clientX - x0) ** 2 + (clientY - y0) ** 2 > distanceTolerance ** 2
|
||||
const [x1, y1] = baseSize.current
|
||||
onResize([x1 + clientX - x0, y1 + clientY - y0])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import * as React from 'react'
|
||||
|
||||
export function useStateIO<S>(
|
||||
initialState: S | (() => S),
|
||||
): {
|
||||
export function useStateIO<S>(initialState: S | (() => S)): {
|
||||
value: S
|
||||
onChange: React.Dispatch<React.SetStateAction<S>>
|
||||
} {
|
||||
|
|
|
|||
Loading…
Reference in a new issue