Skip to content

Commit 3a1f202

Browse files
authored
Merge pull request #549 from NERSC/update-lint
biome lint/format update
2 parents b783ebe + 3d60d63 commit 3a1f202

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+232
-191
lines changed

Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,13 @@ gen: ## Generate client, models, and type definitions (gen-client + pydantic-to-
104104

105105
lint: ## Run backend (ruff) and frontend (biome) linters
106106
@echo "Running ruff linter..."
107-
. .venv/bin/activate && poetry run ruff check .
107+
@if command -v ruff >/dev/null 2>&1; then \
108+
ruff check .; \
109+
else \
110+
echo "Warning: 'ruff' not found in PATH; skipping backend lint." >&2; \
111+
fi
108112
@echo "Running biome linter..."
109-
cd $(FRONTEND_DIR) && npx biome check \
110-
--formatter-enabled=true \
111-
--linter-enabled=true \
112-
--assists-enabled=true \
113-
--write \
114-
./src
113+
cd $(FRONTEND_DIR) && npm run lint
115114
$(call success,Linting complete)
116115

117116
## Set up local Docker registry for operator builds

frontend/interactEM/biome.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
{
22
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
3-
"organizeImports": {
4-
"enabled": true
5-
},
3+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
64
"files": {
7-
"ignore": ["node_modules", "dist"]
5+
"includes": [
6+
"**",
7+
"!**/node_modules",
8+
"!**/dist",
9+
"!**/dist_app",
10+
"!**/playwright-report",
11+
"!**/bundle-visualization",
12+
"!**/bundle-visualization.html"
13+
]
814
},
915
"overrides": [
1016
{
11-
"include": ["src/client/generated/**"],
17+
"includes": ["**/src/client/generated/**"],
1218
"linter": {
1319
"enabled": false
1420
}
@@ -22,13 +28,6 @@
2228
"noUnusedImports": {
2329
"level": "error"
2430
}
25-
},
26-
"suspicious": {
27-
"noExplicitAny": "off",
28-
"noArrayIndexKey": "off"
29-
},
30-
"style": {
31-
"noNonNullAssertion": "off"
3231
}
3332
}
3433
},

frontend/interactEM/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build:lib": "tsc && vite build --config vite.config.ts",
2121
"build:app": "tsc && vite build --config vite.config.app.ts",
2222
"build": "npm run build:lib && npm run build:app",
23-
"lint": "biome check --unsafe --assists-enabled=true --no-errors-on-unmatched --files-ignore-unknown=true ./",
23+
"lint": "npx biome check --write .",
2424
"preview": "vite preview",
2525
"generate-client": "openapi-ts",
2626
"deduplicate-enums": "tsx scripts/deduplicate-enums.ts src/types/gen.ts",
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import { devices, defineConfig } from '@playwright/test';
1+
import { defineConfig, devices } from "@playwright/test"
22

3-
const port = process.env.PLAYWRIGHT_PORT ?? '5173';
4-
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? `http://localhost:${port}`;
5-
const isCI = !!process.env.CI;
6-
const webServerCommand = `npm run dev -- --host --port ${port}`;
3+
const port = process.env.PLAYWRIGHT_PORT ?? "5173"
4+
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? `http://localhost:${port}`
5+
const isCI = !!process.env.CI
6+
const webServerCommand = `npm run dev -- --host --port ${port}`
77

88
export default defineConfig({
9-
testDir: './tests',
9+
testDir: "./tests",
1010
fullyParallel: true,
1111
forbidOnly: !!process.env.CI,
1212
retries: process.env.CI ? 2 : 0,
1313
workers: process.env.CI ? 1 : undefined,
1414
reporter:
15-
process.env.CI === 'true'
16-
? [['line'], ['github']]
15+
process.env.CI === "true"
16+
? [["line"], ["github"]]
1717
: [
18-
['line'],
19-
['html', { open: 'on-failure', outputFolder: 'playwright-report' }],
18+
["line"],
19+
["html", { open: "on-failure", outputFolder: "playwright-report" }],
2020
],
2121
use: {
2222
baseURL,
23-
trace: 'on-first-retry',
23+
trace: "on-first-retry",
2424
},
2525
webServer: {
2626
command: webServerCommand,
@@ -30,16 +30,16 @@ export default defineConfig({
3030
},
3131
projects: [
3232
{
33-
name: 'chromium',
34-
use: { ...devices['Desktop Chrome'] },
33+
name: "chromium",
34+
use: { ...devices["Desktop Chrome"] },
3535
},
3636
{
37-
name: 'firefox',
38-
use: { ...devices['Desktop Firefox'] },
37+
name: "firefox",
38+
use: { ...devices["Desktop Firefox"] },
3939
},
4040
{
41-
name: 'webkit',
42-
use: { ...devices['Desktop Safari'] },
41+
name: "webkit",
42+
use: { ...devices["Desktop Safari"] },
4343
},
4444
],
45-
});
45+
})
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Project, SyntaxKind } from "ts-morph";
1+
import { Project, SyntaxKind } from "ts-morph"
22

33
/**
44
* Deduplicates enum definitions in a TypeScript file.
@@ -7,58 +7,58 @@ import { Project, SyntaxKind } from "ts-morph";
77
* This script consolidates them into a single canonical definition.
88
*/
99
async function deduplicateEnums(filePath: string): Promise<void> {
10-
console.log(`Cleaning up duplicate enums in ${filePath}...`);
10+
console.log(`Cleaning up duplicate enums in ${filePath}...`)
1111

12-
const project = new Project();
13-
const sourceFile = project.addSourceFileAtPath(filePath);
12+
const project = new Project()
13+
const sourceFile = project.addSourceFileAtPath(filePath)
1414

1515
const enumsToClean = [
1616
"NodeType",
1717
"PortType",
1818
"OperatorEventType",
1919
"DeploymentEventType",
2020
"ParameterSpecType",
21-
];
21+
]
2222

2323
for (const baseName of enumsToClean) {
2424
const enumDeclarations = sourceFile
2525
.getEnums()
26-
.filter((e) => e.getName().match(new RegExp(`^${baseName}\\d*$`)));
26+
.filter((e) => e.getName().match(new RegExp(`^${baseName}\\d*$`)))
2727

2828
if (enumDeclarations.length === 0) {
29-
continue;
29+
continue
3030
}
3131

3232
// Find the canonical enum (without numbers), or use the first one
3333
const canonicalEnum =
3434
enumDeclarations.find((e) => e.getName() === baseName) ||
35-
enumDeclarations[0];
36-
const enumsToRemove = enumDeclarations.filter((e) => e !== canonicalEnum);
35+
enumDeclarations[0]
36+
const enumsToRemove = enumDeclarations.filter((e) => e !== canonicalEnum)
3737

3838
// Update all numbered enum references to point to the base name
3939
sourceFile.getDescendantsOfKind(SyntaxKind.Identifier).forEach((node) => {
40-
const text = node.getText();
41-
const match = text.match(new RegExp(`^${baseName}\\d+$`));
40+
const text = node.getText()
41+
const match = text.match(new RegExp(`^${baseName}\\d+$`))
4242
if (match) {
43-
node.replaceWithText(baseName);
43+
node.replaceWithText(baseName)
4444
}
45-
});
45+
})
4646

4747
// Remove duplicate enum declarations
4848
enumsToRemove.forEach((enumDecl) => {
49-
enumDecl.remove();
50-
});
49+
enumDecl.remove()
50+
})
5151

5252
console.log(
53-
` ✓ Consolidated ${enumDeclarations.length} definition(s) for ${baseName}`
54-
);
53+
` ✓ Consolidated ${enumDeclarations.length} definition(s) for ${baseName}`,
54+
)
5555
}
5656

5757
// Save the cleaned file
58-
await sourceFile.save();
59-
console.log("Cleanup complete.");
58+
await sourceFile.save()
59+
console.log("Cleanup complete.")
6060
}
6161

6262
// Execute
63-
const filePath = "src/types/gen.ts";
64-
await deduplicateEnums(filePath);
63+
const filePath = "src/types/gen.ts"
64+
await deduplicateEnums(filePath)

frontend/interactEM/src/App.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import InteractEM from "./pages/interactem"
22

33
export default function App() {
4-
return (
5-
<>
6-
<InteractEM authMode="internal" />
7-
</>
8-
)
4+
return <InteractEM authMode="internal" />
95
}

frontend/interactEM/src/auth/base.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type ReactNode, createContext, useContext } from "react"
1+
import { createContext, type ReactNode, useContext } from "react"
22

33
// Both internal/external auth implement this
44
export type AuthState = {

frontend/interactEM/src/client/generated/@tanstack/react-query.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
import {
44
type DefaultError,
55
type InfiniteData,
6-
type UseMutationOptions,
76
infiniteQueryOptions,
87
queryOptions,
8+
type UseMutationOptions,
99
} from "@tanstack/react-query"
1010
import type { AxiosError } from "axios"
1111

1212
import { client } from "../client.gen"
1313
import {
14-
type Options,
1514
agentsLaunchAgent,
1615
deploymentsCreateOperatorEvent,
1716
deploymentsCreatePipelineDeployment,
@@ -21,6 +20,7 @@ import {
2120
loginLoginAccessToken,
2221
loginLoginWithExternalToken,
2322
loginTestToken,
23+
type Options,
2424
operatorsReadOperators,
2525
pipelinesAddPipelineRevision,
2626
pipelinesCreatePipeline,

frontend/interactEM/src/client/generated/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export {
1010
loginLoginAccessToken,
1111
loginLoginWithExternalToken,
1212
loginTestToken,
13-
operatorsReadOperators,
1413
type Options,
14+
operatorsReadOperators,
1515
pipelinesAddPipelineRevision,
1616
pipelinesCreatePipeline,
1717
pipelinesDeletePipeline,
@@ -114,8 +114,8 @@ export type {
114114
PipelineCreate,
115115
PipelineDeploymentCreate,
116116
PipelineDeploymentPublic,
117-
PipelineDeploymentsPublic,
118117
PipelineDeploymentState,
118+
PipelineDeploymentsPublic,
119119
PipelineDeploymentUpdate,
120120
PipelinePublic,
121121
PipelineRevisionCreate,

frontend/interactEM/src/client/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
export * from "./generated"
22
export * from "./generated/@tanstack/react-query.gen"
3-
export * from "./generated/client.gen"
43
export { createClient } from "./generated/client"
4+
export * from "./generated/client.gen"
5+
56
import { z } from "zod"
67
import {
78
zAgentCreateEvent as zAgentCreateEventTmp,
89
zPipelineCreate as zPipelineCreateTmp,
910
zPipelinePublic as zPipelinePublicTmp,
1011
zPipelineRevisionCreate as zPipelineRevisionCreateTmp,
11-
zPipelineUpdate as zPipelineUpdateTmp,
1212
zPipelinesPublic as zPipelinesPublicTmp,
13+
zPipelineUpdate as zPipelineUpdateTmp,
1314
} from "./generated/zod.gen"
1415

1516
export const zAgentCreateEvent = zAgentCreateEventTmp.extend({

0 commit comments

Comments
 (0)