Skip to content

Commit c4d4f47

Browse files
committed
Fix a lot of biome suggestions.
1 parent 276099c commit c4d4f47

16 files changed

Lines changed: 72 additions & 36 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ AIDBOX_LICENSE_ID ?=
22

33
TYPECHECK = bunx tsc --noEmit
44
FORMAT = bunx biome format --write
5-
LINT = bunx biome check --diagnostic-level=error --write --unsafe
5+
LINT = bunx biome check --write
66
TEST = bun test
77

88
.PHONY: all typecheck test-typeschema test-register test-codegen test-typescript-r4-example

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"noExcessiveCognitiveComplexity": {
4343
"level": "warn",
4444
"options": {
45-
"maxAllowedComplexity": 50
45+
"maxAllowedComplexity": 39
4646
}
4747
}
4848
},

examples/typescript-r4/demo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,15 @@ function runDemo() {
276276
const patient = createPatient();
277277
console.log("✓ Created patient:", patient.id);
278278

279-
const observation = createObservation(patient.id!);
279+
if (!patient.id) throw new Error("Failed to create patient");
280+
const observation = createObservation(patient.id);
280281
console.log("✓ Created glucose observation:", observation.id);
281282

282283
console.log(`\n${"=".repeat(60)}`);
283284
console.log("Bodyweight profile attach/extract demo:");
284285
console.log("=".repeat(60));
285286

286-
const bodyweightObs = createBodyWeightObservation(patient.id!);
287+
const bodyweightObs = createBodyWeightObservation(patient.id);
287288
console.log("✓ Created body weight observation with profile:", bodyweightObs.id);
288289

289290
const bundle = createBundle(patient, observation, bodyweightObs);

src/api/writer-generator/typescript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ export class TypeScript extends Writer<TypeScriptOptions> {
275275
if (field.enum) {
276276
tsType = tsEnumType(field.enum);
277277
} else if (schema.identifier.name === "Reference" && tsName === "reference") {
278+
// biome-ignore lint: that is exactly string what we want
278279
tsType = "`${T}/${string}`";
279280
} else if (field.reference && field.reference.length > 0) {
280281
const references = field.reference.map((ref) => `"${ref.name}"`).join(" | ");

src/cli/commands/generate.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ export const generateCommand: CommandModule<Record<string, unknown>, GenerateArg
119119

120120
// Configure generators from config
121121
if (config.typescript) {
122-
if (verbose) {
123-
logger.info("Configuring TypeScript generation from config");
124-
logger.debug(`Module format: ${config.typescript.moduleFormat || "esm"}`);
125-
logger.debug(`Generate index: ${config.typescript.generateIndex ?? true}`);
126-
logger.debug(`Include docs: ${config.typescript.includeDocuments ?? false}`);
127-
logger.debug(`Naming convention: ${config.typescript.namingConvention || "PascalCase"}`);
128-
}
129122
throw new Error("Not Implemented");
130123
}
131124

src/cli/commands/typeschema/generate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ export const generateTypeschemaCommand: CommandModule<Record<string, unknown>, G
126126
// Use the output format determined earlier
127127

128128
// Ensure output directory exists
129-
const outputPath = argv.output!;
129+
const outputPath = argv.output;
130+
if (!outputPath) throw new Error("Output format not specified");
130131
await mkdir(dirname(outputPath), { recursive: true });
131132

132133
// Format and write the schemas

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,8 @@ export class ConfigLoader {
731731
}
732732

733733
// Merge with defaults
734-
return this.mergeWithDefaults(validation.config!);
734+
if (!validation.config) throw new Error("Invalid configuration");
735+
return this.mergeWithDefaults(validation.config);
735736
} catch (error) {
736737
if (error instanceof Error) {
737738
throw new Error(`Failed to load config from ${filePath}: ${error.message}`);

src/typeschema/core/field-builder.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { mkBindingIdentifier, mkIdentifier } from "./identifier";
1414
import { mkNestedIdentifier } from "./nested-types";
1515

1616
function isRequired(register: Register, fhirSchema: RichFHIRSchema, path: string[]): boolean {
17-
const fieldName = path[path.length - 1]!;
17+
const fieldName = path[path.length - 1];
18+
if (!fieldName) throw new Error(`Internal error: fieldName is missing for path ${path.join("/")}`);
1819
const parentPath = path.slice(0, -1);
1920

2021
const requires = register.resolveFsGenealogy(fhirSchema.package_meta, fhirSchema.url).flatMap((fs) => {
@@ -116,7 +117,7 @@ export const mkField = (
116117
if (!fieldType)
117118
logger?.warn(`Field type not found for '${fhirSchema.url}#${path.join(".")}' (${fhirSchema.derivation})`);
118119
return {
119-
type: fieldType!,
120+
type: fieldType as Identifier,
120121
required: isRequired(register, fhirSchema, path),
121122
excluded: isExcluded(register, fhirSchema, path),
122123

src/typeschema/core/nested-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function mkNestedTypes(
116116
url: baseUrl,
117117
};
118118

119-
const fields = transformNestedElements(register, fhirSchema, path, element.elements!, logger);
119+
const fields = transformNestedElements(register, fhirSchema, path, element.elements ?? {}, logger);
120120

121121
const nestedType: NestedType = {
122122
identifier,

src/typeschema/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ type ValueSetCompose = {
344344
include: {
345345
concept?: Concept[];
346346
system?: string;
347-
filter?: {}[];
347+
filter?: unknown[];
348348
}[];
349349
};
350350

0 commit comments

Comments
 (0)