From 33a8dc016bf60164e88311855bf1b71c621fe692 Mon Sep 17 00:00:00 2001 From: Kacper Kozak Date: Fri, 4 Aug 2023 11:32:50 +0200 Subject: [PATCH 1/2] chore: Upgrade Prettier --- package.json | 3 +- .../src/el/createSeekEl.ts | 4 +- .../light-trails-inspector/src/inspector.ts | 4 +- packages/light-trails/src/lightTrails.ts | 6 +- .../light-trails/src/operators/cascade.ts | 15 ++-- .../light-trails/src/operators/operators.ts | 89 +++++++++---------- .../light-trails/src/operators/parallel.ts | 6 +- .../light-trails/src/operators/sequence.ts | 20 ++--- .../src/timeline/totalDuration.ts | 2 +- packages/light-trails/src/values/text.ts | 8 +- packages/light-trails/src/values/val.ts | 12 +-- yarn.lock | 8 +- 12 files changed, 89 insertions(+), 88 deletions(-) diff --git a/package.json b/package.json index d8dc7db..3071bff 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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" } } diff --git a/packages/light-trails-inspector/src/el/createSeekEl.ts b/packages/light-trails-inspector/src/el/createSeekEl.ts index f0f31ff..2ab4c12 100644 --- a/packages/light-trails-inspector/src/el/createSeekEl.ts +++ b/packages/light-trails-inspector/src/el/createSeekEl.ts @@ -13,7 +13,7 @@ export const createSeekEl = ( let seeking = false - el.onmousedown = event => { + el.onmousedown = (event) => { seeking = true onSeek(event.offsetX * options.scale) } @@ -22,7 +22,7 @@ export const createSeekEl = ( seeking = false } - el.onmousemove = event => { + el.onmousemove = (event) => { if (seeking) { onSeek(event.offsetX * options.scale) } diff --git a/packages/light-trails-inspector/src/inspector.ts b/packages/light-trails-inspector/src/inspector.ts index c159af3..1bf4c9f 100644 --- a/packages/light-trails-inspector/src/inspector.ts +++ b/packages/light-trails-inspector/src/inspector.ts @@ -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 } @@ -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, diff --git a/packages/light-trails/src/lightTrails.ts b/packages/light-trails/src/lightTrails.ts index d7188e6..51b448f 100644 --- a/packages/light-trails/src/lightTrails.ts +++ b/packages/light-trails/src/lightTrails.ts @@ -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 @@ -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 diff --git a/packages/light-trails/src/operators/cascade.ts b/packages/light-trails/src/operators/cascade.ts index 888663d..3c30be9 100644 --- a/packages/light-trails/src/operators/cascade.ts +++ b/packages/light-trails/src/operators/cascade.ts @@ -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) + }) diff --git a/packages/light-trails/src/operators/operators.ts b/packages/light-trails/src/operators/operators.ts index 802cbbf..5120003 100644 --- a/packages/light-trails/src/operators/operators.ts +++ b/packages/light-trails/src/operators/operators.ts @@ -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, + }, + ] diff --git a/packages/light-trails/src/operators/parallel.ts b/packages/light-trails/src/operators/parallel.ts index 5d6c4ab..933e474 100644 --- a/packages/light-trails/src/operators/parallel.ts +++ b/packages/light-trails/src/operators/parallel.ts @@ -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)) diff --git a/packages/light-trails/src/operators/sequence.ts b/packages/light-trails/src/operators/sequence.ts index 3b49c87..a03d932 100644 --- a/packages/light-trails/src/operators/sequence.ts +++ b/packages/light-trails/src/operators/sequence.ts @@ -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 + }) + } diff --git a/packages/light-trails/src/timeline/totalDuration.ts b/packages/light-trails/src/timeline/totalDuration.ts index 200d81f..52d6423 100644 --- a/packages/light-trails/src/timeline/totalDuration.ts +++ b/packages/light-trails/src/timeline/totalDuration.ts @@ -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)) diff --git a/packages/light-trails/src/values/text.ts b/packages/light-trails/src/values/text.ts index b3b501c..33d699c 100644 --- a/packages/light-trails/src/values/text.ts +++ b/packages/light-trails/src/values/text.ts @@ -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) + } diff --git a/packages/light-trails/src/values/val.ts b/packages/light-trails/src/values/val.ts index 1380fe8..9c3c081 100644 --- a/packages/light-trails/src/values/val.ts +++ b/packages/light-trails/src/values/val.ts @@ -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 diff --git a/yarn.lock b/yarn.lock index 3ab53e0..2f3a16d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" From 76249a096ea96054a9324c2454189a576534e97b Mon Sep 17 00:00:00 2001 From: Kacper Kozak Date: Fri, 4 Aug 2023 11:34:47 +0200 Subject: [PATCH 2/2] chore: Upgrade node verison --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d431f7..40b371a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x] + node-version: [16.x] steps: - uses: actions/checkout@v2