style: add prettier

This commit is contained in:
lazzzis 2022-07-05 11:06:55 -07:00
parent 306e2c1f3b
commit 289953703e
19 changed files with 37 additions and 42 deletions

View file

@ -1,2 +1,3 @@
*-profile/
dist/
vscode-icons/

View file

@ -4,7 +4,7 @@ import {
patientClick,
selectFileTreeItem,
sleep,
waitForLegacyPJAXRedirect
waitForLegacyPJAXRedirect,
} from '../../utils'
describe(`in Gitako project page`, () => {

View file

@ -5,7 +5,7 @@ import {
patientClick,
selectFileTreeItem,
sleep,
waitForLegacyPJAXRedirect
waitForLegacyPJAXRedirect,
} from '../../utils'
describe(`in Gitako project page`, () => {

View file

@ -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')

View file

@ -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'))

View file

@ -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 }

View file

@ -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: [

View file

@ -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",

View file

@ -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'

View file

@ -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

View file

@ -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

View file

@ -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
View file

@ -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'

View file

@ -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,

View file

@ -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
}

View file

@ -67,4 +67,4 @@ export function getCurrentPath(branchName = '') {
return path.map(decodeURIComponent)
}
return []
}
}

View file

@ -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]>

View file

@ -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])
}

View file

@ -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>>
} {