mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-18 21:19:13 +00:00
Add eslint to @sd/client & fix types
This commit is contained in:
parent
959783b08a
commit
f7afb9ac2b
7
packages/client/.eslintrc.js
Normal file
7
packages/client/.eslintrc.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module.exports = {
|
||||||
|
...require('@sd/config/eslint-react.js'),
|
||||||
|
parserOptions: {
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
|
project: './tsconfig.json'
|
||||||
|
}
|
||||||
|
};
|
|
@ -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": {
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
>;
|
>;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue