mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-08 04:42:57 +00:00
feat: reconfigure typescript linter / formatter for nodejs (#1042)
The eslint rules specify some formatting requirements that are rather strict and conflict with vscode's default formatter. I was unable to get auto-formatting to setup correctly. Also, eslint has quite recently [given up on formatting](https://eslint.org/blog/2023/10/deprecating-formatting-rules/) and recommends using a 3rd party formatter. This PR adds prettier as the formatter. It restores the eslint rules to their defaults. This does mean we now have the "no explicit any" check back on. I know that rule is pedantic but it did help me catch a few corner cases in type testing that weren't covered in the current code. Leaving in draft as this is dependent on other PRs.
This commit is contained in:
@@ -17,55 +17,58 @@ import * as tmp from "tmp";
|
||||
import { Connection, connect } from "../dist/index.js";
|
||||
|
||||
describe("when connecting", () => {
|
||||
|
||||
let tmpDir: tmp.DirResult;
|
||||
beforeEach(() => tmpDir = tmp.dirSync({ unsafeCleanup: true }));
|
||||
beforeEach(() => (tmpDir = tmp.dirSync({ unsafeCleanup: true })));
|
||||
afterEach(() => tmpDir.removeCallback());
|
||||
|
||||
it("should connect", async() => {
|
||||
it("should connect", async () => {
|
||||
const db = await connect(tmpDir.name);
|
||||
expect(db.display()).toBe(`NativeDatabase(uri=${tmpDir.name}, read_consistency_interval=None)`);
|
||||
})
|
||||
expect(db.display()).toBe(
|
||||
`NativeDatabase(uri=${tmpDir.name}, read_consistency_interval=None)`,
|
||||
);
|
||||
});
|
||||
|
||||
it("should allow read consistency interval to be specified", async() => {
|
||||
const db = await connect(tmpDir.name, { readConsistencyInterval: 5});
|
||||
expect(db.display()).toBe(`NativeDatabase(uri=${tmpDir.name}, read_consistency_interval=5s)`);
|
||||
})
|
||||
it("should allow read consistency interval to be specified", async () => {
|
||||
const db = await connect(tmpDir.name, { readConsistencyInterval: 5 });
|
||||
expect(db.display()).toBe(
|
||||
`NativeDatabase(uri=${tmpDir.name}, read_consistency_interval=5s)`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("given a connection", () => {
|
||||
|
||||
let tmpDir: tmp.DirResult
|
||||
let db: Connection
|
||||
let tmpDir: tmp.DirResult;
|
||||
let db: Connection;
|
||||
beforeEach(async () => {
|
||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
||||
db = await connect(tmpDir.name)
|
||||
db = await connect(tmpDir.name);
|
||||
});
|
||||
afterEach(() => tmpDir.removeCallback());
|
||||
|
||||
it("should raise an error if opening a non-existent table", async() => {
|
||||
it("should raise an error if opening a non-existent table", async () => {
|
||||
await expect(db.openTable("non-existent")).rejects.toThrow("was not found");
|
||||
})
|
||||
});
|
||||
|
||||
it("should raise an error if any operation is tried after it is closed", async() => {
|
||||
it("should raise an error if any operation is tried after it is closed", async () => {
|
||||
expect(db.isOpen()).toBe(true);
|
||||
await db.close();
|
||||
expect(db.isOpen()).toBe(false);
|
||||
await expect(db.tableNames()).rejects.toThrow("Connection is closed");
|
||||
})
|
||||
});
|
||||
|
||||
it("should fail if creating table twice, unless overwrite is true", async() => {
|
||||
it("should fail if creating table twice, unless overwrite is true", async () => {
|
||||
let tbl = await db.createTable("test", [{ id: 1 }, { id: 2 }]);
|
||||
await expect(tbl.countRows()).resolves.toBe(2);
|
||||
await expect(db.createTable("test", [{ id: 1 }, { id: 2 }])).rejects.toThrow();
|
||||
await expect(
|
||||
db.createTable("test", [{ id: 1 }, { id: 2 }]),
|
||||
).rejects.toThrow();
|
||||
tbl = await db.createTable("test", [{ id: 3 }], { mode: "overwrite" });
|
||||
await expect(tbl.countRows()).resolves.toBe(1);
|
||||
})
|
||||
});
|
||||
|
||||
it("should list tables", async() => {
|
||||
it("should list tables", async () => {
|
||||
await db.createTable("test2", [{ id: 1 }, { id: 2 }]);
|
||||
await db.createTable("test1", [{ id: 1 }, { id: 2 }]);
|
||||
expect(await db.tableNames()).toEqual(["test1", "test2"]);
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user