Skip to content

Commit 82026c8

Browse files
committed
style: 💄 fix linter issues
1 parent f20c7ae commit 82026c8

File tree

12 files changed

+71
-57
lines changed

12 files changed

+71
-57
lines changed

src/json-crdt-patch/codec/verbose/__tests__/encode.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ test('can encode "upd_arr" operation', () => {
4141
const encoded = encode(builder.patch);
4242
expect(encoded).toEqual({
4343
id: [5, 28],
44-
ops: [
45-
{op: 'upd_arr', obj: [5, 25], ref: [5, 26], value: [5, 27]},
46-
],
44+
ops: [{op: 'upd_arr', obj: [5, 25], ref: [5, 26], value: [5, 27]}],
4745
});
4846
});

src/json-crdt-patch/enums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const enum JsonCrdtPatchOpcode {
6161
ins_str = 0b01000 | JsonCrdtDataType.str, // 12
6262
ins_bin = 0b01000 | JsonCrdtDataType.bin, // 13
6363
ins_arr = 0b01000 | JsonCrdtDataType.arr, // 14
64-
upd_arr = 0b01000 | JsonCrdtDataType.arr + 1, // 15
64+
upd_arr = 0b01000 | (JsonCrdtDataType.arr + 1), // 15
6565
del = 0b10000, // 16
6666
nop = 0b10001, // 17
6767
}

src/json-crdt-patch/operations.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,7 @@ export class InsStrOp extends Op implements IJsonCrdtPatchEditOperation {
225225
}
226226

227227
public toString(): string {
228-
return super.toString() + `, obj = ${printTs(
229-
this.obj,
230-
)} { ${printTs(this.ref)}${JSON.stringify(this.data)} }`;
228+
return super.toString() + `, obj = ${printTs(this.obj)} { ${printTs(this.ref)}${JSON.stringify(this.data)} }`;
231229
}
232230
}
233231

@@ -299,7 +297,7 @@ export class InsArrOp extends Op implements IJsonCrdtPatchEditOperation {
299297
const obj = printTs(this.obj);
300298
const ref = printTs(this.ref);
301299
const data = this.data.map(printTs).join(', ');
302-
return super.toString() + ', obj = ' + obj + ' { ' + ref + ' ← ' + data + ' }';
300+
return super.toString() + ', obj = ' + obj + ' { ' + ref + ' ← ' + data + ' }';
303301
}
304302
}
305303

@@ -310,10 +308,10 @@ export class InsArrOp extends Op implements IJsonCrdtPatchEditOperation {
310308
*/
311309
export class UpdArrOp extends Op implements IJsonCrdtPatchEditOperation {
312310
/**
313-
* @param id ID of this operation.
314-
* @param obj and "arr" object ID where to update an element.
315-
* @param ref ID of the element to update.
316-
* @param val ID of the new value to set.
311+
* @param id ID of this operation.
312+
* @param obj and "arr" object ID where to update an element.
313+
* @param ref ID of the element to update.
314+
* @param val ID of the new value to set.
317315
*/
318316
constructor(
319317
public readonly id: ITimestampStruct,
@@ -332,7 +330,7 @@ export class UpdArrOp extends Op implements IJsonCrdtPatchEditOperation {
332330
const obj = printTs(this.obj);
333331
const ref = printTs(this.ref);
334332
const val = printTs(this.val);
335-
return super.toString() + ', obj = ' + obj + ' { ' + ref + ': ' + val + ' }';
333+
return super.toString() + ', obj = ' + obj + ' { ' + ref + ': ' + val + ' }';
336334
}
337335
}
338336

src/json-crdt/__tests__/fuzzer/SessionLogical.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class SessionLogical {
161161
const opcode = this.fuzzer.picker.pickArrayOperation(node);
162162
const builder = new PatchBuilder(model.clock);
163163
const length = node.length();
164-
if (!length || (opcode === InsArrOp)) {
164+
if (!length || opcode === InsArrOp) {
165165
const json = RandomJson.generate({nodeCount: Math.ceil(Math.random() * 5)});
166166
const valueId = builder.json(json);
167167
if (!length) builder.insArr(node.id, node.id, [valueId]);

src/json-crdt/equal/__tests__/index.spec.ts

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,42 +47,51 @@ describe('equalSchema(), with content comparison', () => {
4747
});
4848

4949
test('returns false for slightly different nodes', () => {
50-
assertSchemasDifferent({
51-
foo: 'bar',
52-
num: 123,
53-
obj: {key: 'value'},
54-
arr: [1, 2, 3],
55-
bool: true,
56-
}, {
57-
foo: 'bar',
58-
num: 124,
59-
obj: {key: 'value'},
60-
arr: [1, 2, 3],
61-
bool: true,
62-
});
50+
assertSchemasDifferent(
51+
{
52+
foo: 'bar',
53+
num: 123,
54+
obj: {key: 'value'},
55+
arr: [1, 2, 3],
56+
bool: true,
57+
},
58+
{
59+
foo: 'bar',
60+
num: 124,
61+
obj: {key: 'value'},
62+
arr: [1, 2, 3],
63+
bool: true,
64+
},
65+
);
6366
});
6467

6568
test('returns false for slightly different nodes - 2', () => {
66-
assertSchemasDifferent({
67-
foo: 'baz',
68-
num: 123,
69-
obj: {key: 'value'},
70-
arr: [1, 2, 3],
71-
bool: true,
72-
}, {
73-
foo: 'baz',
74-
num: 123,
75-
obj: {key: 'valee'},
76-
arr: [1, 2, 3],
77-
bool: true,
78-
});
69+
assertSchemasDifferent(
70+
{
71+
foo: 'baz',
72+
num: 123,
73+
obj: {key: 'value'},
74+
arr: [1, 2, 3],
75+
bool: true,
76+
},
77+
{
78+
foo: 'baz',
79+
num: 123,
80+
obj: {key: 'valee'},
81+
arr: [1, 2, 3],
82+
bool: true,
83+
},
84+
);
7985
});
8086

8187
test('returns false for slightly different nodes - 3', () => {
82-
assertSchemasDifferent({
83-
bin: new Uint8Array([1, 2, 3]),
84-
}, {
85-
bin: new Uint8Array([1, 0, 3]),
86-
});
88+
assertSchemasDifferent(
89+
{
90+
bin: new Uint8Array([1, 2, 3]),
91+
},
92+
{
93+
bin: new Uint8Array([1, 0, 3]),
94+
},
95+
);
8796
});
8897
});

src/json-crdt/equal/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {deepEqual} from '@jsonjoy.com/util/lib/json-equal/deepEqual';
2-
import {ArrNode, BinNode, ConNode, JsonNode, ObjNode, StrNode, ValNode, VecNode} from '../nodes';
2+
import {ArrNode, BinNode, ConNode, type JsonNode, ObjNode, StrNode, ValNode, VecNode} from '../nodes';
33

44
/**
55
* Deeply checks if two JSON nodes have the same schema and values. Does not
@@ -14,7 +14,8 @@ export const equalSchema = <A extends JsonNode<any>>(a: A, b: unknown, compareCo
1414
if (a === b) return true;
1515
if (a instanceof ConNode) return b instanceof ConNode && (!compareContent || deepEqual(a.val, b.val));
1616
else if (a instanceof ValNode) return b instanceof ValNode && equalSchema(a.node(), b.node(), compareContent);
17-
else if (a instanceof StrNode) return b instanceof StrNode && (!compareContent || (a.length() === b.length() && a.view() === b.view()));
17+
else if (a instanceof StrNode)
18+
return b instanceof StrNode && (!compareContent || (a.length() === b.length() && a.view() === b.view()));
1819
else if (a instanceof ObjNode) {
1920
if (!(b instanceof ObjNode)) return false;
2021
const keys1 = a.keys;

src/json-crdt/model/Model.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ export class Model<N extends JsonNode = JsonNode<any>> implements Printable {
133133
? new clock.ServerClockVector(SESSION.SERVER, 1)
134134
: new clock.ClockVector(sidOrClock, 1)
135135
: sidOrClock;
136-
type Node = undefined extends S ? JsonNode : S extends NodeBuilder ? SchemaToJsonNode<S> : SchemaToJsonNode<nodes.json<S>>;
136+
type Node = undefined extends S
137+
? JsonNode
138+
: S extends NodeBuilder
139+
? SchemaToJsonNode<S>
140+
: SchemaToJsonNode<nodes.json<S>>;
137141
const model: Model<Node> = new Model<Node>(cl);
138142
if (schema !== void 0) model.setSchema(schema instanceof NodeBuilder ? schema : s.json(schema), true);
139143
return model;

src/json-crdt/model/__tests__/Model.array.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ describe('Document', () => {
671671
doc.applyPatch(patch);
672672
expect(doc.view()).toEqual([1, 0, 3]);
673673
});
674-
674+
675675
test('removes subtree replaced by the latest op', () => {
676676
const doc = Model.create([1, {foo: [1, 2, 3]}, 3]);
677677
const node = doc.root.child();

src/json-crdt/model/__tests__/Model.schema.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ describe('.create<Schema>()', () => {
7373
const model = Model.create({
7474
key1: 'value1',
7575
key2: {
76-
key3: [{
77-
foo: 'bar',
78-
}],
76+
key3: [
77+
{
78+
foo: 'bar',
79+
},
80+
],
7981
},
8082
});
8183
expect(model.$.key2.key3[0].foo.$?.view()).toBe('bar');

src/json-crdt/model/api/__tests__/ArrayApi.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {nodes, s} from '../../../../json-crdt-patch';
1+
import {type nodes, s} from '../../../../json-crdt-patch';
22
import {Model} from '../../Model';
33

44
test('can insert a value and delete all previous ones', () => {

0 commit comments

Comments
 (0)