Skip to content

Commit 2edde05

Browse files
committed
style: 💄 fix linter issues
1 parent fe9ac5a commit 2edde05

File tree

16 files changed

+256
-529
lines changed

16 files changed

+256
-529
lines changed

biome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"useOptionalChain": "off",
4646
"noCommaOperator": "off",
4747
"noUselessLabel": "off",
48-
"noBannedTypes": "off"
48+
"noBannedTypes": "off",
49+
"noUselessUndefinedInitialization": "off"
4950
},
5051
"security": {
5152
"noGlobalEval": "off"

packages/json-joy/src/json-crdt-extensions/cnt/__demos__/usage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* npx nodemon -q -x ts-node src/json-crdt-extensions/cnt/__demos__/usage.ts
77
*/
88

9-
import {Model, s} from '../../../json-crdt';
9+
import {Model} from '../../../json-crdt';
1010
import {cnt} from '..';
1111

1212
console.clear();

packages/json-joy/src/json-crdt-extensions/peritext/editor/__tests__/Editor-merge.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {type Kit, runAlphabetKitTestSuite, setupAlphabetKit, setupKit} from '../../__tests__/setup';
1+
import {type Kit, setupAlphabetKit, setupKit} from '../../__tests__/setup';
22
import {CommonSliceType} from '../../slice';
33
import {SliceTypeCon} from '../../slice/constants';
44
import * as fixtures from './fixtures';

packages/json-joy/src/json-crdt-extensions/peritext/editor/__tests__/merge.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import type {ViewRange} from '../types';
2-
import {logTree, toTree} from 'pojo-dump';
2+
// import {logTree, toTree} from 'pojo-dump';
33
import {ModelWithExt, ext} from '../../../ModelWithExt';
44
import type {PeritextNode} from '../../PeritextNode';
55
import type {Model} from '../../../../json-crdt/model';
66
import type {ExtensionNode} from '../../../../json-crdt/schema/types';
77

8-
const normalizeViewRange = (view: ViewRange): void => {
9-
const [, offset, slices] = view;
10-
const length = slices.length;
11-
if (offset > 0) {
12-
view[1] = 0;
13-
for (let i = 0; i < length; i++) {
14-
const slice = slices[i];
15-
slice[1] += offset;
16-
slice[2] += offset;
17-
}
18-
}
19-
slices.sort((a, b) => a[1] - b[1] || a[2] - b[2] || 1);
20-
};
8+
// const normalizeViewRange = (view: ViewRange): void => {
9+
// const [, offset, slices] = view;
10+
// const length = slices.length;
11+
// if (offset > 0) {
12+
// view[1] = 0;
13+
// for (let i = 0; i < length; i++) {
14+
// const slice = slices[i];
15+
// slice[1] += offset;
16+
// slice[2] += offset;
17+
// }
18+
// }
19+
// slices.sort((a, b) => a[1] - b[1] || a[2] - b[2] || 1);
20+
// };
2121

2222
export const assertCanMergeInto = (model: Model<ExtensionNode<PeritextNode>>, view: ViewRange): void => {
2323
// logTree(view);
@@ -46,7 +46,6 @@ export const assertCanMergeIntoEmptyDocument = (view: ViewRange): void => {
4646

4747
export const assertCanMergeViewTrain = (views: ViewRange[]): void => {
4848
const model = ModelWithExt.create(ext.peritext.new(''), 1234567890123);
49-
const i = 1;
5049
for (const view of views) {
5150
// console.log(`Merging view ${i++} of ${views.length}`);
5251
assertCanMergeInto(model, view);

packages/json-joy/src/json-crdt-extensions/peritext/events/__tests__/cursor.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ const testSuite = (getKit: () => Kit) => {
373373
describe('collapses selection into the direction of movement', () => {
374374
test('when focus is at end of selection', () => {
375375
const kit = setup();
376-
const view = kit.editor.text();
376+
const _view = kit.editor.text();
377377
kit.et.cursor({at: [10, 10 + 10]});
378378
kit.et.cursor({move: [['focus', 'char', 0, true]]});
379379
expect(kit.editor.cursor.start.viewPos()).toBe(20);
@@ -386,7 +386,7 @@ const testSuite = (getKit: () => Kit) => {
386386

387387
test('when focus is at the start of the selection', () => {
388388
const kit = setup();
389-
const view = kit.editor.text();
389+
const _view = kit.editor.text();
390390
kit.et.cursor({at: [20, 20 - 10]});
391391
kit.et.cursor({move: [['end', 'char', 0, true]]});
392392
expect(kit.editor.cursor.start.viewPos()).toBe(20);

packages/json-joy/src/json-crdt-extensions/peritext/events/defaults/PeritextEventDefaults.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,34 +424,34 @@ export class PeritextEventDefaults implements PeritextEventHandlerMap {
424424
range.collapseToStart();
425425
const start = range.start;
426426
const pos = start.viewPos();
427-
let inserted: number = 0;
427+
let _inserted: number = 0;
428428
switch (format) {
429429
case 'html': {
430-
inserted = transfer.fromHtml(pos, text);
430+
_inserted = transfer.fromHtml(pos, text);
431431
break;
432432
}
433433
case 'hast': {
434434
const json = JSON.parse(text);
435-
inserted = transfer.fromHast(pos, json);
435+
_inserted = transfer.fromHast(pos, json);
436436
break;
437437
}
438438
case 'jsonml': {
439439
const json = JSON.parse(text);
440-
inserted = transfer.fromJson(pos, json);
440+
_inserted = transfer.fromJson(pos, json);
441441
break;
442442
}
443443
case 'json': {
444444
const json = JSON.parse(text);
445-
inserted = transfer.fromView(pos, json);
445+
_inserted = transfer.fromView(pos, json);
446446
break;
447447
}
448448
case 'mdast': {
449449
const json = JSON.parse(text);
450-
inserted = transfer.fromMdast(pos, json);
450+
_inserted = transfer.fromMdast(pos, json);
451451
break;
452452
}
453453
case 'md': {
454-
inserted = transfer.fromMarkdown(pos, text);
454+
_inserted = transfer.fromMarkdown(pos, text);
455455
break;
456456
}
457457
}

packages/json-joy/src/json-crdt-extensions/peritext/overlay/Overlay.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {first2, insert2, last2, next2, prev2, remove2} from 'sonic-forest/lib/ut
55
import {splay} from 'sonic-forest/lib/splay/util';
66
import {Anchor} from '../rga/constants';
77
import {OverlayPoint} from './OverlayPoint';
8-
import {OverlayRefSliceEnd, OverlayRefSliceStart} from './refs';
98
import {compare, type ITimestampStruct} from '../../../json-crdt-patch/clock';
109
import {CONST, updateNum} from '../../../json-hash/hash';
1110
import {Slice} from '../slice/Slice';
@@ -611,28 +610,24 @@ export class Overlay<T = string> implements Printable, Stateful {
611610
});
612611
}
613612
if (savedSlicesChanged || extraSlicesChanged) {
614-
// biome-ignore lint: .forEach() is the way to iterate here.
615613
savedSlices.forEach((slice) => {
616614
if (slice.isMarker()) this.upsertSlice(slice);
617615
else this.upsertSlice(slice);
618616
});
619-
// biome-ignore lint: .forEach() is the way to iterate here.
620617
extraSlices.forEach((slice) => {
621618
if (slice.isMarker()) this.upsertSlice(slice);
622619
else this.upsertSlice(slice);
623620
});
624621
}
625622
if (localSlicesChanged || savedSlicesChanged || extraSlicesChanged) {
626623
const sliceSet = this.slices;
627-
// biome-ignore lint: .forEach() is the way to iterate here.
628624
localSlices.forEach((slice) => {
629625
const tuple = sliceSet.get(slice);
630626
if (tuple) {
631627
const positionMoved = tuple[0].cmp(slice.start) !== 0 || tuple[1].cmp(slice.end) !== 0;
632628
if (positionMoved) this.delSlice(slice, tuple);
633629
}
634630
});
635-
// biome-ignore lint: .forEach() is the way to iterate here.
636631
localSlices.forEach((slice) => {
637632
const tuple = slice.isMarker() ? this.upsertSlice(slice) : this.upsertSlice(slice);
638633
this.slices.set(slice, tuple);

packages/json-joy/src/json-crdt-extensions/peritext/slice/Slices.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export class Slices<T = string> implements Stateful, Printable {
170170
}
171171

172172
public forEach(callback: (item: Slice<T>) => void): void {
173-
// biome-ignore lint: list is not iterable
174173
this.list.forEach((node) => callback(node.v));
175174
}
176175

@@ -184,19 +183,16 @@ export class Slices<T = string> implements Stateful, Printable {
184183
if (topologyHash !== this._topologyHash) {
185184
this._topologyHash = topologyHash;
186185
let chunk: ArrChunk | undefined;
187-
let order = 0;
188186
for (const iterator = this.set.iterator(); (chunk = iterator()); ) {
189187
const item = this.list.get(chunk.id);
190188
if (chunk.del) {
191189
if (item) this.list.del(chunk.id);
192190
} else {
193191
if (!item) this.list.set(chunk.id, this.unpack(this.set, chunk));
194-
order++;
195192
}
196193
}
197194
}
198195
let hash: number = topologyHash;
199-
// biome-ignore lint: slices is not iterable
200196
this.list.forEach(({v: item}) => {
201197
item.refresh();
202198
hash = updateNum(hash, item.hash);

0 commit comments

Comments
 (0)