chore(lint): replace ESLint with Oxlint and clear anti-slop findings

This commit is contained in:
Chris Scott committed 2026-11-13 01:13:34 -05:00
1 parent c6c13335e5
commit b625acfc0c
1083 files changed
+67089 -80136

No files matched your search

+14 -35
View File
@@ -3,34 +3,24 @@ import { formatBytes, createProgressReporter } from '../src/progress'
import type { ProgressSink } from '../src/progress'
describe('formatBytes', () => {
it('returns "0 B" for 0', () => {
expect(formatBytes(0)).toBe('0 B')
})
it('formats values below 1024 as whole bytes', () => {
expect(formatBytes(1)).toBe('1 B')
expect(formatBytes(500)).toBe('500 B')
expect(formatBytes(1023)).toBe('1023 B')
})
it('formats values at 1024 as KB with one decimal', () => {
expect(formatBytes(1024)).toBe('1.0 KB')
expect(formatBytes(1536)).toBe('1.5 KB')
})
it('formats values at 1 MB as MB with one decimal', () => {
expect(formatBytes(1_048_576)).toBe('1.0 MB')
expect(formatBytes(13_000_000)).toBe('12.4 MB')
})
it('formats values at 1 GB as GB with one decimal', () => {
expect(formatBytes(1_073_741_824)).toBe('1.0 GB')
expect(formatBytes(1_500_000_000)).toBe('1.4 GB')
it.each([
[0, '0 B'],
[1, '1 B'],
[500, '500 B'],
[1023, '1023 B'],
[1024, '1.0 KB'],
[1536, '1.5 KB'],
[1_048_576, '1.0 MB'],
[13_000_000, '12.4 MB'],
[1_073_741_824, '1.0 GB'],
[1_500_000_000, '1.4 GB'],
])('formats %d bytes as %s', (bytes, expected) => {
expect(formatBytes(bytes)).toBe(expected)
})
})
describe('createProgressReporter', () => {
function createSink(isTTY: boolean): { sink: ProgressSink; writes: string[] } {
function createSink(isTTY: boolean) {
const writes: string[] = []
const sink: ProgressSink = {
write(chunk: string) {
@@ -48,19 +38,15 @@ describe('createProgressReporter', () => {
const { sink, writes } = createSink(true)
const reporter = createProgressReporter('Test', sink, now)
// First tick at t=100000
reporter.tick(500)
expect(writes).toHaveLength(1)
expect(writes[0]).toMatch(/^\r\x1b\[K/)
// First frame is '⠋'
expect(writes[0]).toContain('⠋')
expect(writes[0]).toContain('500 B')
// Advance time past throttle window
fakeTime += 100
reporter.tick(1024)
expect(writes).toHaveLength(2)
// Second frame is '⠙'
expect(writes[1]).toContain('⠙')
expect(writes[1]).toContain('1.0 KB')
})
@@ -89,21 +75,16 @@ describe('createProgressReporter', () => {
const { sink, writes } = createSink(true)
const reporter = createProgressReporter('Test', sink, now)
// Render 12 ticks, each 100ms apart (past the 80ms throttle)
for (let i = 0; i < 12; i++) {
reporter.tick(i * 100)
fakeTime += 100
}
expect(writes).toHaveLength(12)
// No write should contain "undefined"
for (const w of writes) {
expect(w).not.toContain('undefined')
}
// After 10 frames, the 11th write cycles back to the first frame '⠋'
// writes[10] is the 11th rendered tick → frameIndex = (0 + 10) % 10 = 0 → '⠋'
expect(writes[10]).toContain('⠋')
// writes[11] is the 12th rendered tick → frameIndex = (0 + 11) % 10 = 1 → '⠙'
expect(writes[11]).toContain('⠙')
})
})
@@ -119,12 +100,10 @@ describe('createProgressReporter', () => {
expect(writes).toHaveLength(1)
expect(writes[0]).toBe('Test: 500 B\n')
// Too soon
fakeTime += 500
reporter.tick(1024)
expect(writes).toHaveLength(1)
// After 1000ms total
fakeTime += 500
reporter.tick(2048)
expect(writes).toHaveLength(2)