Skip to content

Commit

Permalink
style: 💄 fix remaining linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Nov 2, 2024
1 parent c1b04f1 commit e19a44f
Show file tree
Hide file tree
Showing 59 changed files with 187 additions and 81 deletions.
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"noUselessElse": "off",
"noParameterAssign": "off",
"noCommaOperator": "off",
"useSingleVarDeclarator": "off"
"useSingleVarDeclarator": "off",
"useLiteralEnumMembers": "off"
},
"suspicious": {
"noExplicitAny": "off",
Expand Down
5 changes: 4 additions & 1 deletion src/__tests__/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ export const until = async (check: () => boolean, pollInterval: number = 1) => {
do {
if (check()) return;
await tick(pollInterval);
} while (true);
} while (
// biome-ignore lint: constant condition is intentional
true
);
};
14 changes: 7 additions & 7 deletions src/json-cli/json-patch-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ if (!bin) {
let cntCorrect = 0;
let cntFailed = 0;

testSuites.forEach((suite) => {
for (const suite of testSuites) {
console.log('');
console.log(suite.name);
console.log('');

suite.tests.forEach((test: any) => {
if (test.disabled) return;
for (const test of suite.tests) {
if (test.disabled) break;
const testName = test.comment || test.error || JSON.stringify(test.patch);
if (test.expected !== undefined) {
test.patch.forEach(validateOperation);
test.patch.forEach(validateOperation as any);
let isCorrect = false;
let result;
let result: unknown;
try {
const input = JSON.stringify(test.doc);
const {stdout} = spawnSync(bin, [JSON.stringify(test.patch)], {input});
Expand Down Expand Up @@ -69,8 +69,8 @@ testSuites.forEach((suite) => {
}

if (cntFailed) process.exit(1);
});
});
}
}

console.log('');
console.log(`Successful = ${cntCorrect}, Failed = ${cntFailed}, Total = ${cntCorrect + cntFailed}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('.fwd()', () => {
const {peritext, editor} = setup();
const iterator = editor.fwd(peritext.pointAbsStart());
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -46,6 +47,7 @@ describe('.fwd()', () => {
const start = peritext.pointStart()!;
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -59,6 +61,7 @@ describe('.fwd()', () => {
const start = peritext.pointAbsStart()!;
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -72,6 +75,7 @@ describe('.fwd()', () => {
const start = peritext.pointStart()!;
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -85,6 +89,7 @@ describe('.fwd()', () => {
const start = peritext.pointAt(2);
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -98,6 +103,7 @@ describe('.fwd()', () => {
const start = peritext.pointAt(2);
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -111,6 +117,7 @@ describe('.fwd()', () => {
const start = peritext.pointAt(6);
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -124,6 +131,7 @@ describe('.fwd()', () => {
const start = peritext.pointAt(6);
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -143,6 +151,7 @@ describe('.fwd()', () => {
const iterator = editor.fwd(start);
let str = '';
const bools: boolean[] = [];
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -159,6 +168,7 @@ describe('.bwd()', () => {
const {peritext, editor} = setup();
const iterator = editor.bwd(peritext.pointAbsEnd());
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -172,6 +182,7 @@ describe('.bwd()', () => {
const end = peritext.pointEnd()!;
const iterator = editor.bwd(end);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -185,6 +196,7 @@ describe('.bwd()', () => {
const end = peritext.pointAbsEnd()!;
const iterator = editor.bwd(end);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -198,6 +210,7 @@ describe('.bwd()', () => {
const end = peritext.pointEnd()!;
const iterator = editor.bwd(end);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -211,6 +224,7 @@ describe('.bwd()', () => {
const point = peritext.pointAt(2);
const iterator = editor.bwd(point);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -224,6 +238,7 @@ describe('.bwd()', () => {
const point = peritext.pointAt(2);
const iterator = editor.bwd(point);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -237,6 +252,7 @@ describe('.bwd()', () => {
const point = peritext.pointAt(6);
const iterator = editor.bwd(point);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -250,6 +266,7 @@ describe('.bwd()', () => {
const point = peritext.pointAt(6);
const iterator = editor.bwd(point);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -269,6 +286,7 @@ describe('.bwd()', () => {
const iterator = editor.bwd(start);
let str = '';
const bools: boolean[] = [];
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import {Model} from '../../../../json-crdt/model';
import {Peritext} from '../../Peritext';
import {type Kit, runAlphabetKitTestSuite, setupHelloWorldKit, setupHelloWorldWithFewEditsKit} from '../../__tests__/setup';
import {
type Kit,
runAlphabetKitTestSuite,
setupHelloWorldKit,
setupHelloWorldWithFewEditsKit,
} from '../../__tests__/setup';
import {Point} from '../../rga/Point';
import {Anchor} from '../../rga/constants';
import {CursorAnchor} from '../../slice/constants';
Expand Down Expand Up @@ -71,6 +76,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const {peritext, editor} = setup();
const iterator = editor.fwd(peritext.pointAbsStart());
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -84,6 +90,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const start = peritext.pointStart()!;
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -97,6 +104,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const start = peritext.pointAbsStart()!;
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -110,6 +118,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const start = peritext.pointStart()!;
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -123,6 +132,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const start = peritext.pointAt(2);
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -136,6 +146,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const start = peritext.pointAt(6);
const iterator = editor.fwd(start);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -153,6 +164,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const iterator = editor.fwd(start);
let str = '';
const bools: boolean[] = [];
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -173,6 +185,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const {peritext, editor} = setup();
const iterator = editor.bwd(peritext.pointAbsEnd());
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -186,6 +199,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const end = peritext.pointEnd()!;
const iterator = editor.bwd(end);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -199,6 +213,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const end = peritext.pointAbsEnd()!;
const iterator = editor.bwd(end);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -212,6 +227,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const end = peritext.pointEnd()!;
const iterator = editor.bwd(end);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -225,6 +241,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const point = peritext.pointAt(2);
const iterator = editor.bwd(point);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -238,6 +255,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const point = peritext.pointAt(2);
const iterator = editor.bwd(point);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -251,6 +269,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const point = peritext.pointAt(6);
const iterator = editor.bwd(point);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -264,6 +283,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const point = peritext.pointAt(6);
const iterator = editor.bwd(point);
let str = '';
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand All @@ -281,6 +301,7 @@ const runTestsWithAlphabetKit = (setup: () => Kit) => {
const iterator = editor.bwd(start);
let str = '';
const bools: boolean[] = [];
// biome-ignore lint: constant condition is expected
while (1) {
const res = iterator();
if (!res) break;
Expand Down Expand Up @@ -676,6 +697,7 @@ const runParagraphTests = (setup: () => Kit) => {
for (const u of Object.keys(units)) {
const unit = u as TextRangeUnit;
let point = peritext.pointAbsStart();
// biome-ignore lint: constant condition is expected
while (1) {
point = editor.skip(point, 1, unit);
if (!point || point.isRelEnd() || point.isAbsEnd()) break;
Expand All @@ -702,6 +724,7 @@ const runParagraphTests = (setup: () => Kit) => {
for (const u of Object.keys(units)) {
const unit = u as TextRangeUnit;
let point = peritext.pointAbsEnd();
// biome-ignore lint: constant condition is expected
while (1) {
point = editor.skip(point, -1, unit);
if (!point || point.isRelStart() || point.isAbsStart()) break;
Expand Down
1 change: 1 addition & 0 deletions src/json-crdt-extensions/peritext/overlay/Overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ export class Overlay<T = string> implements Printable, Stateful {
const sliceSet = this.slices;
state = updateNum(state, slices.hash);
if (changed) {
// biome-ignore lint: slices is not iterable
slices.forEach((slice) => {
let tuple: [start: OverlayPoint<T>, end: OverlayPoint<T>] | undefined = sliceSet.get(slice);
if (tuple) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const runMarkersTests = (setup: () => Kit) => {
peritext.overlay.refresh();
const list = [...peritext.overlay.markers()];
expect(list.length).toBe(3);
list.forEach((m) => expect(m instanceof MarkerOverlayPoint).toBe(true));
for (const m of list) expect(m instanceof MarkerOverlayPoint).toBe(true);
expect(list[0].marker).toBe(m1);
expect(list[1].marker).toBe(m2);
expect(list[2].marker).toBe(m3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('markers', () => {
peritext.refresh();
expect(markerCount(peritext)).toBe(2);
const points = [];
let point;
let point: any;
for (const iterator = peritext.overlay.markers0(void 0); (point = iterator()); ) points.push(point);
expect(points.length).toBe(2);
expect(points[0].pos()).toBe(2);
Expand Down
Loading

0 comments on commit e19a44f

Please sign in to comment.