Skip to content

Commit

Permalink
Upgrade prettier, update prettier & react-hooks eslint plugins (#456)
Browse files Browse the repository at this point in the history
Re-ran prettier with latest version
  • Loading branch information
jlfwong committed Dec 26, 2023
1 parent c296f53 commit 1717fec
Show file tree
Hide file tree
Showing 20 changed files with 1,486 additions and 220 deletions.
1,540 changes: 1,384 additions & 156 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
"acorn": "7.2.0",
"aphrodite": "2.1.0",
"eslint": "8.0.0",
"eslint-plugin-prettier": "2.6.0",
"eslint-plugin-react-hooks": "4.0.2",
"eslint-plugin-prettier": "5.1.2",
"eslint-plugin-react-hooks": "4.6.0",
"jest": "24.3.0",
"jsverify": "0.8.3",
"jszip": "3.1.5",
"pako": "1.0.6",
"parcel-bundler": "1.12.4",
"preact": "10.4.1",
"prettier": "2.0.4",
"prettier": "3.1.1",
"protobufjs": "6.8.8",
"source-map": "0.6.1",
"ts-jest": "24.3.0",
Expand Down
5 changes: 4 additions & 1 deletion src/gl/flamechart-color-pass-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ export class FlamechartColorPassRenderer {
private material: Graphics.Material
private buffer: Graphics.VertexBuffer

constructor(private gl: Graphics.Context, theme: Theme) {
constructor(
private gl: Graphics.Context,
theme: Theme,
) {
const vertices = [
{pos: [-1, 1], uv: [0, 1]},
{pos: [1, 1], uv: [1, 1]},
Expand Down
5 changes: 4 additions & 1 deletion src/gl/overlay-rectangle-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export class ViewportRectangleRenderer {
private material: Graphics.Material
private buffer: Graphics.VertexBuffer

constructor(private gl: Graphics.Context, theme: Theme) {
constructor(
private gl: Graphics.Context,
theme: Theme,
) {
const vertices = [
[-1, 1],
[1, 1],
Expand Down
10 changes: 8 additions & 2 deletions src/import/callgrind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ class CallGraph {
private totalWeights = new Map<Frame, number>()
private childrenTotalWeights = new Map<Frame, Map<Frame, number>>()

constructor(private fileName: string, private fieldName: string) {}
constructor(
private fileName: string,
private fieldName: string,
) {}

private getOrInsertFrame(info: FrameInfo): Frame {
return Frame.getOrInsert(this.frameSet, info)
Expand Down Expand Up @@ -345,7 +348,10 @@ class CallgrindParser {
private savedFileNames: {[id: string]: string} = {}
private savedFunctionNames: {[id: string]: string} = {}

constructor(contents: TextFileContent, private importedFileName: string) {
constructor(
contents: TextFileContent,
private importedFileName: string,
) {
this.lines = [...contents.splitLines()]
this.lineNum = 0
}
Expand Down
7 changes: 5 additions & 2 deletions src/import/instruments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class ZipBackedFileSystemEntry implements Omit<FileSystemEntry, 'filesystem' | '
private zipDir: any | null
private zipFile: JSZip.JSZipObject | null

constructor(private zip: JSZip, fullPath: string) {
constructor(
private zip: JSZip,
fullPath: string,
) {
this.fullPath = fullPath

this.zipFile = zip.file(fullPath)
Expand Down Expand Up @@ -75,7 +78,7 @@ class ZipBackedFileSystemEntry implements Omit<FileSystemEntry, 'filesystem' | '
const ret: FileSystemEntry[] = []
this.zipDir.forEach((relativePath: string, file: {name: string}) => {
if (relativePath.split('/').length === (relativePath.endsWith('/') ? 2 : 1)) {
ret.push((new ZipBackedFileSystemEntry(this.zip, file.name) as any) as FileSystemEntry)
ret.push(new ZipBackedFileSystemEntry(this.zip, file.name) as any as FileSystemEntry)
}
})
cb(ret)
Expand Down
5 changes: 4 additions & 1 deletion src/import/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ export class StringBackedTextFileContent implements TextFileContent {
}

export class TextProfileDataSource implements ProfileDataSource {
constructor(private fileName: string, private contents: string) {}
constructor(
private fileName: string,
private contents: string,
) {}
async name() {
return this.fileName
}
Expand Down
4 changes: 2 additions & 2 deletions src/import/v8proflog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ function codeToFrameInfo(code: Code, v8log: V8LogProfile): FrameInfo {
matches[1].length > 0
? matches[1]
: file
? `(anonymous ${file.split('/').pop()}:${line})`
: '(anonymous)'
? `(anonymous ${file.split('/').pop()}:${line})`
: '(anonymous)'
return {
key: name,
name: functionName,
Expand Down
5 changes: 4 additions & 1 deletion src/lib/atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ if (process.env.NODE_ENV === 'development') {

export class Atom<T> {
private observers: AtomListener[] = []
constructor(protected state: T, debugKey: string) {
constructor(
protected state: T,
debugKey: string,
) {
if (process.env.NODE_ENV === 'development') {
if (hotReloadStash?.has(debugKey)) {
// If we have a stored value from a previous hot reload, use that
Expand Down
16 changes: 8 additions & 8 deletions src/lib/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export class Color {
hPrime < 1
? [C, X, 0]
: hPrime < 2
? [X, C, 0]
: hPrime < 3
? [0, C, X]
: hPrime < 4
? [0, X, C]
: hPrime < 5
? [X, 0, C]
: [C, 0, X]
? [X, C, 0]
: hPrime < 3
? [0, C, X]
: hPrime < 4
? [0, X, C]
: hPrime < 5
? [X, 0, C]
: [C, 0, X]

const m = L - (0.3 * R1 + 0.59 * G1 + 0.11 * B1)

Expand Down
10 changes: 8 additions & 2 deletions src/lib/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ export function clamp(x: number, minVal: number, maxVal: number) {
}

export class Vec2 {
constructor(readonly x: number, readonly y: number) {}
constructor(
readonly x: number,
readonly y: number,
) {}
withX(x: number) {
return new Vec2(x, this.y)
}
Expand Down Expand Up @@ -251,7 +254,10 @@ export class AffineTransform {
}

export class Rect {
constructor(readonly origin: Vec2, readonly size: Vec2) {}
constructor(
readonly origin: Vec2,
readonly size: Vec2,
) {}

isEmpty() {
return this.width() == 0 || this.height() == 0
Expand Down
10 changes: 8 additions & 2 deletions src/lib/profile-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export function exactMatchStrings(text: string, pattern: string): [number, numbe
// A utility class for storing cached search results to avoid recomputation when
// the search results & profile did not change.
export class ProfileSearchResults {
constructor(readonly profile: Profile, readonly searchQuery: string) {}
constructor(
readonly profile: Profile,
readonly searchQuery: string,
) {}

private matches: Map<Frame, [number, number][] | null> | null = null
getMatchForFrame(frame: Frame): [number, number][] | null {
Expand All @@ -65,7 +68,10 @@ interface CachedFlamechartResult {
}

export class FlamechartSearchResults {
constructor(readonly flamechart: Flamechart, readonly profileResults: ProfileSearchResults) {}
constructor(
readonly flamechart: Flamechart,
readonly profileResults: ProfileSearchResults,
) {}

private matches: CachedFlamechartResult | null = null
private getResults(): CachedFlamechartResult {
Expand Down
5 changes: 4 additions & 1 deletion src/lib/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ export class CallTreeNode extends HasWeights {
this.frozen = true
}

constructor(readonly frame: Frame, readonly parent: CallTreeNode | null) {
constructor(
readonly frame: Frame,
readonly parent: CallTreeNode | null,
) {
super()
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/lib/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ class Panel {
private GRAPH_WIDTH = 74 * PR
private GRAPH_HEIGHT = 30 * PR

constructor(private name: string, private fg: string, private bg: string) {
constructor(
private name: string,
private fg: string,
private bg: string,
) {
this.canvas.width = this.WIDTH
this.canvas.height = this.HEIGHT
this.canvas.style.cssText = 'width:80px;height:48px'
Expand Down
5 changes: 4 additions & 1 deletion src/lib/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ test('getOrInsert', () => {
})

class ValueType {
private constructor(readonly a: string, readonly num: number) {}
private constructor(
readonly a: string,
readonly num: number,
) {}
get key() {
return `${this.a}_${this.num}`
}
Expand Down
20 changes: 9 additions & 11 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,15 @@ export function lazyStatic<T>(cb: () => T): () => T {
}
}

const base64lookupTable = lazyStatic(
(): Map<string, number> => {
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
const ret = new Map<string, number>()
for (let i = 0; i < alphabet.length; i++) {
ret.set(alphabet.charAt(i), i)
}
ret.set('=', -1)
return ret
},
)
const base64lookupTable = lazyStatic((): Map<string, number> => {
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
const ret = new Map<string, number>()
for (let i = 0; i < alphabet.length; i++) {
ret.set(alphabet.charAt(i), i)
}
ret.set('=', -1)
return ret
})

// NOTE: There are probably simpler solutions to this problem, but I have this written already, so
// until we run into problems with this, let's just use this.
Expand Down
8 changes: 4 additions & 4 deletions src/views/application-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import {Application} from './application'
export const ApplicationContainer = memo(() => {
const canvas = useAtom(glCanvasAtom)
const theme = useTheme()
const canvasContext = useMemo(() => (canvas ? getCanvasContext({theme, canvas}) : null), [
theme,
canvas,
])
const canvasContext = useMemo(
() => (canvas ? getCanvasContext({theme, canvas}) : null),
[theme, canvas],
)

return (
<ProfileSearchContextProvider>
Expand Down
5 changes: 2 additions & 3 deletions src/views/flamechart-minimap-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ export class FlamechartMinimapView extends Component<FlamechartMinimapViewProps,
const logicalSpaceMouse = this.windowToLogicalViewSpace().transformPosition(
new Vec2(ev.clientX, ev.clientY),
)
const physicalSpaceMouse = this.logicalToPhysicalViewSpace().transformPosition(
logicalSpaceMouse,
)
const physicalSpaceMouse =
this.logicalToPhysicalViewSpace().transformPosition(logicalSpaceMouse)
return this.configSpaceToPhysicalViewSpace().inverseTransformPosition(physicalSpaceMouse)
}

Expand Down
20 changes: 8 additions & 12 deletions src/views/flamechart-pan-zoom-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,10 @@ export class FlamechartPanZoomView extends Component<FlamechartPanZoomViewProps,
private zoom(logicalViewSpaceCenter: Vec2, multiplier: number) {
this.interactionLock = 'zoom'

const physicalCenter = this.logicalToPhysicalViewSpace().transformPosition(
logicalViewSpaceCenter,
)
const configSpaceCenter = this.configSpaceToPhysicalViewSpace().inverseTransformPosition(
physicalCenter,
)
const physicalCenter =
this.logicalToPhysicalViewSpace().transformPosition(logicalViewSpaceCenter)
const configSpaceCenter =
this.configSpaceToPhysicalViewSpace().inverseTransformPosition(physicalCenter)
if (!configSpaceCenter) return

const zoomTransform = AffineTransform.withTranslation(configSpaceCenter.times(-1))
Expand Down Expand Up @@ -633,12 +631,10 @@ export class FlamechartPanZoomView extends Component<FlamechartPanZoomViewProps,
}

const logicalViewSpaceMouse = new Vec2(ev.offsetX, ev.offsetY)
const physicalViewSpaceMouse = this.logicalToPhysicalViewSpace().transformPosition(
logicalViewSpaceMouse,
)
const configSpaceMouse = this.configSpaceToPhysicalViewSpace().inverseTransformPosition(
physicalViewSpaceMouse,
)
const physicalViewSpaceMouse =
this.logicalToPhysicalViewSpace().transformPosition(logicalViewSpaceMouse)
const configSpaceMouse =
this.configSpaceToPhysicalViewSpace().inverseTransformPosition(physicalViewSpaceMouse)

if (!configSpaceMouse) return

Expand Down
14 changes: 8 additions & 6 deletions src/views/profile-table-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,14 @@ export const ProfileTableView = memo(
[sandwichContext],
)

const onTotalClick = useCallback((ev: MouseEvent) => onSortClick(SortField.TOTAL, ev), [
onSortClick,
])
const onSelfClick = useCallback((ev: MouseEvent) => onSortClick(SortField.SELF, ev), [
onSortClick,
])
const onTotalClick = useCallback(
(ev: MouseEvent) => onSortClick(SortField.TOTAL, ev),
[onSortClick],
)
const onSelfClick = useCallback(
(ev: MouseEvent) => onSortClick(SortField.SELF, ev),
[onSortClick],
)
const onSymbolNameClick = useCallback(
(ev: MouseEvent) => onSortClick(SortField.SYMBOL_NAME, ev),
[onSortClick],
Expand Down

0 comments on commit 1717fec

Please sign in to comment.