Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
0cc51f5
Enable Biome linter with the recommended preset
schani Jul 13, 2026
54359c5
Biome: enable noUnusedImports and fix violations
schani Jul 13, 2026
a37e29f
Biome: enable noUnusedVariables and fix violations
schani Jul 13, 2026
7cc8901
Biome: enable useParseIntRadix and fix violations
schani Jul 13, 2026
54ffb93
Biome: enable noSwitchDeclarations and fix violations
schani Jul 13, 2026
279491f
Biome: enable noConstructorReturn and fix violations
schani Jul 13, 2026
4509283
Biome: enable noVoidTypeReturn and fix violations
schani Jul 13, 2026
c552ebb
Biome: enable noUselessContinue and fix violations
schani Jul 13, 2026
cabd045
Biome: enable noUselessSwitchCase and fix violations
schani Jul 13, 2026
9a54dcf
Biome: enable noUselessTernary and fix violations
schani Jul 13, 2026
e8f5404
Biome: enable noExtraBooleanCast and fix violations
schani Jul 13, 2026
1903654
Biome: enable useDateNow and fix violations
schani Jul 13, 2026
33af22f
Biome: enable useOptionalChain and fix violations
schani Jul 13, 2026
f148807
Biome: enable noUselessConstructor and fix violations
schani Jul 13, 2026
1de619b
Biome: enable noUselessUndefinedInitialization and fix violations
schani Jul 13, 2026
aef7601
Biome: enable noBannedTypes and fix violations
schani Jul 13, 2026
1687b36
Biome: enable useConst and fix violations
schani Jul 13, 2026
b06415a
Biome: enable useExponentiationOperator and fix violations
schani Jul 13, 2026
ebea804
Biome: enable useNodejsImportProtocol and fix violations
schani Jul 13, 2026
14763c5
Biome: enable noNonNullAssertion and fix violations
schani Jul 13, 2026
7b4c90a
Biome: enable useTemplate and fix violations
schani Jul 13, 2026
a96ac4c
Biome: enable useIsArray and fix violations
schani Jul 13, 2026
f1ca818
Biome: enable noTsIgnore and fix violations
schani Jul 13, 2026
c369eeb
Biome: enable noImplicitAnyLet and fix violations
schani Jul 13, 2026
3600d22
Biome: enable noPrototypeBuiltins and fix violations
schani Jul 13, 2026
24b743d
Biome: enable noShadowRestrictedNames and fix violations
schani Jul 13, 2026
4900658
Biome: enable noGlobalIsNan and fix violations
schani Jul 13, 2026
8318461
Biome: enable noUselessEscapeInString and fix violations
schani Jul 13, 2026
e1cbfcd
Biome: enable useIterableCallbackReturn and fix violations
schani Jul 13, 2026
0a63a2f
Biome: enable noExplicitAny and fix violations
schani Jul 13, 2026
f2d4102
Biome: enable noUselessReturn and fix violations
schani Jul 13, 2026
e4df2f0
Biome: enable noUselessElse and fix violations
schani Jul 13, 2026
54e284c
Biome: enable useCollapsedElseIf and fix violations
schani Jul 13, 2026
ecebb49
Biome: enable useCollapsedIf and fix violations
schani Jul 13, 2026
23d8630
Biome: enable useThrowNewError and fix violations
schani Jul 13, 2026
cb8ef4f
Biome: enable useConsistentBuiltinInstantiation
schani Jul 13, 2026
1dbda5b
Biome: enable useObjectSpread and fix violations
schani Jul 13, 2026
60227fa
Biome: enable noYodaExpression and fix violations
schani Jul 13, 2026
9a8b8bb
Biome: enable noSubstr and fix violations
schani Jul 13, 2026
8e6ee26
Biome: enable useExplicitLengthCheck and fix violations
schani Jul 13, 2026
61a830b
Biome: enable noMultiAssign and fix violations
schani Jul 13, 2026
f01f8b2
Biome: enable useConsistentObjectDefinitions and fix violations
schani Jul 13, 2026
fb746dd
Biome: enable useForOf and fix violations
schani Jul 13, 2026
30c91f6
Biome: enable noUnusedTemplateLiteral and fix violations
schani Jul 13, 2026
062c38f
Biome: enable useShorthandAssign and fix violations
schani Jul 13, 2026
3cd2a5d
Biome: enable noInferrableTypes and fix violations
schani Jul 13, 2026
bb34cc2
Biome: enable useDefaultParameterLast and fix violations
schani Jul 13, 2026
5398726
Biome: enable useConsistentMethodSignatures and fix violations
schani Jul 13, 2026
2d76dec
Biome: enable useUnifiedTypeSignatures and fix violations
schani Jul 13, 2026
7d148fc
Biome: enable noNamespace and fix violations
schani Jul 13, 2026
c91f434
Biome: enable useNodeAssertStrict and fix violations
schani Jul 13, 2026
426a4d8
Biome: enable useReadonlyClassProperties and fix violations
schani Jul 13, 2026
46c7a07
Biome: enable noEqualsToNull and fix violations
schani Jul 13, 2026
fa1e5a3
Biome: enable noUnusedExpressions and fix violations
schani Jul 13, 2026
c527fc8
Biome: enable useArraySortCompare and fix violations
schani Jul 13, 2026
1e870d7
Biome: enable noMisplacedAssertion and fix violations
schani Jul 13, 2026
8909926
Biome: enable noShadow and fix violations
schani Jul 13, 2026
5ef7d2d
Biome: enable noUndeclaredDependencies and fix violations
schani Jul 13, 2026
75711a3
Biome: enable noGlobalDirnameFilename and fix violations
schani Jul 13, 2026
46bd87b
Biome: enable zero-violation correctness guard rules
schani Jul 13, 2026
4c99796
Biome: enable zero-violation complexity guard rules
schani Jul 13, 2026
d48cb1c
Biome: enable zero-violation suspicious guard rules
schani Jul 13, 2026
9e67180
Biome: enable zero-violation style guard rules
schani Jul 13, 2026
7f6a000
Biome: enable noDelete (performance), already clean
schani Jul 13, 2026
d791883
Biome: disable noUselessElse per review and revert its changes
schani Jul 13, 2026
831388f
Biome: disable noVoidTypeReturn per review and revert its changes
schani Jul 13, 2026
889d319
Biome: disable noConstructorReturn per review and revert its changes
schani Jul 13, 2026
3738f48
Biome: keep isNullable defaults in DartRenderer's dynamic-expression API
schani Jul 13, 2026
2ddc802
Merge branch 'master' into biome-lint-adoption
schani Jul 13, 2026
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
106 changes: 105 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,114 @@
"indentWidth": 4
},
"linter": {
"enabled": false
"enabled": true,
"rules": {
"preset": "recommended",
"correctness": {
"noUndeclaredDependencies": "on",
"noGlobalDirnameFilename": "on",
"noUnusedInstantiation": "on",
"useSingleJsDocAsterisk": "on",
"noConstructorReturn": "off",
"noVoidTypeReturn": "off"
},
"complexity": {
"noUselessReturn": "on",
"noDivRegex": "on",
"noUselessCatchBinding": "on",
"noUselessStringConcat": "on",
"useArrayFind": "on",
"useWhile": "on",
"noRedundantDefaultExport": "on",
"noExcessiveNestedTestSuites": "on"
},
"performance": {
"noDelete": "on"
},
"style": {
"noUselessElse": "off",
"useCollapsedElseIf": "on",
"useCollapsedIf": "on",
"useThrowNewError": "on",
"useConsistentBuiltinInstantiation": "on",
"useObjectSpread": "on",
"noYodaExpression": "on",
"noSubstr": "on",
"useExplicitLengthCheck": "on",
"noMultiAssign": "on",
"useConsistentObjectDefinitions": "on",
"useForOf": "on",
"noUnusedTemplateLiteral": "on",
"useShorthandAssign": "on",
"noInferrableTypes": "on",
"useDefaultParameterLast": "on",
"useConsistentMethodSignatures": "on",
"useUnifiedTypeSignatures": "on",
"noNamespace": "on",
"useNodeAssertStrict": "on",
"useReadonlyClassProperties": "on",
"useThrowOnlyError": "on",
"useTrimStartEnd": "on",
"useSymbolDescription": "on",
"useSpreadOverApply": "on",
"useNumberNamespace": "on",
"useGlobalThis": "on",
"useErrorCause": "on"
},
"suspicious": {
"noTemplateCurlyInString": "off",
"noEqualsToNull": "on",
"noUnusedExpressions": "on",
"useArraySortCompare": "on",
"noMisplacedAssertion": "on",
"noShadow": "on",
"noConstantBinaryExpressions": "on",
"noVar": "on",
"noFocusedTests": "on",
"noSkippedTests": "on",
"noReturnAssign": "on",
"noDuplicateTestHooks": "on",
"noDeprecatedImports": "on",
"noDuplicateDependencies": "on",
"useErrorMessage": "on",
"noEmptySource": "on"
}
}
},
"assist": { "actions": { "source": { "organizeImports": "off" } } },
"overrides": [
{
"includes": [
"packages/quicktype-core/src/language/CJSON/CJSONRenderer.ts"
],
"linter": {
"rules": {
"suspicious": {
"noShadow": "off"
}
}
}
},
{
"includes": ["test/release-version.ts"],
"linter": {
"rules": {
"suspicious": {
"noMisplacedAssertion": "off"
}
}
}
},
{
"includes": ["packages/quicktype-core/src/**"],
"linter": {
"rules": {
"style": {
"useNodejsImportProtocol": "off"
}
}
}
},
{
"includes": ["**/tsconfig.json", "**/tsconfig.*.json"],
"json": {
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"quicktype-typescript-input": "24.0.0",
"readable-stream": "^4.5.2",
"stream-json": "1.8.0",
"string-to-stream": "^3.0.1"
"string-to-stream": "^3.0.1",
"wordwrap": "^1.0.0"
},
"devDependencies": {
"@biomejs/biome": "^2.5.3",
Expand Down
15 changes: 3 additions & 12 deletions packages/quicktype-core/src/ConvenienceRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
import {
type BlankLineConfig,
type ForEachPosition,
type RenderContext,
Renderer,
} from "./Renderer.js";
import {
Expand All @@ -54,7 +53,6 @@ import {
} from "./support/Comments.js";
import { trimEnd } from "./support/Strings.js";
import { assert, defined, nonNull, panic } from "./support/Support.js";
import type { TargetLanguage } from "./TargetLanguage.js";
import {
type Transformation,
followTargetType,
Expand Down Expand Up @@ -177,13 +175,6 @@ export abstract class ConvenienceRenderer extends Renderer {

private _alphabetizeProperties = false;

public constructor(
targetLanguage: TargetLanguage,
renderContext: RenderContext,
) {
super(targetLanguage, renderContext);
}

public get topLevels(): ReadonlyMap<string, Type> {
return this.typeGraph.topLevels;
}
Expand Down Expand Up @@ -834,9 +825,9 @@ export abstract class ConvenienceRenderer extends Renderer {
(_doubleType) => "double",
(_stringType) => "string",
(arrayType) =>
typeNameForUnionMember(arrayType.items) + "_array",
`${typeNameForUnionMember(arrayType.items)}_array`,
(classType) => lookup(this.nameForNamedType(classType)),
(mapType) => typeNameForUnionMember(mapType.values) + "_map",
(mapType) => `${typeNameForUnionMember(mapType.values)}_map`,
(objectType) => {
assert(
this.targetLanguage.supportsFullObjectType,
Expand Down Expand Up @@ -1275,7 +1266,7 @@ export abstract class ConvenienceRenderer extends Renderer {
// A quote at the end of the line would merge with a closing
// `"""` emitted right after it. The quote needs escaping iff
// it's preceded by an even number of backslashes.
if (lineEnd !== undefined && lineEnd.startsWith('"')) {
if (lineEnd?.startsWith('"')) {
const trailing = /(\\*)"$/.exec(escaped);
if (trailing !== null && trailing[1].length % 2 === 0) {
escaped = `${escaped.slice(0, -1)}\\"`;
Expand Down
2 changes: 0 additions & 2 deletions packages/quicktype-core/src/CycleBreaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ export function breakCycles<T>(
results.push([breakNode, info]);
break;
}

continue;
}

return results;
Expand Down
2 changes: 0 additions & 2 deletions packages/quicktype-core/src/DeclarationIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ export function declarationsForGraph(
for (const t of forwardDeclarable) {
declarations.push({ kind: "define", type: t });
}

return;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion packages/quicktype-core/src/MakeTransformations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function replaceUnion(
);
}

let maybeStringType: TypeRef | undefined = undefined;
let maybeStringType: TypeRef | undefined;
function getStringType(): TypeRef {
if (maybeStringType === undefined) {
maybeStringType = builder.getStringType(
Expand Down
7 changes: 4 additions & 3 deletions packages/quicktype-core/src/MarkovChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ function increment(t: Trie, seq: string, i: number): void {

let st = t.arr[first];
if (st === null) {
t.arr[first] = st = makeTrie();
st = makeTrie();
t.arr[first] = st;
}

if (typeof st !== "object") {
Expand Down Expand Up @@ -116,10 +117,10 @@ export function evaluateFull(
}

scores.push(cp);
p = p * cp;
p *= cp;
}

return [Math.pow(p, 1 / (word.length - depth + 1)), scores];
return [p ** (1 / (word.length - depth + 1)), scores];
}

export function evaluate(mc: MarkovChain, word: string): number {
Expand Down
39 changes: 24 additions & 15 deletions packages/quicktype-core/src/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export type ErrorProperties =
kind: "MiscReadError";
properties: { fileOrURL: string; message: string };
}
| { kind: "MiscUnicodeHighSurrogateWithoutLowSurrogate"; properties: {} }
| {
kind: "MiscUnicodeHighSurrogateWithoutLowSurrogate";
properties: Record<string, never>;
}
| {
kind: "MiscInvalidMinMaxConstraint";
properties: { max: number; min: number };
Expand Down Expand Up @@ -55,23 +58,23 @@ export type ErrorProperties =
}
| {
kind: "SchemaRequiredMustBeStringOrStringArray";
properties: { actual: any; ref: Ref };
properties: { actual: unknown; ref: Ref };
}
| {
kind: "SchemaRequiredElementMustBeString";
properties: { element: any; ref: Ref };
properties: { element: unknown; ref: Ref };
}
| {
kind: "SchemaTypeMustBeStringOrStringArray";
properties: { actual: any };
properties: { actual: unknown };
}
| {
kind: "SchemaTypeElementMustBeString";
properties: { element: any; ref: Ref };
properties: { element: unknown; ref: Ref };
}
| {
kind: "SchemaArrayItemsMustBeStringOrArray";
properties: { actual: any; ref: Ref };
properties: { actual: unknown; ref: Ref };
}
| { kind: "SchemaIDMustHaveAddress"; properties: { id: string; ref: Ref } }
| {
Expand All @@ -80,7 +83,7 @@ export type ErrorProperties =
}
| {
kind: "SchemaSetOperationCasesIsNotArray";
properties: { cases: any; operation: string; ref: Ref };
properties: { cases: unknown; operation: string; ref: Ref };
}
| {
kind: "SchemaMoreThanOneUnionMemberName";
Expand All @@ -98,38 +101,44 @@ export type ErrorProperties =
| { kind: "SchemaFetchErrorAdditional"; properties: { address: string } }

// GraphQL input
| { kind: "GraphQLNoQueriesDefined"; properties: {} }
| { kind: "GraphQLNoQueriesDefined"; properties: Record<string, never> }

// Driver
| { kind: "DriverUnknownSourceLanguage"; properties: { lang: string } }
| { kind: "DriverUnknownOutputLanguage"; properties: { lang: string } }
| { kind: "DriverMoreThanOneInputGiven"; properties: { topLevel: string } }
| { kind: "DriverCannotInferNameForSchema"; properties: { uri: string } }
| { kind: "DriverNoGraphQLQueryGiven"; properties: {} }
| { kind: "DriverNoGraphQLQueryGiven"; properties: Record<string, never> }
| { kind: "DriverNoGraphQLSchemaInDir"; properties: { dir: string } }
| {
kind: "DriverMoreThanOneGraphQLSchemaInDir";
properties: { dir: string };
}
| { kind: "DriverSourceLangMustBeGraphQL"; properties: {} }
| { kind: "DriverGraphQLSchemaNeeded"; properties: {} }
| {
kind: "DriverSourceLangMustBeGraphQL";
properties: Record<string, never>;
}
| { kind: "DriverGraphQLSchemaNeeded"; properties: Record<string, never> }
| { kind: "DriverInputFileDoesNotExist"; properties: { filename: string } }
| {
kind: "DriverCannotMixJSONWithOtherSamples";
properties: { dir: string };
}
| { kind: "DriverCannotMixNonJSONInputs"; properties: { dir: string } }
| { kind: "DriverUnknownDebugOption"; properties: { option: string } }
| { kind: "DriverNoLanguageOrExtension"; properties: {} }
| { kind: "DriverNoLanguageOrExtension"; properties: Record<string, never> }
| { kind: "DriverCLIOptionParsingFailed"; properties: { message: string } }

// IR
| { kind: "IRNoForwardDeclarableTypeInCycle"; properties: {} }
| {
kind: "IRNoForwardDeclarableTypeInCycle";
properties: Record<string, never>;
}
| {
kind: "IRTypeAttributesNotPropagated";
properties: { count: number; indexes: number[] };
}
| { kind: "IRNoEmptyUnions"; properties: {} }
| { kind: "IRNoEmptyUnions"; properties: Record<string, never> }

// Rendering
| {
Expand Down Expand Up @@ -288,7 +297,7 @@ export function messageError<Kind extends ErrorKinds>(
valueString = value;
}

userMessage = userMessage.replace("${" + name + "}", valueString);
userMessage = userMessage.replace(`\${${name}}`, valueString);
}

throw new QuickTypeError(
Expand Down
5 changes: 3 additions & 2 deletions packages/quicktype-core/src/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function lineIndentation(line: string): {
} else if (c === "\t") {
indent = (indent / 4 + 1) * 4;
} else {
return { indent, text: line.substring(i) };
return { indent, text: line.slice(i) };
}
}

Expand All @@ -77,7 +77,8 @@ class EmitContext {
private _preventBlankLine: boolean;

public constructor() {
this._currentEmitTarget = this._emitted = [];
this._emitted = [];
this._currentEmitTarget = this._emitted;
this._numBlankLinesNeeded = 0;
this._preventBlankLine = true; // no blank lines at start of file
}
Expand Down
10 changes: 6 additions & 4 deletions packages/quicktype-core/src/RendererOptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ export class BooleanOption<Name extends string> extends Option<Name, boolean> {
actual: Array<OptionDefinition<Name, boolean>>;
display: Array<OptionDefinition<Name, boolean>>;
} {
const negated = Object.assign({}, this.definition, {
const negated = {
...this.definition,
name: `no-${this.name}`,
defaultValue: !this.definition.defaultValue,
});
const display = Object.assign({}, this.definition, {
} as OptionDefinition<Name, boolean>;
const display = {
...this.definition,
name: `[no-]${this.name}`,
description: `${this.definition.description} (${this.definition.defaultValue ? "on" : "off"} by default)`,
});
} as OptionDefinition<Name, boolean>;
return {
display: [display],
actual: [this.definition, negated],
Expand Down
Loading
Loading