Skip to content

Commit 9b46a4d

Browse files
committed
test: 💍 fix linter errors
1 parent cd8f771 commit 9b46a4d

File tree

11 files changed

+75
-47
lines changed

11 files changed

+75
-47
lines changed

src/json-crdt-extensions/peritext/block/Block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class Block<Attr = unknown> implements IBlock, Printable, Stateful {
145145
}
146146
protected toStringHeader(): string {
147147
const hash = `#${this.hash.toString(36).slice(-4)}`;
148-
const tag = this.path.map(step => formatType(step)).join('.');
148+
const tag = this.path.map((step) => formatType(step)).join('.');
149149
const header = `${this.toStringName()} ${hash} ${tag}`;
150150
return header;
151151
}

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {UndefEndIter, type UndefIterator} from '../../../util/iterator';
1111
import {PersistedSlice} from '../slice/PersistedSlice';
1212
import {ValueSyncStore} from '../../../util/events/sync-store';
1313
import {formatType} from '../slice/util';
14-
import {CommonSliceType, SliceType} from '../slice';
14+
import {CommonSliceType, type SliceType} from '../slice';
1515
import type {ChunkSlice} from '../util/ChunkSlice';
1616
import type {Peritext} from '../Peritext';
1717
import type {Point} from '../rga/Point';
@@ -187,7 +187,8 @@ export class Editor<T = string> implements Printable {
187187
const txt = this.txt;
188188
const overlay = txt.overlay;
189189
const contained = overlay.findContained(range);
190-
for (const slice of contained) if (slice instanceof PersistedSlice && slice.behavior !== SliceBehavior.Cursor) slice.del();
190+
for (const slice of contained)
191+
if (slice instanceof PersistedSlice && slice.behavior !== SliceBehavior.Cursor) slice.del();
191192
txt.delStr(range);
192193
}
193194

@@ -201,7 +202,10 @@ export class Editor<T = string> implements Printable {
201202
public delete(step: number, unit: 'char' | 'word' | 'line'): void {
202203
const txt = this.txt;
203204
for (let i = this.cursors0(), cursor = i(); cursor; cursor = i()) {
204-
if (!cursor.isCollapsed()) return this.collapseCursor(cursor);
205+
if (!cursor.isCollapsed()) {
206+
this.collapseCursor(cursor);
207+
return;
208+
}
205209
let point1 = cursor.start.clone();
206210
let point2 = point1.clone();
207211
if (step > 0) point2 = this.skip(point2, step, unit);
@@ -555,8 +559,7 @@ export class Editor<T = string> implements Printable {
555559
const needToRemoveFormatting = complete.has(type);
556560
makeRangeExtendable(range);
557561
const contained = overlay.findContained(range);
558-
for (const slice of contained)
559-
if (slice instanceof PersistedSlice && slice.type === type) slice.del();
562+
for (const slice of contained) if (slice instanceof PersistedSlice && slice.type === type) slice.del();
560563
if (needToRemoveFormatting) {
561564
overlay.refresh();
562565
const [complete2, partial2] = overlay.stat(range, 1e6);
@@ -608,7 +611,8 @@ export class Editor<T = string> implements Printable {
608611
switch (slice.behavior) {
609612
case SliceBehavior.One:
610613
case SliceBehavior.Many:
611-
case SliceBehavior.Erase: slice.del();
614+
case SliceBehavior.Erase:
615+
slice.del();
612616
}
613617
}
614618
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ export class Overlay<T = string> implements Printable, Stateful {
5959
public first(): OverlayPoint<T> | undefined {
6060
return this.root ? first(this.root) : undefined;
6161
}
62-
62+
6363
public last(): OverlayPoint<T> | undefined {
6464
return this.root ? last(this.root) : undefined;
6565
}
66-
66+
6767
public firstMarker(): MarkerOverlayPoint<T> | undefined {
6868
return this.root2 ? first2(this.root2) : undefined;
6969
}
70-
70+
7171
public lastMarker(): MarkerOverlayPoint<T> | undefined {
7272
return this.root2 ? last2(this.root2) : undefined;
7373
}

src/json-crdt-peritext-ui/__demos__/components/App.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import {renderers as debugRenderers} from '../../plugins/debug';
77

88
export const App: React.FC = () => {
99
const [[model, peritext]] = React.useState(() => {
10-
const model = ModelWithExt.create(ext.peritext.new('The German automotive sector is in the process of cutting thousands of jobs as it grapples with a global shift toward electric vehicles — a transformation Musk himself has been at the forefront of.'));
10+
const model = ModelWithExt.create(
11+
ext.peritext.new(
12+
'The German automotive sector is in the process of cutting thousands of jobs as it grapples with a global shift toward electric vehicles — a transformation Musk himself has been at the forefront of.',
13+
),
14+
);
1115
const peritext = model.s.toExt().txt;
1216
peritext.refresh();
1317
return [model, peritext] as const;

src/json-crdt-peritext-ui/components/ButtonGroup/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ export interface ButtonGroup extends React.HTMLAttributes<HTMLDivElement> {
2020
}
2121

2222
export const ButtonGroup: React.FC<ButtonGroup> = ({children, ...rest}) => {
23-
return <div {...rest} className={(rest.className || '') + blockClass}>{children}</div>;
23+
return (
24+
<div {...rest} className={(rest.className || '') + blockClass}>
25+
{children}
26+
</div>
27+
);
2428
};

src/json-crdt-peritext-ui/components/ButtonSeparator/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ const blockClass = rule({
1313
});
1414

1515
export const ButtonSeparator: React.FC = () => {
16-
return (
17-
<div className={blockClass} />
18-
);
16+
return <div className={blockClass} />;
1917
};

src/json-crdt-peritext-ui/events/PeritextEventDefaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class PeritextEventDefaults implements PeritextEventHandlerMap {
143143
if (marker) {
144144
marker.marker.update({type});
145145
}
146-
console.log('togggling..', marker)
146+
console.log('togggling..', marker);
147147
break;
148148
}
149149
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,23 +244,23 @@ export interface FormatDetail {
244244
export interface MarkerDetail {
245245
/**
246246
* The action to perform.
247-
*
247+
*
248248
* @default 'tog'
249249
*/
250250
action?: 'tog' | 'ins' | 'del' | 'upd';
251251

252252
/**
253253
* The type tag applied to the new block, if the action is `'ins'`. If the
254254
* action is `'upd'`, the type tag is used to update the block type.
255-
*
255+
*
256256
* @default SliceType.Paragraph
257257
*/
258258
type?: SliceType;
259259

260260
/**
261261
* Block-specific custom data. For example, a paragraph block may store
262262
* the alignment and indentation information in this field.
263-
*
263+
*
264264
* @default undefined
265265
*/
266266
data?: unknown;
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// biome-ignore lint: React is used for JSX
22
import * as React from 'react';
3-
import {BlockViewProps} from '../../react/BlockView';
3+
import type {BlockViewProps} from '../../react/BlockView';
44
import {CommonSliceType} from '../../../json-crdt-extensions';
55

66
export interface RenderBlockProps extends BlockViewProps {
@@ -10,12 +10,13 @@ export interface RenderBlockProps extends BlockViewProps {
1010
export const RenderBlock: React.FC<RenderBlockProps> = ({block, children}) => {
1111
const tag = block.tag();
1212
switch (tag) {
13-
case '': return children;
13+
case '':
14+
return children;
1415
case CommonSliceType.blockquote: {
1516
return <blockquote>{children}</blockquote>;
1617
}
1718
default: {
18-
return <div style={{padding: '16px 0'}}>{children}</div>
19+
return <div style={{padding: '16px 0'}}>{children}</div>;
1920
}
2021
}
2122
};

src/json-crdt-peritext-ui/plugins/minimal/RenderCaret.tsx

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const innerClass = rule({
3535
d: 'inline-block',
3636
b: '-0.4em',
3737
l: '-0.065em',
38-
w: `calc(max(.2em, 3px))`,
38+
w: 'calc(max(.2em, 3px))',
3939
h: '1.5em',
4040
bg: DefaultRendererColors.ActiveCursor,
4141
bdl: `1px dotted ${DefaultRendererColors.InactiveCursor}`,
@@ -84,7 +84,7 @@ export const RenderCaret: React.FC<RenderCaretProps> = ({italic, children}) => {
8484

8585
const scoreAnimation = keyframes({
8686
from: {
87-
op: .7,
87+
op: 0.7,
8888
tr: 'scale(1.2)',
8989
},
9090
to: {
@@ -95,13 +95,13 @@ const scoreAnimation = keyframes({
9595
});
9696

9797
const shakingAnimation = keyframes({
98-
'0%': { tr: 'translateX(0), scale(1.2)', op: 1 },
99-
'10%': { tr: 'translateX(-2px)' },
100-
'20%': { tr: 'translateX(2px)' },
101-
'30%': { tr: 'translateX(-1px)' },
102-
'40%': { tr: 'translateX(1px)' },
103-
'50%': { tr: 'translateX(0), scale(1)' },
104-
'100%': { op: 0, vis: 'hidden' },
98+
'0%': {tr: 'translateX(0), scale(1.2)', op: 1},
99+
'10%': {tr: 'translateX(-2px)'},
100+
'20%': {tr: 'translateX(2px)'},
101+
'30%': {tr: 'translateX(-1px)'},
102+
'40%': {tr: 'translateX(1px)'},
103+
'50%': {tr: 'translateX(0), scale(1)'},
104+
'100%': {op: 0, vis: 'hidden'},
105105
});
106106

107107
const scoreClass = rule({
@@ -110,7 +110,7 @@ const scoreClass = rule({
110110
b: '0.3em',
111111
l: '.75em',
112112
fz: '.4em',
113-
op: .5,
113+
op: 0.5,
114114
an: scoreAnimation + ' .5s ease-out forwards',
115115
ws: 'nowrap',
116116
pe: 'none',
@@ -123,7 +123,7 @@ const scoreDeltaClass = rule({
123123
b: '0.9em',
124124
l: '1.2em',
125125
fz: '.5em',
126-
op: .5,
126+
op: 0.5,
127127
col: 'blue',
128128
an: scoreAnimation + ' .3s ease-out forwards',
129129
pe: 'none',
@@ -138,18 +138,20 @@ interface CaretScoreProps {
138138
const CaretScore: React.FC<CaretScoreProps> = React.memo(({score, delta}) => {
139139
const plugin = usePlugin();
140140

141+
// biome-ignore lint: lint/correctness/useExhaustiveDependencies
141142
React.useEffect(() => {
142143
plugin.lastVisScore.value = score;
143144
}, []);
144145

145-
const scoreMsg = score > 100 && score <= 120
146-
? 'Typing Spree!'
146+
const scoreMsg =
147+
score > 100 && score <= 120
148+
? 'Typing Spree!'
147149
: score > 200 && score <= 208
148-
? 'Go, go, go!'
150+
? 'Go, go, go!'
149151
: score > 300 && score <= 320
150152
? 'Rampage!'
151153
: score > 400 && score <= 408
152-
? 'Let\'s go!'
154+
? "Let's go!"
153155
: score > 500 && score <= 520
154156
? 'Unstoppable!'
155157
: score > 600 && score <= 608
@@ -176,8 +178,20 @@ const CaretScore: React.FC<CaretScoreProps> = React.memo(({score, delta}) => {
176178

177179
return (
178180
<>
179-
{score >=24 && <span contentEditable={false} className={scoreClass} style={{animation: typeof scoreMsg === 'string' ? shakingAnimation + ' .7s ease-out forwards' : undefined}}>{scoreMsg}</span>}
180-
{(typeof scoreMsg === 'string' || (score > 42 && delta > 1)) && <span contentEditable={false} className={scoreDeltaClass}>+{delta}</span>}
181+
{score >= 24 && (
182+
<span
183+
contentEditable={false}
184+
className={scoreClass}
185+
style={{animation: typeof scoreMsg === 'string' ? shakingAnimation + ' .7s ease-out forwards' : undefined}}
186+
>
187+
{scoreMsg}
188+
</span>
189+
)}
190+
{(typeof scoreMsg === 'string' || (score > 42 && delta > 1)) && (
191+
<span contentEditable={false} className={scoreDeltaClass}>
192+
+{delta}
193+
</span>
194+
)}
181195
</>
182196
);
183197
});

0 commit comments

Comments
 (0)