Skip to content

Commit 0be3182

Browse files
committed
style: 💄 fix linter issues
1 parent 3c4a344 commit 0be3182

File tree

7 files changed

+64
-47
lines changed

7 files changed

+64
-47
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,12 @@ export class Editor<T = string> implements Printable {
919919
} else this.setStartMarker(type, data, slices);
920920
}
921921

922-
public updMarkerAt(point: Point<T>, type: SliceTypeSteps, data?: unknown, slices: EditorSlices<T> = this.saved): void {
922+
public updMarkerAt(
923+
point: Point<T>,
924+
type: SliceTypeSteps,
925+
data?: unknown,
926+
slices: EditorSlices<T> = this.saved,
927+
): void {
923928
const overlay = this.txt.overlay;
924929
const markerPoint = overlay.getOrNextLowerMarker(point);
925930
if (markerPoint) {

src/json-crdt-extensions/peritext/events/__tests__/format.spec.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {color} from 'nano-theme';
22
import {type Kit, runAlphabetKitTestSuite} from '../../../../json-crdt-extensions/peritext/__tests__/setup';
33
import {ArrApi, ObjApi} from '../../../../json-crdt/model';
4-
import { SliceTypeCon } from '../../slice/constants';
4+
import {SliceTypeCon} from '../../slice/constants';
55
import {PersistedSlice} from '../../slice/PersistedSlice';
6-
import { getEventsKit } from './setup';
6+
import {getEventsKit} from './setup';
77

88
const testSuite = (getKit: () => Kit) => {
99
const setup = () => getEventsKit(getKit);
@@ -100,7 +100,7 @@ const testSuite = (getKit: () => Kit) => {
100100
kit.et.format({action: 'ins', type: SliceTypeCon.b});
101101
kit.et.cursor({at: [10, 20]});
102102
kit.et.format({action: 'ins', type: SliceTypeCon.i});
103-
kit.et.cursor({at: [0]})
103+
kit.et.cursor({at: [0]});
104104
expect(kit.toHtml()).toBe('<p>abcde<b>fghij</b><i><b>klmno</b></i><i>pqrst</i>uvwxyz</p>');
105105
const slice = kit.peritext.savedSlices.each().find(({type}) => type === SliceTypeCon.i);
106106
kit.et.cursor({clear: true});
@@ -115,7 +115,7 @@ const testSuite = (getKit: () => Kit) => {
115115
kit.et.format({action: 'ins', type: SliceTypeCon.b});
116116
kit.et.cursor({at: [10, 20]});
117117
kit.et.format({action: 'ins', type: SliceTypeCon.i});
118-
kit.et.cursor({at: [0]})
118+
kit.et.cursor({at: [0]});
119119
expect(kit.toHtml()).toBe('<p>abcde<b>fghij</b><i><b>klmno</b></i><i>pqrst</i>uvwxyz</p>');
120120
const slice = kit.peritext.savedSlices.each().find(({type}) => type === SliceTypeCon.b)!;
121121
kit.et.cursor({clear: true});
@@ -171,11 +171,13 @@ const testSuite = (getKit: () => Kit) => {
171171
test('can diff an "obj" node', () => {
172172
const kit = setup();
173173
kit.et.cursor({at: [10, 20]});
174-
kit.et.format({action: 'ins', type: SliceTypeCon.col, data: {color: 'green', opacity: .5}});
175-
expect(kit.toHtml()).toBe('<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>');
174+
kit.et.format({action: 'ins', type: SliceTypeCon.col, data: {color: 'green', opacity: 0.5}});
175+
expect(kit.toHtml()).toBe(
176+
'<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>',
177+
);
176178
const slice = kit.peritext.savedSlices.each().find(({type}) => type === SliceTypeCon.col)!;
177179
expect(slice.data()).toEqual({color: 'green', opacity: 0.5});
178-
kit.et.format({action: 'upd', slice, data: {"color":"green", "opacity":1}});
180+
kit.et.format({action: 'upd', slice, data: {color: 'green', opacity: 1}});
179181
expect(slice.data()).toEqual({color: 'green', opacity: 1});
180182
});
181183

@@ -186,7 +188,7 @@ const testSuite = (getKit: () => Kit) => {
186188
expect(kit.toHtml()).toBe('<p>abcdefghij<col data-attr=\'["data"]\'>klmnopqrst</col>uvwxyz</p>');
187189
const slice = kit.peritext.savedSlices.each().find(({type}) => type === SliceTypeCon.col)!;
188190
expect(slice.data()).toEqual(['data']);
189-
kit.et.format({action: 'upd', slice, data: {"color":"green", "opacity":1}});
191+
kit.et.format({action: 'upd', slice, data: {color: 'green', opacity: 1}});
190192
expect(slice.data()).toEqual({color: 'green', opacity: 1});
191193
});
192194

@@ -206,19 +208,23 @@ const testSuite = (getKit: () => Kit) => {
206208
test('can overwrite formatting data', () => {
207209
const kit = setup();
208210
kit.et.cursor({at: [10, 20]});
209-
kit.et.format({action: 'ins', type: SliceTypeCon.col, data: {color: 'green', opacity: .5}});
210-
expect(kit.toHtml()).toBe('<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>');
211+
kit.et.format({action: 'ins', type: SliceTypeCon.col, data: {color: 'green', opacity: 0.5}});
212+
expect(kit.toHtml()).toBe(
213+
'<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>',
214+
);
211215
const slice = kit.peritext.savedSlices.each().find(({type}) => type === SliceTypeCon.col)!;
212216
expect(slice.data()).toEqual({color: 'green', opacity: 0.5});
213-
kit.et.format({action: 'set', slice, data: {"color":"red"}});
217+
kit.et.format({action: 'set', slice, data: {color: 'red'}});
214218
expect(slice.data()).toEqual({color: 'red'});
215219
});
216220

217221
test('can overwrite formatting data with non-object', () => {
218222
const kit = setup();
219223
kit.et.cursor({at: [10, 20]});
220-
kit.et.format({action: 'ins', type: SliceTypeCon.col, data: {color: 'green', opacity: .5}});
221-
expect(kit.toHtml()).toBe('<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>');
224+
kit.et.format({action: 'ins', type: SliceTypeCon.col, data: {color: 'green', opacity: 0.5}});
225+
expect(kit.toHtml()).toBe(
226+
'<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>',
227+
);
222228
const slice = kit.peritext.savedSlices.each().find(({type}) => type === SliceTypeCon.col)!;
223229
expect(slice.data()).toEqual({color: 'green', opacity: 0.5});
224230
kit.et.format({action: 'set', slice, data: 123});
@@ -229,7 +235,7 @@ const testSuite = (getKit: () => Kit) => {
229235
const kit = setup();
230236
kit.et.cursor({at: [10, 20]});
231237
kit.et.format({action: 'ins', type: SliceTypeCon.col, data: true});
232-
expect(kit.toHtml()).toBe('<p>abcdefghij<col data-attr=\'true\'>klmnopqrst</col>uvwxyz</p>');
238+
expect(kit.toHtml()).toBe("<p>abcdefghij<col data-attr='true'>klmnopqrst</col>uvwxyz</p>");
233239
const slice = kit.peritext.savedSlices.each().find(({type}) => type === SliceTypeCon.col)!;
234240
expect(slice.data()).toEqual(true);
235241
kit.et.format({action: 'set', slice, data: {col: '#fff'}});

src/json-crdt-extensions/peritext/events/__tests__/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { createEvents } from '..';
2-
import {type Kit} from '../../../../json-crdt-extensions/peritext/__tests__/setup';
1+
import {createEvents} from '..';
2+
import type {Kit} from '../../../../json-crdt-extensions/peritext/__tests__/setup';
33

44
export const getEventsKit = (getKit: () => Kit) => {
55
const kit = getKit();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Anchor} from '../../../../json-crdt-extensions/peritext/rga/constants';
22
import {placeCursor} from './annals';
33
import {Cursor} from '../../../../json-crdt-extensions/peritext/editor/Cursor';
4-
import {CursorAnchor, SliceTypeSteps, type Peritext} from '../../../../json-crdt-extensions/peritext';
4+
import {CursorAnchor, type SliceTypeSteps, type Peritext} from '../../../../json-crdt-extensions/peritext';
55
import {PersistedSlice} from '../../../../json-crdt-extensions/peritext/slice/PersistedSlice';
66
import type {Range} from '../../../../json-crdt-extensions/peritext/rga/Range';
77
import type {PeritextDataTransfer} from '../../../../json-crdt-extensions/peritext/transfer/PeritextDataTransfer';

src/json-crdt-extensions/peritext/events/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {SliceTypeSteps, TypeTag} from '../../../json-crdt-extensions/perite
44
import type {ITimestampStruct, Patch} from '../../../json-crdt-patch';
55
import type {Cursor} from '../../../json-crdt-extensions/peritext/editor/Cursor';
66
import type {Range} from '../../../json-crdt-extensions/peritext/rga/Range';
7-
import type { PersistedSlice } from '../slice/PersistedSlice';
7+
import type {PersistedSlice} from '../slice/PersistedSlice';
88

99
/**
1010
* Dispatched every time any other event is dispatched.

src/json-crdt-extensions/peritext/slice/PersistedSlice.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ import {type Model, ObjApi} from '../../../json-crdt/model';
2323
import type {ObjNode, VecNode} from '../../../json-crdt/nodes';
2424
import type {ITimestampStruct} from '../../../json-crdt-patch/clock';
2525
import type {ArrChunk} from '../../../json-crdt/nodes';
26-
import type {MutableSlice, SliceView, SliceType, SliceUpdateParams, SliceTypeSteps, SliceTypeStep, TypeTag} from './types';
26+
import type {
27+
MutableSlice,
28+
SliceView,
29+
SliceType,
30+
SliceUpdateParams,
31+
SliceTypeSteps,
32+
SliceTypeStep,
33+
TypeTag,
34+
} from './types';
2735
import type {Stateful} from '../types';
2836
import type {Printable} from 'tree-dump/lib/types';
2937
import type {AbstractRga} from '../../../json-crdt/nodes/rga';
@@ -167,9 +175,7 @@ export class PersistedSlice<T = string> extends Range<T> implements MutableSlice
167175
public dataAsObj(): ObjApi<ObjNode> {
168176
const node = this.dataNode();
169177
if (!(node instanceof ObjApi)) {
170-
this.tupleApi().set([
171-
[SliceTupleIndex.Data, s.obj({})],
172-
]);
178+
this.tupleApi().set([[SliceTupleIndex.Data, s.obj({})]]);
173179
}
174180
return this.dataNode() as unknown as ObjApi<ObjNode>;
175181
}

src/json-crdt-extensions/peritext/slice/types.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ import type {Anchor} from '../rga/constants';
4444
* [['<blockquote>', 0], '<p>']
4545
* [['<blockquote>', 1], '<p>']
4646
* ```
47-
*
47+
*
4848
* Each block nesting level can have a custom data object:
49-
*
49+
*
5050
* ```ts
5151
* [['<blockquote>', 0, {author: 'Alice'}], '<p>']
5252
* [
@@ -79,57 +79,54 @@ export type SliceSchema = nodes.vec<
7979
* slice as well as anchor {@link Anchor} points of the x1 and x2 points.
8080
*/
8181
header: nodes.con<number>,
82-
8382
/**
8483
* ID of the start {@link Point} of the slice.
8584
*/
8685
x1: nodes.con<ITimestampStruct>,
87-
8886
/**
8987
* ID of the end {@link Point} of the slice, if 0 then it is equal to x1.
9088
*/
9189
x2: nodes.con<ITimestampStruct | 0>,
92-
9390
/**
9491
* App specific type of the slice. For slices with "Marker" stacking
9592
* behavior, this is a path of block nesting. For other slices, it
9693
* specifies inline formatting, such as bold, italic, etc.; the value has
9794
* to be a primitive number or a string.
98-
*
95+
*
9996
* Inline formatting is encoded as a single "con" node:
100-
*
97+
*
10198
* ```ts
10299
* s.con('bold')
103100
* ```
104-
*
101+
*
105102
* The most basic one-level block split can be encoded as a single
106103
* "con" node:
107-
*
104+
*
108105
* ```ts
109106
* s.con('p')
110107
* ```
111-
*
108+
*
112109
* Nested blocks are encoded as an "arr" node of "con" nodes or "vec" tuples.
113110
* The "con" nodes are when only the tag is specified, while the "vec" tuples
114111
* are used when the tag is accompanied by a discriminant and/or custom data
115112
* (attributes of the block).
116-
*
113+
*
117114
* ```ts
118115
* s.vec([
119116
* s.con('blockquote'),
120117
* s.con('p')
121118
* ])
122-
*
119+
*
123120
* s.vec([
124121
* // <ul:0>
125122
* s.con('ul'),
126-
*
123+
*
127124
* // <li:1>
128125
* s.vec([
129126
* s.con('li'),
130127
* s.con(1), // discriminant
131128
* ]),
132-
*
129+
*
133130
* // <p:0 indent="2">
134131
* s.vec([
135132
* s.con('p'),
@@ -141,16 +138,19 @@ export type SliceSchema = nodes.vec<
141138
* ])
142139
* ```
143140
*/
144-
type: nodes.con<TypeTag> | nodes.arr<
145-
nodes.con<TypeTag> |
146-
nodes.vec<[
147-
tag: nodes.con<TypeTag>,
148-
discriminant: nodes.con<number>,
149-
data: nodes.obj<// biome-ignore lint: TODO: improve the type of the data node
150-
{}>,
151-
]>
152-
>,
153-
141+
type:
142+
| nodes.con<TypeTag>
143+
| nodes.arr<
144+
| nodes.con<TypeTag>
145+
| nodes.vec<
146+
[
147+
tag: nodes.con<TypeTag>,
148+
discriminant: nodes.con<number>,
149+
data: nodes.obj<// biome-ignore lint: TODO: improve the type of the data node
150+
{}>,
151+
]
152+
>
153+
>,
154154
/**
155155
* Reference to additional metadata about the slice, usually an object.
156156
* Normally used for inline formatting, block formatting attaches data to

0 commit comments

Comments
 (0)