Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Biome linting with auto-fixes [DT-7060] #53

Merged
merged 25 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f9d9902
chore: Install biome
lanesawyer Feb 28, 2024
29cf1f3
Add fmt command
lanesawyer Feb 28, 2024
4881c4e
Add lint command
lanesawyer Feb 28, 2024
eebd3dc
Tweak config to not run on generated files
lanesawyer Feb 28, 2024
693c40a
Add check command to check lint and format
lanesawyer Feb 28, 2024
035a169
Add check:fix command
lanesawyer Feb 28, 2024
d5f045f
Documentation on linter and formatter
lanesawyer Feb 28, 2024
56335f2
Merge branch 'main' into lane/biome
lanesawyer Mar 18, 2024
3c664c5
Merge branch 'main' into lane/biome
lanesawyer Mar 22, 2024
66adb1b
Change ignored files directory after Parcel merge
lanesawyer Mar 22, 2024
a86ed47
Biome at root level to enable VS Code plugin, extends base config
lanesawyer Mar 22, 2024
d99631e
Merge branch 'main' into lane/biome
lanesawyer Feb 1, 2025
1021c1d
Add biome commands to package.json
lanesawyer Feb 1, 2025
bf27ef2
Remove prettier
lanesawyer Feb 1, 2025
251cf93
Merge branch 'main' into lane/biome
lanesawyer Feb 7, 2025
9e176c5
Apply biome fixes
lanesawyer Feb 7, 2025
6d5d16c
Fixing errors in examples
lanesawyer Feb 7, 2025
e9415c2
Tweak command based on API change warning
lanesawyer Feb 7, 2025
ef4ed85
Get ready to merge in main
lanesawyer Feb 10, 2025
6d6513b
Merge branch 'main' into lane/biome
lanesawyer Feb 10, 2025
3fee4f6
Auto fix, also ignore `dist` folders
lanesawyer Feb 10, 2025
980d406
Run lint command on CI
lanesawyer Feb 10, 2025
b0edfb4
Fix type error from bad merge line
lanesawyer Feb 10, 2025
e17ae58
Fix TS React config
lanesawyer Feb 10, 2025
19a1fea
Don't skip lint job!
lanesawyer Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading