Skip to content

Commit

Permalink
chore: Migrate dprint formatting to biome (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt authored May 10, 2024
1 parent 2779aba commit 0e6df57
Show file tree
Hide file tree
Showing 46 changed files with 3,085 additions and 2,650 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ jobs:
version: 8
- run: |
pnpm install
pnpm format
pnpm lint
15 changes: 15 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"files": {
"ignore": ["fixtures", "**/dist", "docs/.vitepress/cache", ".changeset"]
}
}
13 changes: 8 additions & 5 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ export default defineConfig({
title: "zarrita.js",
description: "Zarr building blocks for JavaScript",
head: [
["link", {
rel: "icon",
type: "image/svg+xml",
href: "/favicon.svg",
}],
[
"link",
{
rel: "icon",
type: "image/svg+xml",
href: "/favicon.svg",
},
],
],
themeConfig: {
logo: {
Expand Down
25 changes: 0 additions & 25 deletions dprint.json

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"build": "tsc --build",
"clean": "pnpm --recursive exec rm -rf dist",
"test": "vitest --api",
"fmt": "dprint fmt",
"lint": "dprint check",
"format": "biome format .",
"lint": "echo \"TODO: Add linting\"",
"publint": "pnpm --recursive --filter=\"./packages/**\" exec publint"
},
"devDependencies": {
"@biomejs/biome": "1.7.3",
"@changesets/cli": "^2.27.1",
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
"@types/node": "^20.12.2",
"dprint": "^0.45.1",
"publint": "^0.2.2",
"typescript": "^5.4.5",
"vitest": "^1.5.3"
Expand Down
10 changes: 4 additions & 6 deletions packages/core/__tests__/consolidated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ describe("withConsolidated", () => {
it("loads consolidated metadata", async () => {
let root = path.join(__dirname, "../../../fixtures/v2/data.zarr");
let store = await withConsolidated(new FileSystemStore(root));
let map = new Map(
store.contents().map((x) => [x.path, x.kind]),
);
let map = new Map(store.contents().map((x) => [x.path, x.kind]));
expect(map).toMatchInlineSnapshot(`
Map {
"/" => "group",
Expand Down Expand Up @@ -53,9 +51,9 @@ describe("withConsolidated", () => {
it("loads chunk data from underlying store", async () => {
let root = path.join(__dirname, "../../../fixtures/v2/data.zarr");
let store = await withConsolidated(new FileSystemStore(root));
let entry = store.contents().find((x) =>
x.path === "/3d.chunked.mixed.i2.C"
)!;
let entry = store
.contents()
.find((x) => x.path === "/3d.chunked.mixed.i2.C")!;
let grp = await open(store, { kind: "group" });
let arr = await open(grp.resolve(entry.path), { kind: entry.kind });
expect(arr).toBeInstanceOf(ZarrArray);
Expand Down
10 changes: 6 additions & 4 deletions packages/core/__tests__/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ test("create root group", async () => {
expect(grp.path).toBe("/");
expect(grp.attrs).toStrictEqual(attributes);
expect(grp.store.has("/zarr.json")).true;
expect(json_decode_object(grp.store.get("/zarr.json")!))
.toMatchInlineSnapshot(`
expect(
json_decode_object(grp.store.get("/zarr.json")!),
).toMatchInlineSnapshot(`
{
"attributes": {
"hello": "world",
Expand All @@ -36,8 +37,9 @@ test("create array", async () => {
expect(a.dtype).toBe("int32");
expect(a.chunks).toStrictEqual([2, 5]);
expect(a.attrs).toStrictEqual(attributes);
expect(json_decode_object(h.store.get("/arthur/dent/zarr.json")!))
.toMatchInlineSnapshot(`
expect(
json_decode_object(h.store.get("/arthur/dent/zarr.json")!),
).toMatchInlineSnapshot(`
{
"attributes": {
"answer": 42,
Expand Down
41 changes: 4 additions & 37 deletions packages/core/__tests__/json2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ describe("JsonCodec", () => {
// import numpy as np
// json_codec = JSON()
// json_codec.encode(np.array(['ASC1', 'ASC2', 'END', 'GABA1', 'GABA2', 'MG', 'NSC', 'ODC1', 'OPC', 'Unclassified', 'exCA1', 'exCA3', 'exDG', 'exPFC1', 'exPFC2'], dtype=object))
const encodedStr =
`["ASC1","ASC2","END","GABA1","GABA2","MG","NSC","ODC1","OPC","Unclassified","exCA1","exCA3","exDG","exPFC1","exPFC2","|O",[15]]`;
const encodedStr = `["ASC1","ASC2","END","GABA1","GABA2","MG","NSC","ODC1","OPC","Unclassified","exCA1","exCA3","exDG","exPFC1","exPFC2","|O",[15]]`;
const encodedBytes = new TextEncoder().encode(encodedStr);
const jsonCodec = new JsonCodec({ encoding: "utf-8" });
const decodedResult = jsonCodec.decode(encodedBytes);
Expand All @@ -36,8 +35,7 @@ describe("JsonCodec", () => {
});
});
test("can encode", () => {
const encodedStr =
`["ASC1","ASC2","END","GABA1","GABA2","MG","NSC","ODC1","OPC","Unclassified","exCA1","exCA3","exDG","exPFC1","exPFC2","|O",[15]]`;
const encodedStr = `["ASC1","ASC2","END","GABA1","GABA2","MG","NSC","ODC1","OPC","Unclassified","exCA1","exCA3","exDG","exPFC1","exPFC2","|O",[15]]`;
const encodedBytes = new TextEncoder().encode(encodedStr);

const chunk = {
Expand Down Expand Up @@ -132,24 +130,7 @@ describe("JsonCodec", () => {
const decodedChunk = jsonCodec.decode(encodedChunk);
expect(decodedChunk.data).toEqual(["£"]);
expect(Array.from(encodedChunk)).toEqual([
91,
34,
92,
117,
48,
48,
97,
51,
34,
44,
34,
124,
79,
34,
44,
91,
49,
93,
91, 34, 92, 117, 48, 48, 97, 51, 34, 44, 34, 124, 79, 34, 44, 91, 49, 93,
93,
]);
});
Expand All @@ -164,21 +145,7 @@ describe("JsonCodec", () => {
const decodedChunk = jsonCodec.decode(encodedChunk);
expect(decodedChunk.data).toEqual(["£"]);
expect(Array.from(encodedChunk)).toEqual([
91,
34,
194,
163,
34,
44,
34,
124,
79,
34,
44,
91,
49,
93,
93,
91, 34, 194, 163, 34, 44, 34, 124, 79, 34, 44, 91, 49, 93, 93,
]);
});
});
Loading

0 comments on commit 0e6df57

Please sign in to comment.