Skip to content

Commit

Permalink
chore: Upgrade Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperKozak committed Aug 4, 2023
1 parent 21d2e87 commit 33a8dc0
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 88 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"typecheck": "yarn wsrun --exclude-missing typecheck",
"lint": "eslint --ext .ts,.tsx,.js packages/*/src/",
"test": "yarn wsrun --exclude-missing test",
"format": "prettier --write \"./**/*.{js,jsx,ts,tsx,json}\"",
"prepare": "husky install"
},
"lint-staged": {
Expand All @@ -31,7 +32,7 @@
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.0",
"lint-staged": "^12.3.5",
"prettier": "^2.5.1",
"prettier": "^3.0.1",
"wsrun": "^5.2.4"
}
}
4 changes: 2 additions & 2 deletions packages/light-trails-inspector/src/el/createSeekEl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const createSeekEl = (

let seeking = false

el.onmousedown = event => {
el.onmousedown = (event) => {
seeking = true
onSeek(event.offsetX * options.scale)
}
Expand All @@ -22,7 +22,7 @@ export const createSeekEl = (
seeking = false
}

el.onmousemove = event => {
el.onmousemove = (event) => {
if (seeking) {
onSeek(event.offsetX * options.scale)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/light-trails-inspector/src/inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const inspector = (anim: LightTrailsInstance) => {
const barsWrapperEl = document.createElement('div')
const statusEl = createStatusEl()
const lineEl = createLineEl(inspectorOptions)
const seekEl = createSeekEl(inspectorOptions, off => anim.seek(off))
const seekEl = createSeekEl(inspectorOptions, (off) => anim.seek(off))

const userOptions = { ...anim.__dev.options }

Expand Down Expand Up @@ -42,7 +42,7 @@ export const inspector = (anim: LightTrailsInstance) => {

const render = () => {
barsWrapperEl.innerHTML = ''
anim.__dev.frames.forEach(frame => {
anim.__dev.frames.forEach((frame) => {
barsWrapperEl.appendChild(
createBarEl(
frame,
Expand Down
6 changes: 4 additions & 2 deletions packages/light-trails/src/lightTrails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const lightTrails = (

const findNextPauseTime = () => {
const frame = frames.find(
frame => frame.type === FrameType.Pause && frame.startAt > currentTime,
(frame) => frame.type === FrameType.Pause && frame.startAt > currentTime,
)

if (frame) return frame.startAt
Expand All @@ -139,7 +139,9 @@ export const lightTrails = (
const findPrevPauseTime = () => {
const frame = [...frames]
.reverse()
.find(frame => frame.type === FrameType.Pause && frame.startAt < currentTime)
.find(
(frame) => frame.type === FrameType.Pause && frame.startAt < currentTime,
)

if (frame) return frame.startAt
return 0
Expand Down
15 changes: 7 additions & 8 deletions packages/light-trails/src/operators/cascade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ interface CascadeOptions {
offset: (index: number) => number
}

export const cascade = (
frames: SimpleTrailFunction[],
options: CascadeOptions,
): SimpleTrailFunction => startAt =>
frames.flatMap((frameFn, index) => {
const offset = options.offset(index) + startAt
return frameFn(offset)
})
export const cascade =
(frames: SimpleTrailFunction[], options: CascadeOptions): SimpleTrailFunction =>
(startAt) =>
frames.flatMap((frameFn, index) => {
const offset = options.offset(index) + startAt
return frameFn(offset)
})
89 changes: 42 additions & 47 deletions packages/light-trails/src/operators/operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,65 +15,60 @@ export const fromTo =
easing: Easing = easeInOut,
): RenderTrailFunction =>
(startAt) =>
(renderer) =>
[
{
type: FrameType.Tween,
startAt,
startIndex: 0,
duration,
values,
renderer,
easing,
},
]
(renderer) => [
{
type: FrameType.Tween,
startAt,
startIndex: 0,
duration,
values,
renderer,
easing,
},
]

export const set =
(values: SetValues): RenderTrailFunction =>
(startAt) =>
(renderer) =>
[
{
type: FrameType.Set,
startAt,
startIndex: 0,
duration: 0,
values,
renderer,
},
]
(renderer) => [
{
type: FrameType.Set,
startAt,
startIndex: 0,
duration: 0,
values,
renderer,
},
]

export const delay =
(duration: number): SimpleTrailFunction =>
(startAt) =>
[
{
type: FrameType.Delay,
startAt,
startIndex: 0,
duration,
},
]

export const pause = (): SimpleTrailFunction => (startAt) =>
[
(startAt) => [
{
type: FrameType.Pause,
type: FrameType.Delay,
startAt,
startIndex: 0,
duration: 0,
duration,
},
]

export const pause = (): SimpleTrailFunction => (startAt) => [
{
type: FrameType.Pause,
startAt,
startIndex: 0,
duration: 0,
},
]

export const action =
(callback: (isAfter: boolean) => void): SimpleTrailFunction =>
(startAt) =>
[
{
type: FrameType.Callback,
startAt,
startIndex: 0,
duration: 0,
callback,
},
]
(startAt) => [
{
type: FrameType.Callback,
startAt,
startIndex: 0,
duration: 0,
callback,
},
]
6 changes: 4 additions & 2 deletions packages/light-trails/src/operators/parallel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { SimpleTrailFunction } from '../types'

export const parallel = (frames: SimpleTrailFunction[]): SimpleTrailFunction => startAt =>
frames.flatMap(frameFn => frameFn(startAt))
export const parallel =
(frames: SimpleTrailFunction[]): SimpleTrailFunction =>
(startAt) =>
frames.flatMap((frameFn) => frameFn(startAt))
20 changes: 10 additions & 10 deletions packages/light-trails/src/operators/sequence.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { SimpleTrailFunction } from '../types'
import { totalDuration } from '../timeline/totalDuration'

export const sequence = (
frames: SimpleTrailFunction[],
): SimpleTrailFunction => startAt => {
let offset = startAt
return frames.flatMap(frameFn => {
const frame = frameFn(offset)
offset = totalDuration(frame)
return frame
})
}
export const sequence =
(frames: SimpleTrailFunction[]): SimpleTrailFunction =>
(startAt) => {
let offset = startAt
return frames.flatMap((frameFn) => {
const frame = frameFn(offset)
offset = totalDuration(frame)
return frame
})
}
2 changes: 1 addition & 1 deletion packages/light-trails/src/timeline/totalDuration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TrailFrame } from '../types'

export const totalDuration = (frames: TrailFrame[]): number =>
Math.max(...frames.map(frame => frame.startAt + frame.duration))
Math.max(...frames.map((frame) => frame.startAt + frame.duration))
8 changes: 5 additions & 3 deletions packages/light-trails/src/values/text.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const text = (txt: string) => (n: number): string | number => {
return txt.substr(0, txt.length * n)
}
export const text =
(txt: string) =>
(n: number): string | number => {
return txt.substr(0, txt.length * n)
}
12 changes: 6 additions & 6 deletions packages/light-trails/src/values/val.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const val = (a: number, b: number, suffix?: string) => (
n: number,
): string | number => {
const val = (b - a) * n + a
return suffix ? val + suffix : val
}
export const val =
(a: number, b: number, suffix?: string) =>
(n: number): string | number => {
const val = (b - a) * n + a
return suffix ? val + suffix : val
}

export const valChain = (a: number, suffix?: string) => {
let pref = a
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5063,10 +5063,10 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"

prettier@^2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==
prettier@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.1.tgz#65271fc9320ce4913c57747a70ce635b30beaa40"
integrity sha512-fcOWSnnpCrovBsmFZIGIy9UqK2FaI7Hqax+DIO0A9UxeVoY4iweyaFjS5TavZN97Hfehph0nhsZnjlVKzEQSrQ==

pretty-format@^27.0.0, pretty-format@^27.5.1:
version "27.5.1"
Expand Down

0 comments on commit 33a8dc0

Please sign in to comment.