Skip to content

Commit 124810c

Browse files
committed
chore(json-crdt-peritext-ui): 🤖 fix all formatting and linter errors
1 parent 241e830 commit 124810c

File tree

7 files changed

+33
-33
lines changed

7 files changed

+33
-33
lines changed

src/json-crdt-extensions/peritext/__tests__/Peritext.render-block.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,17 @@ runInlineSlicesTests('text with block split', (editor: Editor) => {
220220
runInlineSlicesTests('text with deletes', (editor: Editor) => {
221221
editor.insert('lmXXXnwYxyz');
222222
editor.cursor.setAt(2, 3);
223-
editor.cursor.delBwd();
223+
editor.cursor.del();
224224
editor.cursor.setAt(3);
225225
editor.insert('opqrstuv');
226226
editor.cursor.setAt(12, 1);
227-
editor.cursor.delBwd();
227+
editor.cursor.del();
228228
editor.cursor.setAt(0);
229229
editor.insert('ab1c3defghijk4444');
230230
editor.cursor.setAt(2, 1);
231-
editor.cursor.delBwd();
231+
editor.cursor.del();
232232
editor.cursor.setAt(3, 1);
233-
editor.cursor.delBwd();
233+
editor.cursor.del();
234234
editor.cursor.setAt(11, 4);
235-
editor.cursor.delBwd();
235+
editor.cursor.del();
236236
});

src/json-crdt-extensions/peritext/editor/Cursor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export class Cursor<T = string> extends PersistedSlice<T> {
1010

1111
/** @todo Rename to `isStartFocus`. */
1212
public isStartFocused(): boolean {
13-
return this.type === CursorAnchor.End || (this.start.cmp(this.end) === 0);
13+
return this.type === CursorAnchor.End || this.start.cmp(this.end) === 0;
1414
}
1515

1616
/** @todo Rename to `isEndFocus`. */
1717
public isEndFocused(): boolean {
18-
return this.type === CursorAnchor.Start || (this.start.cmp(this.end) === 0);
18+
return this.type === CursorAnchor.Start || this.start.cmp(this.end) === 0;
1919
}
2020

2121
// ---------------------------------------------------------------- mutations
@@ -105,8 +105,8 @@ export class Cursor<T = string> extends PersistedSlice<T> {
105105
this.collapse();
106106
return;
107107
}
108-
let point1 = this.start.clone();
109-
let point2 = point1.clone();
108+
const point1 = this.start.clone();
109+
const point2 = point1.clone();
110110
if (step > 0) point2.step(1);
111111
else if (step < 0) point1.step(-1);
112112
else if (step === 0) {

src/json-crdt-extensions/peritext/editor/Editor.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ export class Editor<T = string> {
5151
*/
5252
public get cursor(): Cursor<T> {
5353
let cursor: Cursor<T> | undefined;
54-
for (let i: Cursor<T> | undefined, iterator = this.cursors0(); i = iterator();)
55-
if (!cursor) cursor = i; else this.local.del(i);
54+
for (let i: Cursor<T> | undefined, iterator = this.cursors0(); (i = iterator()); )
55+
if (!cursor) cursor = i;
56+
else this.local.del(i);
5657
return cursor ?? this.addCursor(this.txt.rangeAt(0));
5758
}
5859

@@ -65,15 +66,15 @@ export class Editor<T = string> {
6566
}
6667

6768
public cursors(callback: (cursor: Cursor<T>) => void): void {
68-
for (let cursor: Cursor<T> | undefined, iterator = this.cursors0(); cursor = iterator();) callback(cursor);
69+
for (let cursor: Cursor<T> | undefined, iterator = this.cursors0(); (cursor = iterator()); ) callback(cursor);
6970
}
7071

7172
public delCursor(cursor: Cursor<T>): void {
7273
this.local.del(cursor);
7374
}
7475

7576
public delCursors(): void {
76-
for (let cursor: Cursor<T> | undefined, iterator = this.cursors0(); cursor = iterator();) this.delCursor(cursor);
77+
for (let cursor: Cursor<T> | undefined, iterator = this.cursors0(); (cursor = iterator()); ) this.delCursor(cursor);
7778
}
7879

7980
// ------------------------------------------------------------- text editing
@@ -325,7 +326,8 @@ export class Editor<T = string> {
325326
else for (let i = 0; i < -steps; i++) point = this.bob(point);
326327
return point;
327328
}
328-
case 'all': return steps > 0 ? this.end() : this.start();
329+
case 'all':
330+
return steps > 0 ? this.end() : this.start();
329331
}
330332
}
331333

@@ -341,7 +343,8 @@ export class Editor<T = string> {
341343
this.cursors((cursor) => {
342344
let point = endpoint === 0 ? cursor.focus() : cursor.anchor();
343345
point = this.skip(point.clone(), steps, unit);
344-
if (collapse) cursor.set(point); else cursor.setEndpoint(point, endpoint);
346+
if (collapse) cursor.set(point);
347+
else cursor.setEndpoint(point, endpoint);
345348
});
346349
}
347350

@@ -366,7 +369,7 @@ export class Editor<T = string> {
366369
*/
367370
public rangeWord(point: Point<T>): Range<T> | undefined {
368371
const char = point.rightChar() || point.leftChar();
369-
if (!char) return
372+
if (!char) return;
370373
const c = String(char.view())[0];
371374
const predicate: CharPredicate<string> = isLetter(c) ? isLetter : isWhitespace(c) ? isWhitespace : isPunctuation;
372375
const start = this.bow(point, predicate, true);
@@ -390,9 +393,10 @@ export class Editor<T = string> {
390393
}
391394

392395
public select(unit: TextRangeUnit): void {
393-
this.cursors(cursor => {
396+
this.cursors((cursor) => {
394397
const range = this.range(cursor.start, unit);
395-
if (range) cursor.setRange(range); else this.delCursors
398+
if (range) cursor.setRange(range);
399+
else this.delCursors;
396400
});
397401
}
398402

@@ -430,11 +434,7 @@ export class Editor<T = string> {
430434
// ------------------------------------------------------------------ various
431435

432436
public point(at: Position<T>): Point<T> {
433-
return typeof at === 'number'
434-
? this.txt.pointAt(at)
435-
: Array.isArray(at)
436-
? this.txt.pointAt(at[0], at[1])
437-
: at;
437+
return typeof at === 'number' ? this.txt.pointAt(at) : Array.isArray(at) ? this.txt.pointAt(at[0], at[1]) : at;
438438
}
439439

440440
public end(): Point<T> {

src/json-crdt-extensions/peritext/editor/__tests__/Editor-movement.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ describe('.eow()', () => {
130130
});
131131

132132
test('can select a character', () => {
133-
const {editor, peritext} = setup((editor) =>
134-
editor.insert('x a x'),
135-
);
133+
const {editor, peritext} = setup((editor) => editor.insert('x a x'));
136134
const point1 = peritext.pointAt(2);
137135
const point2 = editor.eow(point1);
138136
expect(point1.id.sid).toBe(point2!.id.sid);

src/json-crdt-extensions/peritext/editor/__tests__/Editor-selection.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ describe('.range()', () => {
154154
const range3 = editor.range(peritext.pointAt(20), 'word');
155155
expect(range3?.text()).toBe('setup');
156156
});
157-
157+
158158
test('can select punctuation', () => {
159159
const {editor, peritext} = setup((editor) => {
160160
editor.insert("const {editor} = setup(editor => editor.insert('Hello world!'));");
@@ -166,7 +166,7 @@ describe('.range()', () => {
166166
const range1 = editor.range(peritext.pointAt(30), 'word');
167167
expect(range1?.text()).toBe('=>');
168168
});
169-
169+
170170
test('can select punctuation at the end of text', () => {
171171
const {editor, peritext} = setup((editor) => {
172172
editor.insert("const {editor} = setup(editor => editor.insert('Hello world!'));");
@@ -177,7 +177,7 @@ describe('.range()', () => {
177177
const range2 = editor.range(peritext.pointAt(peritext.str.length() - 3), 'word');
178178
expect(range2?.text()).toBe("!'));");
179179
});
180-
180+
181181
test('can select whitespace', () => {
182182
const {editor, peritext} = setup((editor) => {
183183
editor.insert("const {editor} = setup(editor => editor.insert('Hello world!'));");

src/json-crdt-extensions/peritext/rga/__tests__/Point.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,8 @@ describe('.halfstep()', () => {
11641164
test('can reach the end of str', () => {
11651165
const {peritext} = setupWithChunkedText();
11661166
const p = peritext.pointAt(0, Anchor.After);
1167-
const endReached = p.halfstep(1) || p.halfstep(2) || p.halfstep(3) || p.halfstep(4) || p.halfstep(5) || p.halfstep(6);
1167+
const endReached =
1168+
p.halfstep(1) || p.halfstep(2) || p.halfstep(3) || p.halfstep(4) || p.halfstep(5) || p.halfstep(6);
11681169
expect(endReached).toBe(true);
11691170
expect(p.isAbsEnd()).toBe(true);
11701171
expect(p.viewPos()).toBe(9);
@@ -1190,7 +1191,7 @@ describe('.halfstep()', () => {
11901191
const points: Point[] = [];
11911192
let point: Point | undefined = peritext.pointAbsStart();
11921193
while (point) {
1193-
let nextPoint = point.clone();
1194+
const nextPoint = point.clone();
11941195
const endReached = nextPoint.halfstep(1);
11951196
if (endReached) {
11961197
point = undefined;
@@ -1215,7 +1216,7 @@ describe('.halfstep()', () => {
12151216
const points: Point[] = [];
12161217
let point: Point | undefined = peritext.pointAbsEnd();
12171218
while (point) {
1218-
let nextPoint = point.clone();
1219+
const nextPoint = point.clone();
12191220
const endReached = nextPoint.halfstep(-1);
12201221
if (endReached) {
12211222
point = undefined;

tslint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"no-angle-bracket-type-assertion": false,
1313
"ban-comma-operator": false,
1414
"no-unused-expression": false,
15-
"no-implicit-dependencies": false
15+
"no-implicit-dependencies": false,
16+
"adjacent-overload-signatures": false
1617
}
1718
}

0 commit comments

Comments
 (0)