Skip to content

Commit

Permalink
resolve lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
with-heart committed Sep 19, 2024
1 parent b597d16 commit 560cac9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
8 changes: 4 additions & 4 deletions packages/xstate-graph/src/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function createDefaultMachineOptions<TMachine extends AnyStateMachine>(
serializeEvent,
events: (state) => {
const events =
typeof getEvents === 'function' ? getEvents(state) : getEvents ?? [];
typeof getEvents === 'function' ? getEvents(state) : (getEvents ?? []);
return __unsafe_getAllOwnEventDescriptors(state).flatMap((type) => {
const matchingEvents = events.filter((ev) => (ev as any).type === type);
if (matchingEvents.length) {
Expand Down Expand Up @@ -128,7 +128,7 @@ export function toDirectedGraph(
return targets.map((target, targetIndex) => {
const edge: DirectedGraphEdge = {
id: `${stateNode.id}:${transitionIndex}:${targetIndex}`,
source: stateNode as AnyStateNode,
source: stateNode,
target: target as AnyStateNode,
transition: t,
label: {
Expand All @@ -148,8 +148,8 @@ export function toDirectedGraph(

const graph = {
id: stateNode.id,
stateNode: stateNode as AnyStateNode,
children: getChildren(stateNode as AnyStateNode).map(toDirectedGraph),
stateNode: stateNode,
children: getChildren(stateNode).map(toDirectedGraph),
edges,
toJSON: () => {
const { id, children, edges: graphEdges } = graph;
Expand Down
2 changes: 1 addition & 1 deletion packages/xstate-store/src/react.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useRef, useSyncExternalStore } from 'react';
import { Store, SnapshotFromStore, AnyStore } from './types';
import { SnapshotFromStore, AnyStore } from './types';

function defaultCompare<T>(a: T | undefined, b: T) {
return a === b;
Expand Down
2 changes: 1 addition & 1 deletion packages/xstate-store/src/solid.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @jsxImportSource solid-js */
import { createEffect, createSignal, onCleanup } from 'solid-js';
import type { Store, SnapshotFromStore, AnyStore } from './types';
import type { SnapshotFromStore, AnyStore } from './types';

function defaultCompare<T>(a: T | undefined, b: T) {
return a === b;
Expand Down
16 changes: 5 additions & 11 deletions packages/xstate-store/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function createStoreCore<

return {
unsubscribe() {
eventListeners!.delete(wrappedHandler);
eventListeners.delete(wrappedHandler);
}
};
},
Expand Down Expand Up @@ -434,16 +434,10 @@ export function createStoreTransition<

if (typeof assigner === 'function') {
currentContext = updater
? updater(
currentContext,
(draftContext) =>
(
assigner as StoreCompleteAssigner<
TContext,
StoreEvent,
TEmitted
>
)?.(draftContext, event, enqueue)
? updater(currentContext, (draftContext) =>
(
assigner as StoreCompleteAssigner<TContext, StoreEvent, TEmitted>
)?.(draftContext, event, enqueue)
)
: setter(currentContext, (draftContext) =>
Object.assign(
Expand Down
2 changes: 1 addition & 1 deletion packages/xstate-store/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export interface Store<

export type AnyStore = Store<any, any, any>;

export type Compute<A extends any> = { [K in keyof A]: A[K] } & unknown;
export type Compute<A> = { [K in keyof A]: A[K] };

export type SnapshotFromStore<TStore extends Store<any, any, any>> =
TStore extends Store<infer TContext, any, any>
Expand Down

0 comments on commit 560cac9

Please sign in to comment.