Skip to content

Commit

Permalink
fix more lint issues in store and web sections
Browse files Browse the repository at this point in the history
  • Loading branch information
AlidotSal committed Jan 24, 2025
1 parent b49a0b9 commit 7335fb6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/solid/store/src/modifiers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setProperty, unwrap, isWrappable, StoreNode, $RAW } from "./store.js";
import { setProperty, unwrap, isWrappable, type StoreNode, $RAW } from "./store.js";

const $ROOT = Symbol("store-root");

Expand Down
6 changes: 3 additions & 3 deletions packages/solid/store/src/mutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
$RAW,
$NODE,
$HAS,
StoreNode,
type StoreNode,
setProperty,
ownKeys,
IS_DEV
Expand Down Expand Up @@ -50,7 +50,7 @@ const proxyTraps: ProxyHandler<StoreNode> = {
if (!tracked) {
const desc = Object.getOwnPropertyDescriptor(target, property);
const isFunction = typeof value === "function";
if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get))
if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc?.get))
value = getNode(nodes, property, value)();
else if (value != null && isFunction && value === Array.prototype[property as any]) {
return (...args: unknown[]) =>
Expand Down Expand Up @@ -140,7 +140,7 @@ export function createMutable<T extends StoreNode>(state: T, options?: { name?:
);

const wrappedStore = wrap(unwrappedStore);
if (IS_DEV) DEV!.registerGraph({ value: unwrappedStore, name: options && options.name });
if (IS_DEV) DEV!.registerGraph({ value: unwrappedStore, name: options?.name });
return wrappedStore;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/solid/store/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ export function updatePath(current: any, path: any[], traversed: PropertyKey[] =
updatePath(current, [part[i]].concat(path), traversed);
}
return;
} else if (isArray && partType === "function") {
} if (isArray && partType === "function") {
// Ex. update('data', i => i.id === 42, 'label', l => l + ' !!!');
for (let i = 0; i < current.length; i++) {
if (part(current[i], i)) updatePath(current, [i].concat(path), traversed);
}
return;
} else if (isArray && partType === "object") {
} if (isArray && partType === "object") {
// Ex. update('data', { from: 3, to: 12, by: 2 }, 'label', l => l + ' !!!');
const { from = 0, to = current.length - 1, by = 1 } = part;
for (let i = from; i <= to; i += by) {
updatePath(current, [i].concat(path), traversed);
}
return;
} else if (path.length > 1) {
} if (path.length > 1) {
updatePath(current[part], path, [part].concat(traversed));
return;
}
Expand Down
18 changes: 9 additions & 9 deletions packages/solid/store/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function isWrappable(obj: any) {
export function unwrap<T>(item: T, set?: Set<unknown>): T;
export function unwrap<T>(item: any, set = new Set()): T {
let result, unwrapped, v, prop;
if ((result = item != null && item[$RAW])) return result;
if ((result = item?.[$RAW])) return result;
if (!isWrappable(item) || set.has(item)) return item;

if (Array.isArray(item)) {
Expand Down Expand Up @@ -173,7 +173,7 @@ const proxyTraps: ProxyHandler<StoreNode> = {
if (
getListener() &&
(typeof value !== "function" || target.hasOwnProperty(property)) &&
!(desc && desc.get)
!(desc?.get)
)
value = getNode(nodes, property, value)();
}
Expand Down Expand Up @@ -220,14 +220,14 @@ export function setProperty(
len = state.length;

if (IS_DEV)
DevHooks.onStoreNodeUpdate && DevHooks.onStoreNodeUpdate(state, property, value, prev);
DevHooks.onStoreNodeUpdate?.(state, property, value, prev);

if (value === undefined) {
delete state[property];
if (state[$HAS] && state[$HAS][property] && prev !== undefined) state[$HAS][property].$();
if (state[$HAS]?.[property] && prev !== undefined) state[$HAS][property].$();
} else {
state[property] = value;
if (state[$HAS] && state[$HAS][property] && prev === undefined) state[$HAS][property].$();
if (state[$HAS]?.[property] && prev === undefined) state[$HAS][property].$();
}
let nodes = getNodes(state, $NODE),
node: DataNode | undefined;
Expand Down Expand Up @@ -280,20 +280,20 @@ export function updatePath(current: StoreNode, path: any[], traversed: PropertyK
updatePath(current, [part[i]].concat(path), traversed);
}
return;
} else if (isArray && partType === "function") {
} if (isArray && partType === "function") {
// Ex. update('data', i => i.id === 42, 'label', l => l + ' !!!');
for (let i = 0; i < current.length; i++) {
if (part(current[i], i)) updatePath(current, [i].concat(path), traversed);
}
return;
} else if (isArray && partType === "object") {
} if (isArray && partType === "object") {
// Ex. update('data', { from: 3, to: 12, by: 2 }, 'label', l => l + ' !!!');
const { from = 0, to = current.length - 1, by = 1 } = part;
for (let i = from; i <= to; i += by) {
updatePath(current, [i].concat(path), traversed);
}
return;
} else if (path.length > 1) {
} if (path.length > 1) {
updatePath(current[part], path, [part].concat(traversed));
return;
}
Expand Down Expand Up @@ -510,7 +510,7 @@ export function createStore<T extends object = {}>(
`Unexpected type ${typeof unwrappedStore} received when initializing 'createStore'. Expected an object.`
);
const wrappedStore = wrap(unwrappedStore);
if (IS_DEV) DEV!.registerGraph({ value: unwrappedStore, name: options && options.name });
if (IS_DEV) DEV!.registerGraph({ value: unwrappedStore, name: options?.name });
function setStore(...args: any[]): void {
batch(() => {
isArray && args.length === 1
Expand Down
4 changes: 2 additions & 2 deletions packages/solid/web/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ssrElement } from "./server.js";
import { splitProps, Component, JSX } from "solid-js";
import { splitProps, type Component, type JSX } from "solid-js";

export * from "./server";

Expand Down Expand Up @@ -28,7 +28,7 @@ export function Dynamic<T>(

if (comp) {
if (t === "function") return (comp as Function)(others);
else if (t === "string") {
if (t === "string") {
return ssrElement(comp as string, others, undefined, true);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/solid/web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {
onCleanup,
untrack,
splitProps,
JSX,
type JSX,
createRoot,
sharedConfig,
enableHydration,
$DEVCOMP,
ComponentProps,
ValidComponent,
type ComponentProps,
type ValidComponent,
createEffect,
getOwner,
runWithOwner
Expand Down

0 comments on commit 7335fb6

Please sign in to comment.