Add Prettier and ESLint tooling (Refs #77)

This commit is contained in:
2026-10-09 15:56:13 -04:00
parent 8ed059b8d3
commit 16469e2d43
711 changed files with 99737 additions and 28286 deletions
+22 -6
View File
@@ -7,17 +7,31 @@ afterEach(() => vi.restoreAllMocks());
it('preserves results and errors, logs slow query shapes without values', () => {
const db = new Database(':memory:');
const log = vi.spyOn(console, 'warn').mockImplementation(() => {});
vi.spyOn(performance, 'now').mockReturnValueOnce(0).mockReturnValueOnce(21)
.mockReturnValueOnce(30).mockReturnValueOnce(31).mockReturnValueOnce(40).mockReturnValueOnce(62);
vi.spyOn(performance, 'now')
.mockReturnValueOnce(0)
.mockReturnValueOnce(21)
.mockReturnValueOnce(30)
.mockReturnValueOnce(31)
.mockReturnValueOnce(40)
.mockReturnValueOnce(62);
try {
const query = timeStatement(db.prepare("SELECT ? AS value, 'private''literal' AS literal"), "SELECT ? AS value, 'private''literal' AS literal", 20);
const query = timeStatement(
db.prepare("SELECT ? AS value, 'private''literal' AS literal"),
"SELECT ? AS value, 'private''literal' AS literal",
20
);
expect(query.get('secret')).toEqual({ value: 'secret', literal: "private'literal" });
expect(query.all('other')).toHaveLength(1);
expect(() => query.get()).toThrow();
expect(log).toHaveBeenCalledTimes(2);
expect(log.mock.calls[0]).toEqual(['[sql]', { ms: 21, method: 'get', sql: 'SELECT ? AS value, ? AS literal' }]);
expect(log.mock.calls[0]).toEqual([
'[sql]',
{ ms: 21, method: 'get', sql: 'SELECT ? AS value, ? AS literal' }
]);
expect(JSON.stringify(log.mock.calls)).not.toMatch(/secret|private|other/);
} finally { db.close(); }
} finally {
db.close();
}
});
it('does not wrap statements when disabled or invalid', () => {
@@ -28,5 +42,7 @@ it('does not wrap statements when disabled or invalid', () => {
for (const threshold of [0, -1, NaN, Infinity]) {
expect(timeStatement(statement, 'SELECT 1', threshold).get).toBe(get);
}
} finally { db.close(); }
} finally {
db.close();
}
});