Skip to content

Commit 61f348b

Browse files
committed
style: 💄 fix linter issues
1 parent 30c6e14 commit 61f348b

File tree

17 files changed

+142
-84
lines changed

17 files changed

+142
-84
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ import type {Peritext} from '../Peritext';
2121
import type {ChunkSlice} from '../util/ChunkSlice';
2222
import type {MarkerSlice} from '../slice/MarkerSlice';
2323
import type {SliceRegistry} from '../registry/SliceRegistry';
24-
import type {CharIterator, CharPredicate, Position, TextRangeUnit, ViewStyle, ViewRange, ViewSlice, EditorUi} from './types';
24+
import type {
25+
CharIterator,
26+
CharPredicate,
27+
Position,
28+
TextRangeUnit,
29+
ViewStyle,
30+
ViewRange,
31+
ViewSlice,
32+
EditorUi,
33+
} from './types';
2534

2635
/**
2736
* For inline boolean ("Overwrite") slices, both range endpoints should be
@@ -510,7 +519,13 @@ export class Editor<T = string> implements Printable {
510519
* @param endpoint 0 for "focus", 1 for "anchor", 2 for both.
511520
* @param collapse Whether to collapse the range to a single point.
512521
*/
513-
public move(steps: number, unit: TextRangeUnit, endpoint: 0 | 1 | 2 = 0, collapse: boolean = true, ui?: EditorUi<T>): void {
522+
public move(
523+
steps: number,
524+
unit: TextRangeUnit,
525+
endpoint: 0 | 1 | 2 = 0,
526+
collapse: boolean = true,
527+
ui?: EditorUi<T>,
528+
): void {
514529
this.forCursor((cursor) => {
515530
switch (endpoint) {
516531
case 0: {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface EditorUi<T = string> {
2525
/**
2626
* Visually skips to the end or beginning of the line. Visually as in, it will
2727
* respect the visual line breaks created by word wrapping.
28-
*
28+
*
2929
* Skips just one line, regardless of the magnitude of the `steps` parameter.
3030
*
3131
* @param point The point from which to start skipping.
@@ -35,7 +35,7 @@ export interface EditorUi<T = string> {
3535
* @returns The point after skipping the specified number of lines, or
3636
* undefined if no such point exists.
3737
*/
38-
eol?(point: Point<T>, steps: number): (Point<T> | undefined);
38+
eol?(point: Point<T>, steps: number): Point<T> | undefined;
3939

4040
/**
4141
* Used when user presses "ArrowUp" or "ArrowDown" keys. It will skip to the

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {UndoCollector} from '../../types';
1111
import type {UiHandle} from './ui/UiHandle';
1212
import type {Point} from '../../../json-crdt-extensions/peritext/rga/Point';
1313
import {Anchor} from '../../../json-crdt-extensions/peritext/rga/constants';
14-
import {EditorUi} from '../../../json-crdt-extensions/peritext/editor/types';
14+
import type {EditorUi} from '../../../json-crdt-extensions/peritext/editor/types';
1515

1616
const toText = (buf: Uint8Array) => new TextDecoder().decode(buf);
1717

@@ -26,13 +26,13 @@ export interface PeritextEventDefaultsOpts {
2626
* {@link PeritextEventTarget} to provide default behavior for each event type.
2727
* If `event.preventDefault()` is called on a Peritext event, the default handler
2828
* will not be executed.
29-
*/
29+
*/
3030
export class PeritextEventDefaults implements PeritextEventHandlerMap {
3131
public undo?: UndoCollector;
3232
public ui?: UiHandle;
3333

3434
protected editorUi: EditorUi = {
35-
eol: (point: Point, steps: number): (Point | undefined) => {
35+
eol: (point: Point, steps: number): Point | undefined => {
3636
const ui = this.ui;
3737
if (!ui) return;
3838
const res = ui.getLineEnd(point, steps > 0);
@@ -47,14 +47,15 @@ export class PeritextEventDefaults implements PeritextEventHandlerMap {
4747
if (!currLine) return;
4848
const lineEdgeX = currLine[0][1].x;
4949
const relX = pos[0] - lineEdgeX;
50-
let iterations = Math.abs(steps);
50+
const iterations = Math.abs(steps);
5151
let nextPoint = point;
5252
for (let i = 0; i < iterations; i++) {
5353
const nextLine = steps > 0 ? ui.getNextLineInfo(currLine) : ui.getPrevLineInfo(currLine);
5454
if (!nextLine) break;
5555
nextPoint = ui.findPointAtRelX(relX, nextLine);
5656
if (!nextPoint) break;
57-
if (point.anchor === Anchor.Before) nextPoint.refBefore(); else nextPoint.refAfter();
57+
if (point.anchor === Anchor.Before) nextPoint.refBefore();
58+
else nextPoint.refAfter();
5859
}
5960
return nextPoint;
6061
},

src/json-crdt-peritext-ui/events/defaults/ui/UiHandle.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class UiHandle {
3737
public pointX(pos: number | Point<string>): [x: number, rect: Rect] | undefined {
3838
const txt = this.txt;
3939
const point = typeof pos === 'number' ? txt.pointAt(pos) : pos;
40-
const rect = this.getPointRect(point, point.anchor === Anchor.Before ? true : false);
40+
const rect = this.getPointRect(point, point.anchor === Anchor.Before);
4141
if (!rect) return;
4242
const x = point.anchor === Anchor.Before ? rect.x : rect.x + rect.width;
4343
return [x, rect];
@@ -47,7 +47,7 @@ export class UiHandle {
4747
const lineRect = line[0][1];
4848
const lineX = lineRect.x;
4949
let point = line[0][0].clone();
50-
let curr = point;
50+
const curr = point;
5151
let bestDiff = 1e9;
5252
const max = line[1][0].viewPos() - line[0][0].viewPos();
5353
if (!this.api.getCharRect) return point;
@@ -83,7 +83,7 @@ export class UiHandle {
8383
return [curr, currRect];
8484
};
8585
while (true) {
86-
const next = curr.copy(p => p.step(right ? 1 : -1));
86+
const next = curr.copy((p) => p.step(right ? 1 : -1));
8787
if (!next) return prepareReturn();
8888
const nextRect = this.getPointRect(next, right);
8989
if (!nextRect) return prepareReturn();
@@ -107,14 +107,14 @@ export class UiHandle {
107107
public getPrevLineInfo(line: UiLineInfo): UiLineInfo | undefined {
108108
const [[left]] = line;
109109
if (left.isStart()) return;
110-
const point = left.copy(p => p.step(-1));
110+
const point = left.copy((p) => p.step(-1));
111111
return this.getLineInfo(point);
112112
}
113113

114114
public getNextLineInfo(line: UiLineInfo): UiLineInfo | undefined {
115115
const [, [right]] = line;
116116
if (right.viewPos() >= this.txt.str.length()) return;
117-
const point = right.copy(p => p.step(1));
117+
const point = right.copy((p) => p.step(1));
118118
return this.getLineInfo(point);
119119
}
120120
}

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ export interface PeritextUiApi {
3232
isRTL?(pos: number | Point<string>): boolean;
3333
}
3434

35-
export type UiLineEdge = [
36-
point: Point,
37-
rect: Rect,
38-
];
39-
40-
export type UiLineInfo = [
41-
left: UiLineEdge,
42-
right: UiLineEdge,
43-
];
35+
export type UiLineEdge = [point: Point, rect: Rect];
4436

37+
export type UiLineInfo = [left: UiLineEdge, right: UiLineEdge];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export interface CursorDetail {
156156
* one word in the direction specified by `len`. If `'line'`, the cursor
157157
* will be moved to the beginning or end of line, in direction specified
158158
* by `len`.
159-
*
159+
*
160160
* - `'point'`: Moves by one Peritext anchor point. Each character has two
161161
* anchor points, one from each side of the character.
162162
* - `'char'`: Moves by one character. Skips one visible character.
@@ -171,7 +171,7 @@ export interface CursorDetail {
171171
* - `'block'`: Moves to the beginning or end of block, i.e. paragraph,
172172
* blockequote, etc.
173173
* - `'all'`: Moves to the beginning or end of the document.
174-
*
174+
*
175175
* @default 'char'
176176
*/
177177
unit?: 'point' | 'char' | 'word' | 'line' | 'vert' | 'block' | 'all';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const RenderCaret: React.FC<RenderCaretProps> = ({italic, point, children
7474
const {dom} = usePeritext();
7575
const focus = useSyncStoreOpt(dom?.cursor.focus) || false;
7676
const plugin = useCursorPlugin();
77-
77+
7878
const anchorForward = point.anchor === Anchor.Before;
7979

8080
const score = plugin.score.value;

src/json-crdt-peritext-ui/plugins/debug/DebugPlugin.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ export class DebugPlugin implements PeritextPlugin {
2424
</RenderPeritext>
2525
);
2626

27-
public readonly caret: PeritextPlugin['caret'] = (props, children) => <RenderCaret {...props}>{children}</RenderCaret>;
27+
public readonly caret: PeritextPlugin['caret'] = (props, children) => (
28+
<RenderCaret {...props}>{children}</RenderCaret>
29+
);
2830
}

src/json-crdt-peritext-ui/plugins/debug/RenderBlock.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ export const RenderBlock: React.FC<RenderBlockProps> = ({block, hash, children})
3030

3131
return (
3232
<div style={{position: 'relative'}}>
33-
<div contentEditable={false} className={labelContainerClass} onMouseDown={e => e.preventDefault()}>
34-
<DebugLabel right={hash.toString(36)}>
35-
{block.path
36-
.map((type) => formatType(type))
37-
.join('.')}
38-
</DebugLabel>
33+
<div contentEditable={false} className={labelContainerClass} onMouseDown={(e) => e.preventDefault()}>
34+
<DebugLabel right={hash.toString(36)}>{block.path.map((type) => formatType(type)).join('.')}</DebugLabel>
3935
</div>
4036
<div style={{outline: '1px dotted blue'}}>{children}</div>
4137
</div>

src/json-crdt-peritext-ui/plugins/debug/RenderCaret/CharOverlay.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const CharOverlay: React.FC<CharOverlayProps> = ({rectRef, ...rest}) => {
1313
useWindowSize();
1414
useWindowScroll();
1515
const ref = React.useRef<HTMLSpanElement | null>(null);
16+
// biome-ignore lint: lint/correctness/useExhaustiveDependencies
1617
React.useEffect(() => {
1718
(rectRef as any).current = (rect?: Rect) => {
1819
const span = ref.current;
@@ -30,7 +31,5 @@ export const CharOverlay: React.FC<CharOverlayProps> = ({rectRef, ...rest}) => {
3031
};
3132
}, []);
3233

33-
return (
34-
<span {...rest} ref={ref} />
35-
);
34+
return <span {...rest} ref={ref} />;
3635
};

0 commit comments

Comments
 (0)