Skip to content

Commit 2725359

Browse files
committed
[lint] Address new lint defaults
1 parent 606958b commit 2725359

File tree

27 files changed

+243
-208
lines changed

27 files changed

+243
-208
lines changed

gulpfile.mjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const clearDir = async (dir = DIST_DIR) => {
8888
const makeDir = async (dir) => {
8989
try {
9090
await promises.mkdir(dir);
91-
} catch (e) {}
91+
} catch {}
9292
};
9393

9494
const ensureDir = async (fileOrDirectory) => {
@@ -111,11 +111,11 @@ const forEachDeepFile = (dir, callback, extension = '') =>
111111
const forEachDirAndFile = (dir, dirCallback, fileCallback, extension = '') =>
112112
readdirSync(dir, {withFileTypes: true}).forEach((entry) => {
113113
const path = resolve(join(dir, entry.name));
114-
entry.isDirectory()
115-
? dirCallback?.(path)
116-
: path.endsWith(extension)
117-
? fileCallback?.(path)
118-
: null;
114+
if (entry.isDirectory()) {
115+
dirCallback?.(path);
116+
} else if (path.endsWith(extension)) {
117+
fileCallback?.(path);
118+
}
119119
});
120120

121121
const copyWithReplace = async (src, [from, to], dst = src) => {
@@ -330,6 +330,7 @@ const lintCheckDocs = async (dir) => {
330330
'no-console': 0,
331331
'react/prop-types': 0,
332332
'react-hooks/rules-of-hooks': 0,
333+
'@typescript-eslint/no-unused-expressions': 0,
333334
'max-len': [
334335
2,
335336
{code: 80, ignorePattern: '^(\\s+\\* )?((im|ex)ports?|// ->)\\W.*'},

src/@types/synchronizers/synchronizer-local/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-empty-object-type */
12
/// synchronizer-local
23

34
import type {Receive, Send, Synchronizer} from '../index.d.ts';

src/@types/synchronizers/synchronizer-local/with-schemas/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-empty-object-type */
12
/// synchronizer-local
23

34
import type {Receive, Send, Synchronizer} from '../../with-schemas/index.d.ts';

src/common/listeners.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,15 @@ export const getListenerFunctions = (
222222
([listener, , path = [], pathGetters, extraArgsGetter]) => {
223223
const callWithIds = (...ids: Ids): any => {
224224
const index = size(ids);
225-
index == size(path)
226-
? (listener as any)(thing, ...ids, ...extraArgsGetter(ids))
227-
: isUndefined(path[index])
228-
? arrayForEach(pathGetters[index]?.(...ids) ?? [], (id) =>
229-
callWithIds(...ids, id),
230-
)
231-
: callWithIds(...ids, path[index] as Id);
225+
if (index == size(path)) {
226+
(listener as any)(thing, ...ids, ...extraArgsGetter(ids));
227+
} else if (isUndefined(path[index])) {
228+
arrayForEach(pathGetters[index]?.(...ids) ?? [], (id) =>
229+
callWithIds(...ids, id),
230+
);
231+
} else {
232+
callWithIds(...ids, path[index] as Id);
233+
}
232234
};
233235
callWithIds();
234236
},

src/common/map.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ export const mapToObj = <MapValue, ObjValue = MapValue>(
7575
const objValue = valueMapper
7676
? valueMapper(mapValue, id)
7777
: (mapValue as any as ObjValue);
78-
excludeObjValue?.(objValue) ? 0 : (obj[id] = objValue);
78+
if (!excludeObjValue?.(objValue)) {
79+
obj[id] = objValue;
80+
}
7981
}
8082
});
8183
return obj;

src/common/other.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export const startInterval = (
1010
sec: number,
1111
immediate?: 1,
1212
) => {
13-
immediate && callback();
13+
if (immediate) {
14+
callback();
15+
}
1416
return setInterval(callback, sec * 1000);
1517
};
1618
export const stopInterval = clearInterval;

src/persisters/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,11 @@ export const createCustomPersister = <
169169
await schedule(async () => {
170170
try {
171171
const content = await getPersisted();
172-
isArray(content)
173-
? setContentOrChanges(content)
174-
: errorNew(`Content is not an array ${content}`);
172+
if (isArray(content)) {
173+
setContentOrChanges(content);
174+
} else {
175+
errorNew(`Content is not an array ${content}`);
176+
}
175177
} catch (error) {
176178
onIgnoredError?.(error);
177179
if (initialContent) {

src/persisters/persister-partykit-server/index.ts

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,27 @@ const saveStore = async (
147147
objToArray(row, async (cell, cellId) => {
148148
const ids: [Id, Id, Id] = [tableId, rowId, cellId];
149149
const key = constructStorageKey(storagePrefix, T, ...ids);
150-
isUndefined(cell)
151-
? !initialSave &&
150+
if (isUndefined(cell)) {
151+
if (
152+
!initialSave &&
152153
(await that.canDelCell(
153154
...ids,
154155
requestOrConnection as Connection,
155-
)) &&
156-
arrayPush(keysToDel, key)
157-
: (await that.canSetCell(
158-
...ids,
159-
cell,
160-
initialSave,
161-
requestOrConnection,
162-
await storage.get(key),
163-
)) && (keysToSet[key] = cell);
156+
))
157+
) {
158+
arrayPush(keysToDel, key);
159+
}
160+
} else if (
161+
await that.canSetCell(
162+
...ids,
163+
cell,
164+
initialSave,
165+
requestOrConnection,
166+
await storage.get(key),
167+
)
168+
) {
169+
keysToSet[key] = cell;
170+
}
164171
}),
165172
)),
166173
),
@@ -171,20 +178,24 @@ const saveStore = async (
171178
await promiseAll(
172179
objToArray(changes[1], async (value, valueId) => {
173180
const key = storagePrefix + V + valueId;
174-
isUndefined(value)
175-
? !initialSave &&
176-
(await that.canDelValue(
177-
valueId,
178-
requestOrConnection as Connection,
179-
)) &&
180-
arrayPush(keysToDel, key)
181-
: (await that.canSetValue(
182-
valueId,
183-
value,
184-
initialSave,
185-
requestOrConnection,
186-
await storage.get(key),
187-
)) && (keysToSet[key] = value);
181+
if (isUndefined(value)) {
182+
if (
183+
!initialSave &&
184+
(await that.canDelValue(valueId, requestOrConnection as Connection))
185+
) {
186+
arrayPush(keysToDel, key);
187+
}
188+
} else if (
189+
await that.canSetValue(
190+
valueId,
191+
value,
192+
initialSave,
193+
requestOrConnection,
194+
await storage.get(key),
195+
)
196+
) {
197+
keysToSet[key] = value;
198+
}
188199
}),
189200
);
190201

src/store/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,11 @@ export const createStore: typeof createStoreDecl = (): Store => {
557557
cellIdsChanged(tableId, rowId, cellId, -1);
558558
mapSet(row, cellId);
559559
};
560-
isUndefined(defaultCell) ? delCell(cellId) : mapForEach(row, delCell);
560+
if (isUndefined(defaultCell)) {
561+
delCell(cellId);
562+
} else {
563+
mapForEach(row, delCell);
564+
}
561565
if (collIsEmpty(row)) {
562566
rowIdsChanged(tableId, rowId, -1);
563567
if (collIsEmpty(mapSet(table, rowId))) {

src/synchronizers/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export const ifPayloadValid = (
1414
then: (clientId: string, remainder: string) => void,
1515
) => {
1616
const splitAt = payload.indexOf(MESSAGE_SEPARATOR);
17-
splitAt !== -1
18-
? then(slice(payload, 0, splitAt), slice(payload, splitAt + 1))
19-
: 0;
17+
if (splitAt !== -1) {
18+
then(slice(payload, 0, splitAt), slice(payload, splitAt + 1));
19+
}
2020
};
2121

2222
export const receivePayload = (payload: string, receive: Receive) =>

0 commit comments

Comments
 (0)