From 16397ce3ee32d5f27417aa6661eb786b01eb3bbb Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Tue, 30 Aug 2022 14:16:29 -0400 Subject: [PATCH] prettier --- Taskfile.yaml | 6 +++--- src/Updux.js | 24 ++++++++++++------------ src/initial.test.js | 12 +++++++----- src/reactions.test.js | 4 ++-- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index c0dbd7b..e97b9a2 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -24,15 +24,15 @@ tasks: lint:delta: cmds: - - task: 'lint:prettier:delta' - - task: 'lint:eslint:delta' + - task: 'lint:prettier:delta' + - task: 'lint:eslint:delta' lint:prettier:delta: vars: FILES: sh: git diff-ls --diff-filter=d {{.ROOT_BRANCH | default "main"}} | grep -v .vitebook cmds: - - npx prettier --check {{.FILES | catLines }} + - npx prettier --check {{.FILES | catLines }} lint:eslint:delta: vars: diff --git a/src/Updux.js b/src/Updux.js index 18bdd7d..b32af1d 100644 --- a/src/Updux.js +++ b/src/Updux.js @@ -76,10 +76,11 @@ export class Updux { } get initial() { - if (Object.keys(this.#subduxes).length === 0) return this.#localInitial ?? {}; + if (Object.keys(this.#subduxes).length === 0) + return this.#localInitial ?? {}; - if( this.#subduxes['*'] ) { - if( this.#localInitial ) return this.#localInitial; + if (this.#subduxes['*']) { + if (this.#localInitial) return this.#localInitial; return []; } @@ -183,19 +184,18 @@ export class Updux { this.#effects = [...this.#effects, [action, effect]]; } - addReaction( reaction ) { - this.#localReactions = [ ...this.#localReactions, reaction ] + addReaction(reaction) { + this.#localReactions = [...this.#localReactions, reaction]; } subscribeTo(store, subscription) { const localStore = augmentMiddlewareApi( { ...store, - subscribe: (subscriber) => - this.subscribeTo(store, subscriber), // TODO not sure + subscribe: (subscriber) => this.subscribeTo(store, subscriber), // TODO not sure }, this.actions, - this.selectors + this.selectors, ); const subscriber = subscription(localStore); @@ -221,7 +221,7 @@ export class Updux { subscribeAll(store) { let results = this.#localReactions.map((sub) => - this.subscribeTo(store, sub) + this.subscribeTo(store, sub), ); for (const subdux in this.#subduxes) { @@ -237,10 +237,10 @@ export class Updux { return { unsub: () => results.forEach(({ unsub }) => unsub()), subscriberMemoized: () => - results.forEach(({ subscriberMemoized}) => subscriberMemoized()), - subscriber: () => - results.forEach(({ subscriber }) => subscriber() + results.forEach(({ subscriberMemoized }) => + subscriberMemoized(), ), + subscriber: () => results.forEach(({ subscriber }) => subscriber()), }; } } diff --git a/src/initial.test.js b/src/initial.test.js index abbfd50..0aa2a85 100644 --- a/src/initial.test.js +++ b/src/initial.test.js @@ -26,7 +26,7 @@ test('initial value', () => { }); }); -test( "splat initial", async () => { +test('splat initial', async () => { const bar = new Updux({ initial: { id: 0 }, }); @@ -37,8 +37,10 @@ test( "splat initial", async () => { expect(foo.initial).toEqual([]); - expect( new Updux({ - initial: 'overriden', - subduxes: { '*': bar }, - }).initial ).toEqual('overriden'); + expect( + new Updux({ + initial: 'overriden', + subduxes: { '*': bar }, + }).initial, + ).toEqual('overriden'); }); diff --git a/src/reactions.test.js b/src/reactions.test.js index 225b2c7..8b17efb 100644 --- a/src/reactions.test.js +++ b/src/reactions.test.js @@ -30,7 +30,7 @@ test('subduxes reactions', async () => { subduxes: { a: new Updux({ initial: 1, - reactions: [() => state => spyA(state)], + reactions: [() => (state) => spyA(state)], actions: { inc: null }, mutations: { inc: () => (state) => state + 1, @@ -45,6 +45,6 @@ test('subduxes reactions', async () => { store.dispatch.inc(); expect(spyA).toHaveBeenCalledTimes(2); - expect(spyA).toHaveBeenCalledWith(3) + expect(spyA).toHaveBeenCalledWith(3); expect(spyB).toHaveBeenCalledOnce(); // the original inc initialized the state });