Skip to content

Commit 92d5863

Browse files
committed
Fix linter
1 parent 7e45188 commit 92d5863

File tree

6 files changed

+23
-34
lines changed

6 files changed

+23
-34
lines changed

packages/collaboration-manager/src/CollaborationManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import {
55
EventType,
66
type ModelEvents,
77
TextAddedEvent,
8-
TextFormattedEvent, type TextFormattedEventData,
9-
TextRemovedEvent,
8+
TextFormattedEvent, TextRemovedEvent,
109
TextUnformattedEvent
1110
} from '@editorjs/model';
1211
import { Operation, OperationType } from './Operation.js';

packages/collaboration-manager/src/Operation.spec.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-magic-numbers */
22
import type { BlockNodeSerialized, DataKey, DocumentIndex } from '@editorjs/model';
33
import { IndexBuilder } from '@editorjs/model';
4-
import { describe } from "@jest/globals";
4+
import { describe } from '@jest/globals';
55
import { type InsertOrDeleteOperationData, type ModifyOperationData, Operation, OperationType } from './Operation.js';
66

77
const createOperation = (
@@ -18,7 +18,7 @@ const createOperation = (
1818
if (Array.isArray(value)) {
1919
index.addBlockIndex(startIndex);
2020
} else {
21-
index.addDataKey('text' as DataKey).addTextRange([ startIndex, startIndex ]);
21+
index.addDataKey('text' as DataKey).addTextRange([startIndex, startIndex]);
2222
}
2323

2424
const data: InsertOrDeleteOperationData | ModifyOperationData = {
@@ -33,7 +33,7 @@ const createOperation = (
3333
return new Operation(
3434
type,
3535
index.build(),
36-
data,
36+
data
3737
);
3838
};
3939

@@ -102,15 +102,15 @@ describe('Operation', () => {
102102
const localOp = createOperation(OperationType.Insert, 0, 'abc');
103103
const transformedOp = receivedOp.transform(localOp);
104104

105-
expect(transformedOp.index.textRange).toEqual([ 6, 6 ]);
105+
expect(transformedOp.index.textRange).toEqual([6, 6]);
106106
});
107107

108108
it('should transform a received operation if it is at the same position as a local one', () => {
109109
const receivedOp = createOperation(OperationType.Modify, 0, 'abc');
110110
const localOp = createOperation(OperationType.Insert, 0, 'def');
111111
const transformedOp = receivedOp.transform(localOp);
112112

113-
expect(transformedOp.index.textRange).toEqual([ 3, 3 ]);
113+
expect(transformedOp.index.textRange).toEqual([3, 3]);
114114
});
115115

116116
it('should not change the text index if local op is a Block operation', () => {
@@ -121,7 +121,7 @@ describe('Operation', () => {
121121
} ]);
122122
const transformedOp = receivedOp.transform(localOp);
123123

124-
expect(transformedOp.index.textRange).toEqual([ 0, 0 ]);
124+
expect(transformedOp.index.textRange).toEqual([0, 0]);
125125
});
126126

127127
it('should not change the operation if local op is a Block operation after a received one', () => {
@@ -184,15 +184,15 @@ describe('Operation', () => {
184184
const localOp = createOperation(OperationType.Delete, 0, 'abc');
185185
const transformedOp = receivedOp.transform(localOp);
186186

187-
expect(transformedOp.index.textRange).toEqual([ 0, 0 ]);
187+
expect(transformedOp.index.textRange).toEqual([0, 0]);
188188
});
189189

190190
it('should transform a received operation if it is at the same position as a local one', () => {
191191
const receivedOp = createOperation(OperationType.Modify, 3, 'abc');
192192
const localOp = createOperation(OperationType.Delete, 3, 'def');
193193
const transformedOp = receivedOp.transform(localOp);
194194

195-
expect(transformedOp.index.textRange).toEqual([ 0, 0 ]);
195+
expect(transformedOp.index.textRange).toEqual([0, 0]);
196196
});
197197

198198
it('should not change the text index if local op is a Block operation', () => {
@@ -203,7 +203,7 @@ describe('Operation', () => {
203203
} ]);
204204
const transformedOp = receivedOp.transform(localOp);
205205

206-
expect(transformedOp.index.textRange).toEqual([ 1, 1 ]);
206+
expect(transformedOp.index.textRange).toEqual([1, 1]);
207207
});
208208

209209
it('should not change the text index if local op is a Block operation', () => {
@@ -214,7 +214,7 @@ describe('Operation', () => {
214214
} ]);
215215
const transformedOp = receivedOp.transform(localOp);
216216

217-
expect(transformedOp.index.textRange).toEqual([ 0, 0 ]);
217+
expect(transformedOp.index.textRange).toEqual([0, 0]);
218218
});
219219

220220
it('should not change the operation if local op is a Block operation after a received one', () => {
@@ -304,7 +304,8 @@ describe('Operation', () => {
304304
const op = createOperation(OperationType.Modify, 0, { bold: true }, { bold: false });
305305
const inverted = op.inverse();
306306

307-
expect(inverted.data).toEqual({ payload: { bold: false }, prevPayload: { bold: true } });
307+
expect(inverted.data).toEqual({ payload: { bold: false },
308+
prevPayload: { bold: true } });
308309
});
309310

310311
it('should throw an error if unsupported operation type is provided', () => {

packages/collaboration-manager/src/Operation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class Operation<T extends OperationType = OperationType> {
141141
break;
142142
}
143143

144-
newIndexBuilder.addTextRange([ this.index.textRange![0] + payload.length, this.index.textRange![1] + payload.length ]);
144+
newIndexBuilder.addTextRange([this.index.textRange![0] + payload.length, this.index.textRange![1] + payload.length]);
145145

146146
break;
147147
}
@@ -155,7 +155,7 @@ export class Operation<T extends OperationType = OperationType> {
155155
break;
156156
}
157157

158-
newIndexBuilder.addTextRange([ this.index.textRange![0] - payload.length, this.index.textRange![1] - payload.length ]);
158+
newIndexBuilder.addTextRange([this.index.textRange![0] - payload.length, this.index.textRange![1] - payload.length]);
159159

160160
break;
161161
}
@@ -172,8 +172,9 @@ export class Operation<T extends OperationType = OperationType> {
172172
}
173173

174174
/**
175+
* Checks if operation needs to be transformed
175176
*
176-
* @param indexToCompare
177+
* @param indexToCompare - index of a relative operation
177178
*/
178179
#shouldTransform(indexToCompare: Index): boolean {
179180
if (indexToCompare.isBlockIndex && this.index.blockIndex !== undefined) {

packages/model/src/entities/EditorDocument/EditorDocument.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ describe('EditorDocument', () => {
834834
const spy = jest.spyOn(document, 'insertText');
835835
const index = new IndexBuilder().addBlockIndex(blockIndex)
836836
.addDataKey(dataKey)
837-
.addTextRange([ 0, 0 ])
837+
.addTextRange([0, 0])
838838
.build();
839839

840840
document.insertData(index, text);
@@ -879,7 +879,7 @@ describe('EditorDocument', () => {
879879
const index = new IndexBuilder()
880880
.addBlockIndex(blockIndex)
881881
.addDataKey(dataKey)
882-
.addTextRange([ 0, rangeEnd ])
882+
.addTextRange([0, rangeEnd])
883883
.build();
884884

885885
document.removeData(index, 'hello');

packages/model/src/entities/EditorDocument/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ export class EditorDocument extends EventBus {
4949
* @param [args.toolsRegistry] - ToolsRegistry instance for the current document. Defaults to a new ToolsRegistry instance.
5050
*/
5151
constructor({
52-
properties = {},
53-
toolsRegistry = new ToolsRegistry(),
54-
}: EditorDocumentConstructorParameters = {}) {
52+
properties = {},
53+
toolsRegistry = new ToolsRegistry(),
54+
}: EditorDocumentConstructorParameters = {}) {
5555
super();
5656

5757
this.#properties = properties;

packages/model/src/entities/Index/index.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@ import type { DocumentIndex, TextRange } from '../../EventBus/index.js';
22
import type { DataKey } from '../BlockNode/index.js';
33
import type { BlockTuneName } from '../BlockTune/index.js';
44

5-
interface IndexDelta {
6-
/**
7-
* The first number is a delta of the starts,
8-
* the second number is a delta of the ends
9-
*/
10-
textRangeDelta?: TextRange;
11-
12-
blockIndexDelta?: number;
13-
14-
isTheSameDataKey?: boolean;
15-
}
16-
175
/**
186
* Class representing index in the document model tree
197
*/
@@ -64,7 +52,7 @@ export class Index {
6452
const index = new Index();
6553

6654
for (const value of arrayIndex) {
67-
const [ type, data ] = value.split('@');
55+
const [type, data] = value.split('@');
6856

6957
switch (type) {
7058
case 'doc':

0 commit comments

Comments
 (0)