Skip to content

Commit cf7524c

Browse files
authored
chore: Setup biome linting (#173)
1 parent 0e6df57 commit cf7524c

40 files changed

+213
-151
lines changed

.changeset/kind-cherries-explain.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@zarrita/typedarray": patch
3+
"@zarrita/indexing": patch
4+
"@zarrita/ndarray": patch
5+
"@zarrita/storage": patch
6+
"@zarrita/core": patch
7+
---
8+
9+
Remove use of public any from API in favor of unknown

biome.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
"linter": {
77
"enabled": true,
88
"rules": {
9-
"recommended": true
9+
"recommended": true,
10+
"style": {
11+
"useConst": "off",
12+
"noParameterAssign": "off"
13+
},
14+
"suspicious": {
15+
"noShadowRestrictedNames": "off"
16+
}
1017
}
1118
},
1219
"files": {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"clean": "pnpm --recursive exec rm -rf dist",
66
"test": "vitest --api",
77
"format": "biome format .",
8-
"lint": "echo \"TODO: Add linting\"",
8+
"lint": "biome lint .",
99
"publint": "pnpm --recursive --filter=\"./packages/**\" exec publint"
1010
},
1111
"devDependencies": {

packages/core/__tests__/consolidated.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe("withConsolidated", () => {
5151
it("loads chunk data from underlying store", async () => {
5252
let root = path.join(__dirname, "../../../fixtures/v2/data.zarr");
5353
let store = await withConsolidated(new FileSystemStore(root));
54+
// biome-ignore lint/style/noNonNullAssertion: Fine for a test
5455
let entry = store
5556
.contents()
5657
.find((x) => x.path === "/3d.chunked.mixed.i2.C")!;
@@ -102,7 +103,7 @@ describe("withConsolidated", () => {
102103
let try_open = () => withConsolidated(new FileSystemStore(root));
103104
await expect(try_open).rejects.toThrowError(NodeNotFoundError);
104105
await expect(try_open).rejects.toThrowErrorMatchingInlineSnapshot(
105-
`[NodeNotFoundError: Node not found: v2 consolidated metadata]`,
106+
"[NodeNotFoundError: Node not found: v2 consolidated metadata]",
106107
);
107108
});
108109
});

packages/core/__tests__/create.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ test("create root group", async () => {
1010
expect(grp.attrs).toStrictEqual(attributes);
1111
expect(grp.store.has("/zarr.json")).true;
1212
expect(
13+
// biome-ignore lint/style/noNonNullAssertion: we know it's there
1314
json_decode_object(grp.store.get("/zarr.json")!),
1415
).toMatchInlineSnapshot(`
1516
{
@@ -38,6 +39,7 @@ test("create array", async () => {
3839
expect(a.chunks).toStrictEqual([2, 5]);
3940
expect(a.attrs).toStrictEqual(attributes);
4041
expect(
42+
// biome-ignore lint/style/noNonNullAssertion: we know it's there
4143
json_decode_object(h.store.get("/arthur/dent/zarr.json")!),
4244
).toMatchInlineSnapshot(`
4345
{

packages/core/__tests__/hierarchy.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe("Array", () => {
6363
});
6464

6565
test("Array.is", () => {
66-
let arr = new Array(new Map(), "/", array_metadata as any);
66+
let arr = new Array(new Map(), "/", array_metadata as ArrayMetadata);
6767
expectTypeOf(arr.dtype).toMatchTypeOf<DataType>();
6868
if (arr.is("bigint")) {
6969
expectTypeOf(arr.dtype).toMatchTypeOf<BigintDataType>();

packages/core/__tests__/json2.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe("JsonCodec", () => {
9090
expect(() => jsonCodec.encode(chunk)).toThrowError();
9191
});
9292
test("throws on encode with check_circular and circular reference", () => {
93-
let data: any[] = ["A", null];
93+
let data: unknown[] = ["A", null];
9494
data[1] = data;
9595
const chunk = {
9696
data,
@@ -102,7 +102,7 @@ describe("JsonCodec", () => {
102102
});
103103
test("supports !allow_nan", () => {
104104
const chunk = {
105-
data: [1, 2, NaN],
105+
data: [1, 2, Number.NaN],
106106
shape: [3],
107107
stride: [1],
108108
};
@@ -117,7 +117,7 @@ describe("JsonCodec", () => {
117117
};
118118
const jsonCodec = new JsonCodec({ sort_keys: true });
119119
const decodedChunk = jsonCodec.decode(jsonCodec.encode(chunk));
120-
expect(Object.keys(decodedChunk.data[0])).toEqual(["1", "2", "3"]);
120+
expect(decodedChunk.data[0]).toEqual({ "1": 1, "2": 2, "3": 3 });
121121
});
122122
test("supports ensure_ascii", () => {
123123
const chunk = {

0 commit comments

Comments
 (0)