Add eslint to @sd/client & fix types

This commit is contained in:
Utku Bakir 2022-12-14 13:10:42 +03:00
parent 959783b08a
commit f7afb9ac2b
6 changed files with 15 additions and 8 deletions

View file

@ -0,0 +1,7 @@
module.exports = {
...require('@sd/config/eslint-react.js'),
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json'
}
};

View file

@ -8,7 +8,7 @@
], ],
"scripts": { "scripts": {
"test": "jest", "test": "jest",
"lint": "TIMING=1 eslint src --fix", "lint": "eslint src/**/*.{ts,tsx} && tsc --noEmit",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist" "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
}, },
"dependencies": { "dependencies": {

View file

@ -1,5 +1,5 @@
import { PropsWithChildren, createContext, useCallback, useContext, useMemo } from 'react'; import { PropsWithChildren, createContext, useCallback, useContext, useMemo } from 'react';
import { proxy, subscribe, useSnapshot } from 'valtio'; import { subscribe, useSnapshot } from 'valtio';
import { useBridgeQuery } from '../rspc'; import { useBridgeQuery } from '../rspc';
import { valtioPersist } from '../stores'; import { valtioPersist } from '../stores';
@ -81,7 +81,7 @@ export const useCurrentLibrary = () => {
} }
return current; return current;
}, [libraries, currentLibraryUuid]); // TODO: This runs when the 'libraries' change causing the whole app to re-render which is cringe. }, [libraries, currentLibraryUuid, switchLibrary]); // TODO: This runs when the 'libraries' change causing the whole app to re-render which is cringe.
return { return {
library, library,

View file

@ -10,7 +10,7 @@ export function normiCustomHooks(
{ contextSharing }: NormiOptions, { contextSharing }: NormiOptions,
nextHooks?: () => CustomHooks nextHooks?: () => CustomHooks
): () => CustomHooks { ): () => CustomHooks {
let normiCache = getNormiCache(contextSharing ?? false); const normiCache = getNormiCache(contextSharing ?? false);
const next = nextHooks?.(); const next = nextHooks?.();
// TODO: Handle manual modifications to the query cache // TODO: Handle manual modifications to the query cache

View file

@ -6,8 +6,8 @@ export type OmitDistributive<T, K extends PropertyKey> = T extends any
? Id<OmitRecursively<T, K>> ? Id<OmitRecursively<T, K>>
: T : T
: never; : never;
export type Id<T> = {} & { [P in keyof T]: T[P] }; // Cosmetic use only makes the tooltips expand the type can be removed export type Id<T> = object & { [P in keyof T]: T[P] }; // Cosmetic use only makes the tooltips expand the type can be removed
export type OmitRecursively<T extends any, K extends PropertyKey> = Omit< export type OmitRecursively<T, K extends PropertyKey> = Omit<
{ [P in keyof T]: OmitDistributive<T[P], K> }, { [P in keyof T]: OmitDistributive<T[P], K> },
K K
>; >;

View file

@ -59,7 +59,7 @@ export function normaliseValueForStorage(value: any, rootElem: boolean): any {
} else if (typeof value === 'object') { } else if (typeof value === 'object') {
if ('$id' in value && '$type' in value) { if ('$id' in value && '$type' in value) {
if (rootElem) { if (rootElem) {
let v = Object.assign({}, value); const v = Object.assign({}, value);
delete v.$id; delete v.$id;
delete v.$type; delete v.$type;
@ -144,7 +144,7 @@ export function loadDataFromCache(value: any, normiCache: NormiCache): any {
} else if (typeof value === 'object') { } else if (typeof value === 'object') {
if ('$id' in value && '$type' in value) { if ('$id' in value && '$type' in value) {
// if (rootElem) { // if (rootElem) {
let v = Object.assign({}, value); const v = Object.assign({}, value);
delete v.$id; delete v.$id;
delete v.$type; delete v.$type;