Skip to content

Commit

Permalink
chore: Biome linting with auto-fixes [DT-7060] (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanesawyer authored Feb 10, 2025
1 parent 0cbf74c commit fdecfa9
Show file tree
Hide file tree
Showing 68 changed files with 372 additions and 404 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
# Skip job until we get a linter added
if: false

steps:
- uses: actions/checkout@v4
Expand All @@ -77,7 +75,7 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Lint
run: echo "Add pnpm lint command here"
run: pnpm lint:check

test:
name: Test
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"files": {
"ignoreUnknown": false,
"ignore": []
"ignore": ["**/dist/*"]
},
"formatter": {
"enabled": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { BrowserRouter, Route, Routes } from 'react-router';
import { DziDemo } from './dzi/dzi-demo';
import { Home } from './home';
import { OmezarrDemo } from './omezarr/omezarr-demo';
import { DziDemo } from './dzi/dzi-demo';

export function App() {
return (
Expand Down
3 changes: 2 additions & 1 deletion examples/src/common/image-renderer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { vec2, vec4 } from '@alleninstitute/vis-geometry';
import REGL, { type Framebuffer2D } from 'regl';
import type REGL from 'regl';
import type { Framebuffer2D } from 'regl';

type Props = {
target: Framebuffer2D | null;
Expand Down
4 changes: 2 additions & 2 deletions examples/src/common/loaders/ome-zarr/fetchSlice.worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type ZarrDataset, type ZarrRequest, getSlice } from '@alleninstitute/vis-omezarr';
// a web-worker which fetches slices of data, decodes them, and returns the result as a flat float32 array, using transferables
import type { Chunk } from 'zarrita';
import { type ZarrDataset, type ZarrRequest, getSlice } from '@alleninstitute/vis-omezarr';

const ctx = self;
type ZarrSliceRequest = {
Expand All @@ -11,7 +11,7 @@ type ZarrSliceRequest = {
layerIndex: number;
};
function isSliceRequest(payload: any): payload is ZarrSliceRequest {
return typeof payload === 'object' && payload['type'] === 'ZarrSliceRequest';
return typeof payload === 'object' && payload.type === 'ZarrSliceRequest';
}
ctx.onmessage = (msg: MessageEvent<unknown>) => {
const { data } = msg;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/common/loaders/ome-zarr/sliceWorkerPool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { uniqueId } from 'lodash';
import type { ZarrDataset, ZarrRequest } from '@alleninstitute/vis-omezarr';
import { uniqueId } from 'lodash';

type PromisifiedMessage = {
requestCacheKey: string;
Expand Down
8 changes: 4 additions & 4 deletions examples/src/common/loaders/scatterplot/data.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// todo rename this file

import { Box2D, visitBFS, type box2D, type vec2 } from '@alleninstitute/vis-geometry';
import { Box2D, type box2D, type vec2, visitBFS } from '@alleninstitute/vis-geometry';
import type REGL from 'regl';
import {
fetchColumn,
type ColumnData,
type ColumnRequest,
type ColumnarNode,
type ColumnarTree,
type SlideViewDataset,
fetchColumn,
type loadDataset,
} from './scatterbrain-loader';
import REGL from 'regl';
export type Dataset = ReturnType<typeof loadDataset>;
export type RenderSettings = {
dataset: Dataset;
Expand All @@ -27,7 +27,7 @@ function isVisible(view: box2D, sizeLimit: number, tree: ColumnarTree<vec2>) {
}
export function getVisibleItems(dataset: Dataset, view: box2D, sizeLimit: number) {
const hits: ColumnarTree<vec2>[] = [];
let tree = 'slides' in dataset ? Object.values(dataset.slides)[0].tree : dataset.tree;
const tree = 'slides' in dataset ? Object.values(dataset.slides)[0].tree : dataset.tree;
visitBFS(
tree,
(t: ColumnarTree<vec2>) => t.children,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box2D, Box3D, Vec3, type box, type box3D, type vec2, type vec3 } from '@alleninstitute/vis-geometry';
import { MakeTaggedBufferView, type TaggedTypedArray, type WebGLSafeBasicType } from '../../typed-array';
import type REGL from 'regl';
import { MakeTaggedBufferView, type TaggedTypedArray, type WebGLSafeBasicType } from '../../typed-array';

type volumeBound = {
lx: number;
Expand Down
16 changes: 8 additions & 8 deletions examples/src/data-renderers/annotation-renderer.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type REGL from 'regl';
import type { RenderCallback } from './types';
import { Box2D, Vec2, type box2D, type vec2, type vec4 } from '@alleninstitute/vis-geometry';
import { type AsyncDataCache, type FrameLifecycle, beginLongRunningFrame } from '@alleninstitute/vis-scatterbrain';
import type REGL from 'regl';
import type { Camera } from '~/common/camera';
import type { AnnotationGrid } from '~/data-sources/annotation/annotation-grid';
import { MeshFromAnnotation } from '~/data-sources/annotation/annotation-to-mesh';
import { fetchAnnotation } from '~/data-sources/annotation/fetch-annotation';
import type { AnnotationMesh, GPUAnnotationMesh } from '~/data-sources/annotation/types';
import type { buildLoopRenderer, buildMeshRenderer } from './mesh-renderer';
import type { OptionalTransform } from '~/data-sources/types';
import { AsyncDataCache, beginLongRunningFrame, type FrameLifecycle } from '@alleninstitute/vis-scatterbrain';
import { fetchAnnotation } from '~/data-sources/annotation/fetch-annotation';
import { MeshFromAnnotation } from '~/data-sources/annotation/annotation-to-mesh';
import type { AnnotationGrid } from '~/data-sources/annotation/annotation-grid';
import type { Camera } from '~/common/camera';
import type { buildLoopRenderer, buildMeshRenderer } from './mesh-renderer';
import type { RenderCallback } from './types';

type SlideId = string;

Expand Down
14 changes: 7 additions & 7 deletions examples/src/data-renderers/dynamicGridSlideRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { beginLongRunningFrame, type AsyncDataCache } from '@alleninstitute/vis-scatterbrain';
import type REGL from 'regl';
import { buildRenderer as buildScatterplotRenderer } from './scatterplot';
import { Box2D, Vec2, type vec2 } from '@alleninstitute/vis-geometry';
import { applyOptionalTrn } from './utils';
import { type AsyncDataCache, beginLongRunningFrame } from '@alleninstitute/vis-scatterbrain';
import type REGL from 'regl';
import type { Camera } from '~/common/camera';
import { fetchItem, getVisibleItemsInSlide } from '~/common/loaders/scatterplot/data';
import type { ColumnRequest, ColumnarTree } from '~/common/loaders/scatterplot/scatterbrain-loader';
import type { DynamicGrid, DynamicGridSlide } from '../data-sources/scatterplot/dynamic-grid';
import type { buildRenderer as buildScatterplotRenderer } from './scatterplot';
import type { RenderCallback } from './types';
import { fetchItem, getVisibleItemsInSlide } from '~/common/loaders/scatterplot/data';
import type { ColumnarTree, ColumnRequest } from '~/common/loaders/scatterplot/scatterbrain-loader';
import type { Camera } from '~/common/camera';
import { applyOptionalTrn } from './utils';
type CacheContentType = {
type: 'vbo';
data: REGL.Buffer;
Expand Down
5 changes: 3 additions & 2 deletions examples/src/data-renderers/lineRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { box2D, vec2, vec4 } from '@alleninstitute/vis-geometry';
import REGL, { type AttributeConfig } from 'regl';
import type REGL from 'regl';
import type { AttributeConfig } from 'regl';
import type { ColumnData } from '~/common/loaders/scatterplot/scatterbrain-loader';

type Attrs = { pos: REGL.AttributeConfig };
Expand Down Expand Up @@ -75,7 +76,7 @@ export function buildPathRenderer(regl: REGL.Regl) {
settings: { view: box2D; target: REGL.Framebuffer2D | null },
tasks: Record<string, ColumnData | object | undefined>,
) => {
const pos = tasks['position'];
const pos = tasks.position;
const { view, target } = settings;
if (pos && 'type' in pos && pos.type === 'float') {
cmd(pos.data, item.color, view, target);
Expand Down
4 changes: 2 additions & 2 deletions examples/src/data-renderers/mesh-renderer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { vec4, vec2 } from '@alleninstitute/vis-geometry';
import REGL from 'regl';
import type { vec2, vec4 } from '@alleninstitute/vis-geometry';
import type REGL from 'regl';

const frag = `
precision highp float;
Expand Down
5 changes: 3 additions & 2 deletions examples/src/data-renderers/scatterplot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import REGL, { type Framebuffer2D } from 'regl';
import { Box2D, type box2D, type vec2, type vec4 } from '@alleninstitute/vis-geometry';
import type { ColumnarTree, ColumnBuffer } from '~/common/loaders/scatterplot/scatterbrain-loader';
import type REGL from 'regl';
import type { Framebuffer2D } from 'regl';
import type { RenderSettings } from '~/common/loaders/scatterplot/data';
import type { ColumnBuffer, ColumnarTree } from '~/common/loaders/scatterplot/scatterbrain-loader';

type Props = {
view: vec4;
Expand Down
10 changes: 5 additions & 5 deletions examples/src/data-renderers/simpleAnnotationRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type REGL from 'regl';
import { beginLongRunningFrame, type AsyncDataCache } from '@alleninstitute/vis-scatterbrain';
import type { RenderCallback } from './types';
import { Box2D, type box2D } from '@alleninstitute/vis-geometry';
import type { Path, buildPathRenderer } from './lineRenderer';
import { type AsyncDataCache, beginLongRunningFrame } from '@alleninstitute/vis-scatterbrain';
import { flatten } from 'lodash';
import type { OptionalTransform } from '../data-sources/types';
import type REGL from 'regl';
import type { Camera } from '~/common/camera';
import type { ColumnData } from '~/common/loaders/scatterplot/scatterbrain-loader';
import type { OptionalTransform } from '../data-sources/types';
import type { Path, buildPathRenderer } from './lineRenderer';
import type { RenderCallback } from './types';

type Renderer = ReturnType<typeof buildPathRenderer>;

Expand Down
2 changes: 1 addition & 1 deletion examples/src/data-renderers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box2D, Vec2, type box2D, type vec2 } from '@alleninstitute/vis-geometry';

export function applyOptionalTrn(box: box2D, trn: undefined | { offset: vec2 }, inv: boolean = false) {
export function applyOptionalTrn(box: box2D, trn: undefined | { offset: vec2 }, inv = false) {
// todo scale...
return trn ? Box2D.translate(box, Vec2.scale(trn.offset, inv ? -1 : 1)) : box;
}
11 changes: 6 additions & 5 deletions examples/src/data-renderers/versa-renderer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import REGL, { type Framebuffer2D } from 'regl';
import { Box2D, type Interval, Vec2, type box2D, type vec2, type vec4 } from '@alleninstitute/vis-geometry';
import { omit } from 'lodash';
import {
type ZarrDataset,
type ZarrRequest,
pickBestScale,
planeSizeInVoxels,
sizeInUnits,
type ZarrDataset,
type ZarrRequest,
} from '@alleninstitute/vis-omezarr';
import { getSlicePool } from '~/common/loaders/ome-zarr/sliceWorkerPool';
import { omit } from 'lodash';
import type REGL from 'regl';
import type { Framebuffer2D } from 'regl';
import type { Camera } from '~/common/camera';
import { getSlicePool } from '~/common/loaders/ome-zarr/sliceWorkerPool';

const TILE_SIZE = 256;

Expand Down
20 changes: 10 additions & 10 deletions examples/src/data-renderers/volumeSliceRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { type AsyncDataCache, beginLongRunningFrame } from '@alleninstitute/vis-scatterbrain';
import type REGL from 'regl';
import { beginLongRunningFrame, type AsyncDataCache } from '@alleninstitute/vis-scatterbrain';
import type { RenderCallback } from './types';

import { applyOptionalTrn } from './utils';
import { Box2D, Vec2, type vec2 } from '@alleninstitute/vis-geometry';
import type { AxisAlignedZarrSlice } from '../data-sources/ome-zarr/planar-slice';
import type { AxisAlignedZarrSliceGrid } from '../data-sources/ome-zarr/slice-grid';
import {
pickBestScale,
sizeInUnits,
sizeInVoxels,
sliceDimensionForPlane,
uvForPlane,
} from '@alleninstitute/vis-omezarr';
import type { Camera } from '~/common/camera';
import type { AxisAlignedZarrSlice } from '../data-sources/ome-zarr/planar-slice';
import type { AxisAlignedZarrSliceGrid } from '../data-sources/ome-zarr/slice-grid';
import { applyOptionalTrn } from './utils';
import {
cacheKeyFactory,
getVisibleTiles,
requestsForTile,
type AxisAlignedPlane,
type buildVersaRenderer,
type VoxelSliceRenderSettings,
type VoxelTile,
type buildVersaRenderer,
cacheKeyFactory,
getVisibleTiles,
requestsForTile,
} from './versa-renderer';
import type { Camera } from '~/common/camera';

type Renderer = ReturnType<typeof buildVersaRenderer>;
type CacheContentType = { type: 'texture2D'; data: REGL.Texture2D };
Expand Down Expand Up @@ -113,7 +113,7 @@ export function renderGrid<C extends CacheContentType | object>(
for (let i = 0; i < slices; i++) {
const gridIndex: vec2 = [i % rowSize, Math.floor(i / rowSize)];

let param = i / slices;
const param = i / slices;
const slice: AxisAlignedZarrSlice = {
...grid,
type: 'AxisAlignedZarrSlice',
Expand Down
2 changes: 1 addition & 1 deletion examples/src/data-sources/annotation/annotation-codec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { compileSchema, parseSchema } from 'kiwi-schema';
import type { AnnotationCodec } from './annotation-schema-type';
import { parseSchema, compileSchema } from 'kiwi-schema';

export const AnnotationSchema = `
enum PathCommandType {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/data-sources/annotation/annotation-to-mesh.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type box2D, type vec2, Box2D, Vec2, Vec4 } from '@alleninstitute/vis-geometry';
import { Box2D, Vec2, Vec4, type box2D, type vec2 } from '@alleninstitute/vis-geometry';
import type { Annotation, Path, PathCommand } from './annotation-schema-type';
import type { AnnotationMesh, AnnotationPolygon, ClosedLoop } from './types';
// a helper function, which does a first path over commands, grouping them into closed loops
Expand Down
2 changes: 1 addition & 1 deletion examples/src/data-sources/annotation/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { vec4, box2D } from '@alleninstitute/vis-geometry';
import type { box2D, vec4 } from '@alleninstitute/vis-geometry';
import type REGL from 'regl';

export type ClosedLoop = {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/data-sources/ome-zarr/planar-slice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadMetadata, type ZarrDataset } from '@alleninstitute/vis-omezarr';
import { type ZarrDataset, loadMetadata } from '@alleninstitute/vis-omezarr';
import type { AxisAlignedPlane } from '~/data-renderers/versa-renderer';
import type { ColorMapping } from '../../data-renderers/types';
import type { OptionalTransform, Simple2DTransform } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion examples/src/data-sources/ome-zarr/slice-grid.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadMetadata, type ZarrDataset } from '@alleninstitute/vis-omezarr';
import { type ZarrDataset, loadMetadata } from '@alleninstitute/vis-omezarr';
import type { AxisAlignedPlane } from '~/data-renderers/versa-renderer';
import type { ColorMapping } from '../../data-renderers/types';
import type { OptionalTransform, Simple2DTransform } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion examples/src/data-sources/scatterplot/dynamic-grid.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
type ColumnRequest,
type SlideViewDataset,
loadScatterbrainJson,
isSlideViewData,
loadDataset,
loadScatterbrainJson,
} from '~/common/loaders/scatterplot/scatterbrain-loader';
import type { OptionalTransform, Simple2DTransform } from '../types';

Expand Down
10 changes: 5 additions & 5 deletions examples/src/dzi/dzi-demo.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { DziImage, DziRenderSettings } from '@alleninstitute/vis-dzi';
import { Box2D, type box2D, type vec2 } from '@alleninstitute/vis-geometry';
import { useEffect, useMemo, useRef, useState } from 'react';
import { RenderServerProvider } from '../common/react/render-server-provider';
import React from 'react';
import type { DziImage, DziRenderSettings } from '@alleninstitute/vis-dzi';
import { Box2D, Vec2, type box2D, type vec2 } from '@alleninstitute/vis-geometry';
import { DziViewer } from './dzi-viewer';
import { pan, zoom } from '~/common/camera';
import { RenderServerProvider } from '../common/react/render-server-provider';
import { DziViewer } from './dzi-viewer';

// We know the sizes and formats ahead of time for these examples,
// if you'd like to see how to get this data from an endpoint with a dzi file check out use-dzi-image.ts
Expand Down Expand Up @@ -90,7 +90,7 @@ export function DziDemo() {
<p>Scroll below to view image</p>
<div style={{ display: 'flex', flexDirection: 'row' }}>
{images.map((v) => (
<div style={{ width: screenSize[0], height: screenSize[1] }}>
<div key={v.imagesUrl} style={{ width: screenSize[0], height: screenSize[1] }}>
<DziViewer
id={v.imagesUrl}
dzi={v}
Expand Down
15 changes: 7 additions & 8 deletions examples/src/dzi/dzi-viewer.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { useContext, useEffect, useRef, useState } from 'react';
import {
buildDziRenderer,
type GpuProps as CachedPixels,
type DziImage,
type DziRenderSettings,
type DziTile,
type GpuProps as CachedPixels,
buildAsyncDziRenderer,
buildDziRenderer,
} from '@alleninstitute/vis-dzi';
import { buildAsyncRenderer, type RenderFrameFn } from '@alleninstitute/vis-scatterbrain';
import { Vec2, type vec2 } from '@alleninstitute/vis-geometry';
import type { RenderFrameFn, buildAsyncRenderer } from '@alleninstitute/vis-scatterbrain';
import { useContext, useEffect, useRef, useState } from 'react';
import { renderServerContext } from '~/common/react/render-server-provider';
import React from 'react';

type Props = {
id: string;
Expand All @@ -36,7 +35,7 @@ export function DziViewer(props: Props) {
>();

useEffect(() => {
if (server && server.regl) {
if (server?.regl) {
renderer.current = buildAsyncDziRenderer(server.regl);
}
return () => {
Expand Down Expand Up @@ -74,13 +73,13 @@ export function DziViewer(props: Props) {
server.beginRendering(
renderMyData,
(e) => {
if (e.status == 'begin') {
if (e.status === 'begin') {
server.regl?.clear({
framebuffer: e.target,
color: [0, 0, 0, 0],
depth: 1,
});
} else if (e.status == 'progress' || e.status == 'finished') {
} else if (e.status === 'progress' || e.status === 'finished') {
e.server.copyToClient(compose);
}
},
Expand Down
Loading

0 comments on commit fdecfa9

Please sign in to comment.