chore: strengthen backend eslint profile

This commit is contained in:
2026-09-28 11:04:18 +03:00
parent ca5dbcb382
commit 9b3558f96c
179 changed files with 4485 additions and 2716 deletions
@@ -67,7 +67,7 @@ describe('source-confirmed daily candle coverage', () => {
expect(window.to.valueOf() - window.from.valueOf()).toBeLessThanOrEqual(
365 * 86400000,
);
if (index) expect(window.from).toEqual(windows[index - 1].to);
expect(window.from).toEqual(index ? windows[index - 1].to : range.from);
});
});
});
@@ -2,13 +2,13 @@ import { MILLISECONDS_PER_DAY } from '../../../../common/time';
export type CandleRange = { from: Date; to: Date };
export type CandleCoverage = CandleRange & {
isComplete: boolean;
fetchedAt: Date;
isComplete: boolean;
};
export type SavedCandle = {
time: string;
close: string;
isComplete: boolean;
time: string;
};
const windowDays = 365;
const tailFreshForMs = 60_000;
@@ -30,14 +30,15 @@ export function candleGaps(
!covered.isComplete &&
(now.valueOf() - covered.fetchedAt.valueOf() >= tailFreshForMs ||
utcDay(now).valueOf() !== utcDay(covered.fetchedAt).valueOf())
)
) {
continue;
}
gaps = gaps.flatMap((gap) => {
if (covered.to <= gap.from || covered.from >= gap.to) return [gap];
return [
...(covered.from > gap.from
? [{ from: gap.from, to: covered.from }]
: []),
...(covered.from > gap.from ?
[{ from: gap.from, to: covered.from }] :
[]),
...(covered.to < gap.to ? [{ from: covered.to, to: gap.to }] : []),
];
});
@@ -73,11 +74,14 @@ export function confirmedCandleCoverage(
for (const boundary of [
midnight,
...[...incompleteDays].flatMap((day) => [day, day + MILLISECONDS_PER_DAY]),
])
if (boundary > range.from.valueOf() && boundary < range.to.valueOf())
]) {
if (boundary > range.from.valueOf() && boundary < range.to.valueOf()) {
boundaries.add(boundary);
}
}
const sorted = [...boundaries].sort((a, b) => a - b);
return sorted.slice(1).map((to, index) => {
// eslint-disable-next-line security/detect-object-injection -- The index comes from the sorted numeric boundary array.
const from = sorted[index];
return {
from: new Date(from),