From 342f9f3b82b1d1daf0bb571d7ea143674d83716d Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:43:42 +0000 Subject: [PATCH] style: format code with Prettier This commit fixes the style issues introduced in 317deef according to the output from Prettier. Details: None --- FAQ.md | 23 +- PACKAGES.md | 12 +- doc/Transformers.md | 10 +- packages/quicktype-core/src/DeclarationIR.ts | 5 +- packages/quicktype-core/src/Naming.ts | 17 +- packages/quicktype-core/src/Renderer.ts | 5 +- packages/quicktype-core/src/Source.ts | 2 +- packages/quicktype-core/src/TargetLanguage.ts | 6 +- packages/quicktype-core/src/Transformers.ts | 47 +++- packages/quicktype-core/src/Type.ts | 39 +++- packages/quicktype-core/src/TypeGraph.ts | 5 +- .../src/input/CompressedJSON.ts | 5 +- .../quicktype-core/src/language/CPlusPlus.ts | 5 +- packages/quicktype-core/src/language/Java.ts | 5 +- .../quicktype-core/src/language/Scala3.ts | 147 +++++++------ .../quicktype-core/src/language/Smithy4s.ts | 200 +++++++++--------- packages/quicktype-core/src/language/Swift.ts | 8 +- test/fixtures.ts | 15 +- test/fixtures/elm/runner.js | 10 +- test/fixtures/haskell/package.yaml | 18 +- test/fixtures/haskell/stack.yaml | 2 +- test/fixtures/javascript-prop-types/main.js | 4 +- test/fixtures/typescript-zod/main.ts | 1 - test/inputs/graphql/github1.graphql | 8 +- test/inputs/graphql/github2.graphql | 16 +- test/inputs/graphql/github3.graphql | 16 +- test/inputs/graphql/github4.graphql | 20 +- test/inputs/graphql/github5.graphql | 8 +- test/inputs/graphql/github6.graphql | 10 +- test/inputs/graphql/github7.graphql | 44 ++-- test/inputs/graphql/github8.graphql | 32 +-- test/inputs/graphql/github9.graphql | 26 +-- 32 files changed, 450 insertions(+), 321 deletions(-) diff --git a/FAQ.md b/FAQ.md index 34beed013..f557747ac 100644 --- a/FAQ.md +++ b/FAQ.md @@ -15,7 +15,7 @@ - [I'd like to customize the output for my particular application.](#id-like-to-customize-the-output-for-my-particular-application) - [How can I control the property order in JSON Schema?](#how-can-i-control-the-property-order-in-json-schema) - [quicktype is awesome, I'd like to support it!](#quicktype-is-awesome-id-like-to-support-it) -- [How is this different from other JSON converters?](#how-is-quicktype-different-from-other-json-converters) +- [How is this different from other JSON converters?](#how-is-quicktype-different-from-other-json-converters) ## What is this? @@ -29,16 +29,16 @@ You paste JSON on the left, and code appears on the right. [This video](https:// `quicktype` is superior to other JSON converters in many important ways: -- **Type inference**: quicktype infers optionals, dates, UUIDs, enums, integers, and unions. It also infers maps (versus objects) using a Markov chain. -- **Careful naming**: quicktype’s naming system creates nice, legal, unique names for types and properties, handling reserved words and tricky corner cases (e.g. `{ “”: “this is legal”, “null”: “so is this”, "1;DROP TABLE users”: “and this" }`). -- **Heterogeneous data**: JSON data is often heterogenous. quicktype infers this, and creates union types in languages that support them, or synthetic union types in languages that don’t (e.g. try quicktyping `[0, “zero”]` as Swift and Go). -- **Type unification**. This works across multiple samples, so you can quicktype a directory of API data, for example, and unify types across all responses (e.g. you’ll get just one `Customer` type, even if customer data occurs in many samples). You can also provide multiple samples for the same type for better coverage. -- **Marshalling code**: In addition to types, quicktype generates functions for marshalling your types to and from JSON. -- Supports dynamic languages: quicktype can add dynamic typechecks for JavaScript, TypeScript, Flow, Python, and Ruby. -- **Convenient CLI**: Run `quicktype https://blockchain.info/latestblock -o LatestBlock.ts` to quicktype a Bitcoin API in TypeScript. -- **Client-side**: [The web version of quicktype](https://app.quicktype.io/) runs on the client, so servers never see your data (most JSON converters send your JSON to their server) -- **Typed input**: Feed quicktype TypeScript or JSON Schema instead of JSON for better control over generated types. -- **Code quality**: quicktype emits clean code +- **Type inference**: quicktype infers optionals, dates, UUIDs, enums, integers, and unions. It also infers maps (versus objects) using a Markov chain. +- **Careful naming**: quicktype’s naming system creates nice, legal, unique names for types and properties, handling reserved words and tricky corner cases (e.g. `{ “”: “this is legal”, “null”: “so is this”, "1;DROP TABLE users”: “and this" }`). +- **Heterogeneous data**: JSON data is often heterogenous. quicktype infers this, and creates union types in languages that support them, or synthetic union types in languages that don’t (e.g. try quicktyping `[0, “zero”]` as Swift and Go). +- **Type unification**. This works across multiple samples, so you can quicktype a directory of API data, for example, and unify types across all responses (e.g. you’ll get just one `Customer` type, even if customer data occurs in many samples). You can also provide multiple samples for the same type for better coverage. +- **Marshalling code**: In addition to types, quicktype generates functions for marshalling your types to and from JSON. +- Supports dynamic languages: quicktype can add dynamic typechecks for JavaScript, TypeScript, Flow, Python, and Ruby. +- **Convenient CLI**: Run `quicktype https://blockchain.info/latestblock -o LatestBlock.ts` to quicktype a Bitcoin API in TypeScript. +- **Client-side**: [The web version of quicktype](https://app.quicktype.io/) runs on the client, so servers never see your data (most JSON converters send your JSON to their server) +- **Typed input**: Feed quicktype TypeScript or JSON Schema instead of JSON for better control over generated types. +- **Code quality**: quicktype emits clean code ## How do I use this with my code? @@ -115,6 +115,7 @@ We have [a blog post](https://blog.quicktype.io/customizing-quicktype/) on that There is a custom schema field `quicktypePropertyOrder` which can be used to specify the order of properties for quicktype. For example: + ```json ... "Location": { diff --git a/PACKAGES.md b/PACKAGES.md index 59ab3a0ef..03f92fb4e 100644 --- a/PACKAGES.md +++ b/PACKAGES.md @@ -1,12 +1,12 @@ # The packages -* `quicktype-core`: This is the engine of quicktype. It takes JSON, JSON Schema, and GraphQL input and produces output in a variety of programming languages. We're trying to keep this lean in terms of download size so that it can be embedded, such as in [quicktype-playground](https://github.com/quicktype/quicktype-playground). +- `quicktype-core`: This is the engine of quicktype. It takes JSON, JSON Schema, and GraphQL input and produces output in a variety of programming languages. We're trying to keep this lean in terms of download size so that it can be embedded, such as in [quicktype-playground](https://github.com/quicktype/quicktype-playground). -* `quicktype-typescript-input`: This is a bit of code that allows TypeScript code to be fed as input to `quicktype-core`, by transforming it to JSON Schema with [typescript-json-schema](https://github.com/YousefED/typescript-json-schema). It depends on `quicktype-core`. +- `quicktype-typescript-input`: This is a bit of code that allows TypeScript code to be fed as input to `quicktype-core`, by transforming it to JSON Schema with [typescript-json-schema](https://github.com/YousefED/typescript-json-schema). It depends on `quicktype-core`. -* `quicktype-graphql-input`: This is the GraphQL input module. It's split off into a separate package because it's not used in the web UI and `quicktype-playgrounds`, and it uses the moderately sized `graphql` dependency. +- `quicktype-graphql-input`: This is the GraphQL input module. It's split off into a separate package because it's not used in the web UI and `quicktype-playgrounds`, and it uses the moderately sized `graphql` dependency. -* `quicktype`: This is the command line interface for quicktype. It's a monolithic package that doesn't depend on the other packages, but contains all their code directly. This is mainly for ease of development. Packages that want to use quicktype's CLI interface, such as [json-to-azure-node-schema](https://github.com/json-helpers/json-to-azure-node-schema) will have to use this package. +- `quicktype`: This is the command line interface for quicktype. It's a monolithic package that doesn't depend on the other packages, but contains all their code directly. This is mainly for ease of development. Packages that want to use quicktype's CLI interface, such as [json-to-azure-node-schema](https://github.com/json-helpers/json-to-azure-node-schema) will have to use this package. # Module resolution @@ -14,9 +14,9 @@ In addition, since those two input packages depend on `quicktype-core`, we would have to first build `quicktype-core`, publish it, and then build the input packages, depending on the just published `quicktype-core`. This is bad for development, since we couldn't do modifications to all packages without publishing, if we want to test independent of the `quicktype` package. The same goes for CI. Therefore, the two have to build as packages depending on the local `build/quicktype-core` package, but have to be published depending on the proper `quicktype-core` NPM package. We solve this the following way: -* All packages, including `quicktype-typescript-input` and `quicktype-graphql-input`, import files with local paths, such as `"../quicktype-core"`. This seems the only way to make VSCode's TypeScript integration, as well as `ts-node` happy. Unfortunately, since local paths can's use `tsc`'s path mapping, we have to rewrite those paths _before_ compiling, which is done in `build/quicktype-*-input/build.ts`: it copies all the sources, rewrites them, compiles, and then deletes the copied sources again. +- All packages, including `quicktype-typescript-input` and `quicktype-graphql-input`, import files with local paths, such as `"../quicktype-core"`. This seems the only way to make VSCode's TypeScript integration, as well as `ts-node` happy. Unfortunately, since local paths can's use `tsc`'s path mapping, we have to rewrite those paths _before_ compiling, which is done in `build/quicktype-*-input/build.ts`: it copies all the sources, rewrites them, compiles, and then deletes the copied sources again. -* Depending on whether we build the input packages, or publish them, their `package.json`s will have to refer to either the local `quicktype-core` package, or the NPM one. This is also done by the build script, which replaces the dependency with the right one for the job. +- Depending on whether we build the input packages, or publish them, their `package.json`s will have to refer to either the local `quicktype-core` package, or the NPM one. This is also done by the build script, which replaces the dependency with the right one for the job. ## Issues diff --git a/doc/Transformers.md b/doc/Transformers.md index 25bed649f..225898eb4 100644 --- a/doc/Transformers.md +++ b/doc/Transformers.md @@ -4,9 +4,9 @@ quicktype has facilities for transforming JSON strings into other data types, pr There are two different sorts of transformed string types: -- Those that transform strings into other JSON-representable types, such as stringified integers. +- Those that transform strings into other JSON-representable types, such as stringified integers. -- Those that transform into types that are not directly representable in JSON (other than as strings), such as date/time types. +- Those that transform into types that are not directly representable in JSON (other than as strings), such as date/time types. Several pieces need to be implemented to add a new transformed string type: @@ -22,8 +22,8 @@ Several pieces need to be implemented to add a new transformed string type: ## Stuff we need to improve -- Automatic generation of tests. We should have a test generator that produces test files with all string types in all reasonable combinations. +- Automatic generation of tests. We should have a test generator that produces test files with all string types in all reasonable combinations. -- One CLI option for all string types. No CLI option work should be necessary to implement a new string type. +- One CLI option for all string types. No CLI option work should be necessary to implement a new string type. -- The AJV thing should be automated, too. We have almost all the validation code necessary in `StringTypes.ts` anyway. +- The AJV thing should be automated, too. We have almost all the validation code necessary in `StringTypes.ts` anyway. diff --git a/packages/quicktype-core/src/DeclarationIR.ts b/packages/quicktype-core/src/DeclarationIR.ts index 8b36dbd51..87972b2f9 100644 --- a/packages/quicktype-core/src/DeclarationIR.ts +++ b/packages/quicktype-core/src/DeclarationIR.ts @@ -16,7 +16,10 @@ export interface Declaration { export class DeclarationIR { readonly declarations: ReadonlyArray; - constructor(declarations: Iterable, readonly forwardedTypes: Set) { + constructor( + declarations: Iterable, + readonly forwardedTypes: Set + ) { this.declarations = Array.from(declarations); } } diff --git a/packages/quicktype-core/src/Naming.ts b/packages/quicktype-core/src/Naming.ts index a8508ca51..53b78370f 100644 --- a/packages/quicktype-core/src/Naming.ts +++ b/packages/quicktype-core/src/Naming.ts @@ -77,7 +77,11 @@ export type NameStyle = (rawName: string) => string; export class Namer { private readonly _prefixes: ReadonlySet; - constructor(readonly name: string, readonly nameStyle: NameStyle, prefixes: string[]) { + constructor( + readonly name: string, + readonly nameStyle: NameStyle, + prefixes: string[] + ) { this._prefixes = new Set(prefixes); } @@ -177,7 +181,10 @@ export abstract class Name { private readonly _associates = new Set(); // If a Named is fixed, the namingFunction is undefined. - constructor(private readonly _namingFunction: Namer | undefined, readonly order: number) {} + constructor( + private readonly _namingFunction: Namer | undefined, + readonly order: number + ) {} addAssociate(associate: AssociatedName): void { this._associates.add(associate); @@ -255,7 +262,11 @@ export class SimpleName extends Name { } export class AssociatedName extends Name { - constructor(private readonly _sponsor: Name, order: number, readonly getName: (sponsorName: string) => string) { + constructor( + private readonly _sponsor: Name, + order: number, + readonly getName: (sponsorName: string) => string + ) { super(undefined, order); } diff --git a/packages/quicktype-core/src/Renderer.ts b/packages/quicktype-core/src/Renderer.ts index bd9badc6f..5671b5713 100644 --- a/packages/quicktype-core/src/Renderer.ts +++ b/packages/quicktype-core/src/Renderer.ts @@ -128,7 +128,10 @@ export abstract class Renderer { private _emitContext: EmitContext; - constructor(protected readonly targetLanguage: TargetLanguage, renderContext: RenderContext) { + constructor( + protected readonly targetLanguage: TargetLanguage, + renderContext: RenderContext + ) { this.typeGraph = renderContext.typeGraph; this.leadingComments = renderContext.leadingComments; diff --git a/packages/quicktype-core/src/Source.ts b/packages/quicktype-core/src/Source.ts index 6898480af..236db6082 100644 --- a/packages/quicktype-core/src/Source.ts +++ b/packages/quicktype-core/src/Source.ts @@ -81,7 +81,7 @@ export function sourcelikeToSource(sl: Sourcelike): Source { kind: "sequence", sequence: arrayIntercalate( newline(), - lines.map((l: string) => ({ kind: "text", text: l } as Source)) + lines.map((l: string) => ({ kind: "text", text: l }) as Source) ) }; } diff --git a/packages/quicktype-core/src/TargetLanguage.ts b/packages/quicktype-core/src/TargetLanguage.ts index 4b8203026..89cee18ee 100644 --- a/packages/quicktype-core/src/TargetLanguage.ts +++ b/packages/quicktype-core/src/TargetLanguage.ts @@ -13,7 +13,11 @@ import { DateTimeRecognizer, DefaultDateTimeRecognizer } from "./DateTime"; export type MultiFileRenderResult = ReadonlyMap; export abstract class TargetLanguage { - constructor(readonly displayName: string, readonly names: string[], readonly extension: string) {} + constructor( + readonly displayName: string, + readonly names: string[], + readonly extension: string + ) {} protected abstract getOptions(): Option[]; diff --git a/packages/quicktype-core/src/Transformers.ts b/packages/quicktype-core/src/Transformers.ts index e64752358..5d2408f2b 100644 --- a/packages/quicktype-core/src/Transformers.ts +++ b/packages/quicktype-core/src/Transformers.ts @@ -28,7 +28,11 @@ function getNumberOfNodes(xfer: Transformer | undefined): number { } export abstract class Transformer { - constructor(readonly kind: string, protected readonly graph: TypeGraph, readonly sourceTypeRef: TypeRef) {} + constructor( + readonly kind: string, + protected readonly graph: TypeGraph, + readonly sourceTypeRef: TypeRef + ) {} get sourceType(): Type { return derefTypeRef(this.sourceTypeRef, this.graph); @@ -73,7 +77,12 @@ export abstract class Transformer { } export abstract class ProducerTransformer extends Transformer { - constructor(kind: string, graph: TypeGraph, sourceTypeRef: TypeRef, readonly consumer: Transformer | undefined) { + constructor( + kind: string, + graph: TypeGraph, + sourceTypeRef: TypeRef, + readonly consumer: Transformer | undefined + ) { super(kind, graph, sourceTypeRef); } @@ -105,7 +114,12 @@ export abstract class ProducerTransformer extends Transformer { } export abstract class MatchTransformer extends Transformer { - constructor(kind: string, graph: TypeGraph, sourceTypeRef: TypeRef, readonly transformer: Transformer) { + constructor( + kind: string, + graph: TypeGraph, + sourceTypeRef: TypeRef, + readonly transformer: Transformer + ) { super(kind, graph, sourceTypeRef); } @@ -342,7 +356,11 @@ export class ArrayEncodingTransformer extends Transformer { } export class ChoiceTransformer extends Transformer { - constructor(graph: TypeGraph, sourceTypeRef: TypeRef, public readonly transformers: ReadonlyArray) { + constructor( + graph: TypeGraph, + sourceTypeRef: TypeRef, + public readonly transformers: ReadonlyArray + ) { super("choice", graph, sourceTypeRef); assert(transformers.length > 0, "Choice must have at least one transformer"); } @@ -603,7 +621,12 @@ export class DecodingChoiceTransformer extends Transformer { } export class UnionMemberMatchTransformer extends MatchTransformer { - constructor(graph: TypeGraph, sourceTypeRef: TypeRef, transformer: Transformer, readonly memberTypeRef: TypeRef) { + constructor( + graph: TypeGraph, + sourceTypeRef: TypeRef, + transformer: Transformer, + readonly memberTypeRef: TypeRef + ) { super("union-member-match", graph, sourceTypeRef, transformer); } @@ -660,7 +683,12 @@ export class UnionMemberMatchTransformer extends MatchTransformer { * This matches strings and enum cases. */ export class StringMatchTransformer extends MatchTransformer { - constructor(graph: TypeGraph, sourceTypeRef: TypeRef, transformer: Transformer, readonly stringCase: string) { + constructor( + graph: TypeGraph, + sourceTypeRef: TypeRef, + transformer: Transformer, + readonly stringCase: string + ) { super("string-match", graph, sourceTypeRef, transformer); } @@ -744,7 +772,12 @@ export class UnionInstantiationTransformer extends Transformer { * Produces a string or an enum case. */ export class StringProducerTransformer extends ProducerTransformer { - constructor(graph: TypeGraph, sourceTypeRef: TypeRef, consumer: Transformer | undefined, readonly result: string) { + constructor( + graph: TypeGraph, + sourceTypeRef: TypeRef, + consumer: Transformer | undefined, + readonly result: string + ) { super("string-producer", graph, sourceTypeRef, consumer); } diff --git a/packages/quicktype-core/src/Type.ts b/packages/quicktype-core/src/Type.ts index 7a16f06d3..80f6fa023 100644 --- a/packages/quicktype-core/src/Type.ts +++ b/packages/quicktype-core/src/Type.ts @@ -108,7 +108,10 @@ function triviallyStructurallyCompatible(x: Type, y: Type): boolean { export class TypeIdentity { private readonly _hashCode: number; - constructor(private readonly _kind: TypeKind, private readonly _components: ReadonlyArray) { + constructor( + private readonly _kind: TypeKind, + private readonly _components: ReadonlyArray + ) { let h = hashCodeInit; h = addHashCode(h, hashCodeOf(this._kind)); for (const c of _components) { @@ -139,7 +142,10 @@ export type MaybeTypeIdentity = TypeIdentity | undefined; export abstract class Type { abstract readonly kind: TypeKind; - constructor(readonly typeRef: TypeRef, protected readonly graph: TypeGraph) {} + constructor( + readonly typeRef: TypeRef, + protected readonly graph: TypeGraph + ) {} get index(): number { return typeRefIndex(this.typeRef); @@ -305,7 +311,11 @@ export function primitiveTypeIdentity(kind: PrimitiveTypeKind, attributes: TypeA } export class PrimitiveType extends Type { - constructor(typeRef: TypeRef, graph: TypeGraph, public readonly kind: PrimitiveTypeKind) { + constructor( + typeRef: TypeRef, + graph: TypeGraph, + public readonly kind: PrimitiveTypeKind + ) { super(typeRef, graph); } @@ -346,7 +356,11 @@ export function arrayTypeIdentity(attributes: TypeAttributes, itemsRef: TypeRef) export class ArrayType extends Type { public readonly kind = "array"; - constructor(typeRef: TypeRef, graph: TypeGraph, private _itemsRef?: TypeRef) { + constructor( + typeRef: TypeRef, + graph: TypeGraph, + private _itemsRef?: TypeRef + ) { super(typeRef, graph); } @@ -405,7 +419,10 @@ export class ArrayType extends Type { } export class GenericClassProperty { - constructor(readonly typeData: T, readonly isOptional: boolean) {} + constructor( + readonly typeData: T, + readonly isOptional: boolean + ) {} equals(other: any): boolean { if (!(other instanceof GenericClassProperty)) { @@ -420,7 +437,11 @@ export class GenericClassProperty { } export class ClassProperty extends GenericClassProperty { - constructor(typeRef: TypeRef, readonly graph: TypeGraph, isOptional: boolean) { + constructor( + typeRef: TypeRef, + readonly graph: TypeGraph, + isOptional: boolean + ) { super(typeRef, isOptional); } @@ -661,7 +682,11 @@ export function enumTypeIdentity(attributes: TypeAttributes, cases: ReadonlySet< export class EnumType extends Type { public readonly kind = "enum"; - constructor(typeRef: TypeRef, graph: TypeGraph, readonly cases: ReadonlySet) { + constructor( + typeRef: TypeRef, + graph: TypeGraph, + readonly cases: ReadonlySet + ) { super(typeRef, graph); } diff --git a/packages/quicktype-core/src/TypeGraph.ts b/packages/quicktype-core/src/TypeGraph.ts index 09993039e..7c5ab5c5d 100644 --- a/packages/quicktype-core/src/TypeGraph.ts +++ b/packages/quicktype-core/src/TypeGraph.ts @@ -69,7 +69,10 @@ export function typeAndAttributesForTypeRef( export class TypeAttributeStore { private readonly _topLevelValues: Map = new Map(); - constructor(private readonly _typeGraph: TypeGraph, private _values: (TypeAttributes | undefined)[]) {} + constructor( + private readonly _typeGraph: TypeGraph, + private _values: (TypeAttributes | undefined)[] + ) {} private getTypeIndex(t: Type): number { const tref = t.typeRef; diff --git a/packages/quicktype-core/src/input/CompressedJSON.ts b/packages/quicktype-core/src/input/CompressedJSON.ts index 2bdb2cc85..3c8a4474e 100644 --- a/packages/quicktype-core/src/input/CompressedJSON.ts +++ b/packages/quicktype-core/src/input/CompressedJSON.ts @@ -55,7 +55,10 @@ export abstract class CompressedJSON { private _objects: Value[][] = []; private _arrays: Value[][] = []; - constructor(readonly dateTimeRecognizer: DateTimeRecognizer, readonly handleRefs: boolean) {} + constructor( + readonly dateTimeRecognizer: DateTimeRecognizer, + readonly handleRefs: boolean + ) {} abstract parse(input: T): Promise; diff --git a/packages/quicktype-core/src/language/CPlusPlus.ts b/packages/quicktype-core/src/language/CPlusPlus.ts index 510b69802..3822e6d28 100644 --- a/packages/quicktype-core/src/language/CPlusPlus.ts +++ b/packages/quicktype-core/src/language/CPlusPlus.ts @@ -383,7 +383,10 @@ function addQualifier(qualifier: Sourcelike, qualified: Sourcelike[]): Sourcelik } class WrappingCode { - constructor(private readonly start: Sourcelike[], private readonly end: Sourcelike[]) {} + constructor( + private readonly start: Sourcelike[], + private readonly end: Sourcelike[] + ) {} wrap(qualifier: Sourcelike, inner: Sourcelike): Sourcelike { return [addQualifier(qualifier, this.start), inner, this.end]; diff --git a/packages/quicktype-core/src/language/Java.ts b/packages/quicktype-core/src/language/Java.ts index 5289794fd..2f053db3e 100644 --- a/packages/quicktype-core/src/language/Java.ts +++ b/packages/quicktype-core/src/language/Java.ts @@ -195,7 +195,10 @@ export function javaNameStyle( } abstract class JavaDateTimeProvider { - constructor(protected readonly _renderer: JavaRenderer, protected readonly _className: string) {} + constructor( + protected readonly _renderer: JavaRenderer, + protected readonly _className: string + ) {} abstract keywords: string[]; abstract dateTimeImports: string[]; diff --git a/packages/quicktype-core/src/language/Scala3.ts b/packages/quicktype-core/src/language/Scala3.ts index 489749cea..d4e54c2ef 100644 --- a/packages/quicktype-core/src/language/Scala3.ts +++ b/packages/quicktype-core/src/language/Scala3.ts @@ -13,20 +13,10 @@ import { isNumeric, legalizeCharacters, splitIntoWords - } from "../support/Strings"; import { assertNever } from "../support/Support"; import { TargetLanguage } from "../TargetLanguage"; -import { - ArrayType, - ClassProperty, - ClassType, - EnumType, - MapType, - ObjectType, - Type, - UnionType -} from "../Type"; +import { ArrayType, ClassProperty, ClassType, EnumType, MapType, ObjectType, Type, UnionType } from "../Type"; import { matchType, nullableFromUnion, removeNullFromUnion } from "../TypeUtils"; import { RenderContext } from "../Renderer"; @@ -37,13 +27,16 @@ export enum Framework { } export const scala3Options = { - framework: new EnumOption("framework", "Serialization framework", + framework: new EnumOption( + "framework", + "Serialization framework", [ ["just-types", Framework.None], ["circe", Framework.Circe], - ["upickle", Framework.Upickle], - ] - , undefined), + ["upickle", Framework.Upickle] + ], + undefined + ), packageName: new StringOption("package", "Package", "PACKAGE", "quicktype") }; @@ -135,13 +128,17 @@ const keywords = [ "Enum" ]; - /** * Check if given parameter name should be wrapped in a backtick * @param paramName */ const shouldAddBacktick = (paramName: string): boolean => { - return keywords.some(s => paramName === s) || invalidSymbols.some(s => paramName.includes(s)) || !isNaN(+parseFloat(paramName)) || !isNaN(parseInt(paramName.charAt(0))); + return ( + keywords.some(s => paramName === s) || + invalidSymbols.some(s => paramName.includes(s)) || + !isNaN(+parseFloat(paramName)) || + !isNaN(parseInt(paramName.charAt(0))) + ); }; const wrapOption = (s: string, optional: boolean): string => { @@ -248,10 +245,10 @@ export class Scala3Renderer extends ConvenienceRenderer { delimiter === "curly" ? ["{", "}"] : delimiter === "paren" - ? ["(", ")"] - : delimiter === "none" - ? ["", ""] - : ["{", "})"]; + ? ["(", ")"] + : delimiter === "none" + ? ["", ""] + : ["{", "})"]; this.emitLine(line, " ", open); this.indent(f); this.emitLine(close); @@ -393,7 +390,7 @@ export class Scala3Renderer extends ConvenienceRenderer { } protected emitClassDefinitionMethods() { - this.emitLine(")"); + this.emitLine(")"); } protected emitEnumDefinition(e: EnumType, enumName: Name): void { @@ -403,19 +400,25 @@ export class Scala3Renderer extends ConvenienceRenderer { ["enum ", enumName, " : "], () => { let count = e.cases.size; - if (count > 0) { this.emitItem("\t case ") }; + if (count > 0) { + this.emitItem("\t case "); + } this.forEachEnumCase(e, "none", (name, jsonName) => { if (!(jsonName == "")) { const backticks = shouldAddBacktick(jsonName) || jsonName.includes(" ") || - !isNaN(parseInt(jsonName.charAt(0))) - if (backticks) { this.emitItem("`") } + !isNaN(parseInt(jsonName.charAt(0))); + if (backticks) { + this.emitItem("`"); + } this.emitItemOnce([name]); - if (backticks) { this.emitItem("`") } + if (backticks) { + this.emitItem("`"); + } if (--count > 0) this.emitItem([","]); } else { - --count + --count; } }); }, @@ -433,7 +436,7 @@ export class Scala3Renderer extends ConvenienceRenderer { this.emitDescription(this.descriptionForType(u)); const [maybeNull, nonNulls] = removeNullFromUnion(u, sortBy); - const theTypes: Array = [] + const theTypes: Array = []; this.forEachUnionMember(u, nonNulls, "none", null, (_, t) => { theTypes.push(this.scalaType(t)); }); @@ -470,7 +473,6 @@ export class Scala3Renderer extends ConvenienceRenderer { } export class UpickleRenderer extends Scala3Renderer { - protected emitClassDefinitionMethods() { this.emitLine(") derives ReadWriter "); } @@ -481,11 +483,9 @@ export class UpickleRenderer extends Scala3Renderer { this.emitLine("import upickle.default.*"); this.ensureBlankLine(); } - } export class Smithy4sRenderer extends Scala3Renderer { - protected emitHeader(): void { if (this.leadingComments !== undefined) { this.emitCommentLines(this.leadingComments); @@ -513,8 +513,6 @@ export class Smithy4sRenderer extends Scala3Renderer { this.emitLine("structure ", className, "{}"); } - - protected emitEnumDefinition(e: EnumType, enumName: Name): void { this.emitDescription(this.descriptionForType(e)); @@ -522,30 +520,26 @@ export class Smithy4sRenderer extends Scala3Renderer { this.emitItem(["enum ", enumName, " { "]); let count = e.cases.size; this.forEachEnumCase(e, "none", (name, jsonName) => { - // if (!(jsonName == "")) { + // if (!(jsonName == "")) { /* const backticks = shouldAddBacktick(jsonName) || jsonName.includes(" ") || !isNaN(parseInt(jsonName.charAt(0))) if (backticks) {this.emitItem("`")} else */ this.emitLine(); - this.emitItem([name, " = \"", jsonName, "\""]); + this.emitItem([name, ' = "', jsonName, '"']); // if (backticks) {this.emitItem("`")} if (--count > 0) this.emitItem([","]); //} else { //--count - //} + //} }); this.ensureBlankLine(); this.emitItem(["}"]); - } - } - export class CirceRenderer extends Scala3Renderer { - seenUnionTypes: Array = []; protected circeEncoderForType(t: Type, _ = false, noOptional = false, paramName: string = ""): Sourcelike { @@ -602,15 +596,14 @@ export class CirceRenderer extends Scala3Renderer { jsonName.includes(" ") || !isNaN(parseInt(jsonName.charAt(0))) if (backticks) {this.emitItem("`")} else */ - this.emitItem(["\"", jsonName, "\""]); + this.emitItem(['"', jsonName, '"']); // if (backticks) {this.emitItem("`")} if (--count > 0) this.emitItem([" | "]); //} else { //--count - //} + //} }); this.ensureBlankLine(); - } protected emitHeader(): void { @@ -622,25 +615,45 @@ export class CirceRenderer extends Scala3Renderer { this.emitLine("import cats.syntax.functor._"); this.ensureBlankLine(); - this.emitLine("// For serialising string unions") - this.emitLine("given [A <: Singleton](using A <:< String): Decoder[A] = Decoder.decodeString.emapTry(x => Try(x.asInstanceOf[A])) "); - this.emitLine("given [A <: Singleton](using ev: A <:< String): Encoder[A] = Encoder.encodeString.contramap(ev) "); + this.emitLine("// For serialising string unions"); + this.emitLine( + "given [A <: Singleton](using A <:< String): Decoder[A] = Decoder.decodeString.emapTry(x => Try(x.asInstanceOf[A])) " + ); + this.emitLine( + "given [A <: Singleton](using ev: A <:< String): Encoder[A] = Encoder.encodeString.contramap(ev) " + ); this.ensureBlankLine(); - this.emitLine("// If a union has a null in, then we'll need this too... ") + this.emitLine("// If a union has a null in, then we'll need this too... "); this.emitLine("type NullValue = None.type"); } protected emitTopLevelArray(t: ArrayType, name: Name): void { super.emitTopLevelArray(t, name); const elementType = this.scalaType(t.items); - this.emitLine(["given (using ev : ", elementType, "): Encoder[Map[String,", elementType, "]] = Encoder.encodeMap[String, ", elementType, "]"]); + this.emitLine([ + "given (using ev : ", + elementType, + "): Encoder[Map[String,", + elementType, + "]] = Encoder.encodeMap[String, ", + elementType, + "]" + ]); } protected emitTopLevelMap(t: MapType, name: Name): void { super.emitTopLevelMap(t, name); const elementType = this.scalaType(t.values); this.ensureBlankLine(); - this.emitLine(["given (using ev : ", elementType, "): Encoder[Map[String, ", elementType, "]] = Encoder.encodeMap[String, ", elementType, "]"]); + this.emitLine([ + "given (using ev : ", + elementType, + "): Encoder[Map[String, ", + elementType, + "]] = Encoder.encodeMap[String, ", + elementType, + "]" + ]); } protected emitUnionDefinition(u: UnionType, unionName: Name): void { @@ -653,7 +666,7 @@ export class CirceRenderer extends Scala3Renderer { this.emitDescription(this.descriptionForType(u)); const [maybeNull, nonNulls] = removeNullFromUnion(u, sortBy); - const theTypes: Array = [] + const theTypes: Array = []; this.forEachUnionMember(u, nonNulls, "none", null, (_, t) => { theTypes.push(this.scalaType(t)); }); @@ -670,38 +683,43 @@ export class CirceRenderer extends Scala3Renderer { this.ensureBlankLine(); if (!this.seenUnionTypes.some(y => y === thisUnionType)) { this.seenUnionTypes.push(thisUnionType); - const sourceLikeTypes: Array<[Sourcelike, Type]> = [] + const sourceLikeTypes: Array<[Sourcelike, Type]> = []; this.forEachUnionMember(u, nonNulls, "none", null, (_, t) => { sourceLikeTypes.push([this.scalaType(t), t]); - }); if (maybeNull !== null) { sourceLikeTypes.push([this.nameForUnionMember(u, maybeNull), maybeNull]); } - this.emitLine(["given Decoder[", unionName, "] = {"]) + this.emitLine(["given Decoder[", unionName, "] = {"]); this.indent(() => { - this.emitLine(["List[Decoder[", unionName, "]]("]) + this.emitLine(["List[Decoder[", unionName, "]]("]); this.indent(() => { - sourceLikeTypes.forEach((t) => { + sourceLikeTypes.forEach(t => { this.emitLine(["Decoder[", t[0], "].widen,"]); }); - }) - this.emitLine(").reduceLeft(_ or _)") - } - ) - this.emitLine(["}"]) + }); + this.emitLine(").reduceLeft(_ or _)"); + }); + this.emitLine(["}"]); this.ensureBlankLine(); - this.emitLine(["given Encoder[", unionName, "] = Encoder.instance {"]) + this.emitLine(["given Encoder[", unionName, "] = Encoder.instance {"]); this.indent(() => { sourceLikeTypes.forEach((t, i) => { const paramTemp = `enc${i.toString()}`; - this.emitLine(["case ", paramTemp, " : ", t[0], " => ", this.circeEncoderForType(t[1], false, false, paramTemp)]); + this.emitLine([ + "case ", + paramTemp, + " : ", + t[0], + " => ", + this.circeEncoderForType(t[1], false, false, paramTemp) + ]); }); - }) - this.emitLine("}") + }); + this.emitLine("}"); } } } @@ -741,4 +759,3 @@ export class Scala3TargetLanguage extends TargetLanguage { } } } - diff --git a/packages/quicktype-core/src/language/Smithy4s.ts b/packages/quicktype-core/src/language/Smithy4s.ts index 3b4ece721..664fe94e9 100644 --- a/packages/quicktype-core/src/language/Smithy4s.ts +++ b/packages/quicktype-core/src/language/Smithy4s.ts @@ -13,20 +13,10 @@ import { isNumeric, legalizeCharacters, splitIntoWords - } from "../support/Strings"; import { assertNever } from "../support/Support"; import { TargetLanguage } from "../TargetLanguage"; -import { - ArrayType, - ClassProperty, - ClassType, - EnumType, - MapType, - ObjectType, - Type, - UnionType -} from "../Type"; +import { ArrayType, ClassProperty, ClassType, EnumType, MapType, ObjectType, Type, UnionType } from "../Type"; import { matchCompoundType, matchType, nullableFromUnion, removeNullFromUnion } from "../TypeUtils"; import { RenderContext } from "../Renderer"; @@ -35,11 +25,7 @@ export enum Framework { } export const SmithyOptions = { - framework: new EnumOption("framework", "Serialization framework", - [ - ["just-types", Framework.None] - ] - , undefined), + framework: new EnumOption("framework", "Serialization framework", [["just-types", Framework.None]], undefined), packageName: new StringOption("package", "Package", "PACKAGE", "quicktype") }; @@ -50,7 +36,7 @@ const invalidSymbols = [ "+", "!", "@", - "#", + "#", "%", "^", "&", @@ -74,9 +60,9 @@ const invalidSymbols = [ const keywords = [ "abstract", "case", - "catch", + "catch", "do", - "else", + "else", "export", "false", "final", @@ -86,7 +72,7 @@ const keywords = [ "if", "implicit", "import", - "new", + "new", "override", "package", "private", @@ -99,7 +85,7 @@ const keywords = [ "throw", "trait", "try", - "true", + "true", "val", "var", "while", @@ -121,13 +107,17 @@ const keywords = [ "Enum" ]; - /** * Check if given parameter name should be wrapped in a backtick * @param paramName */ const shouldAddBacktick = (paramName: string): boolean => { - return keywords.some(s => paramName === s) || invalidSymbols.some(s => paramName.includes(s)) || !isNaN(parseFloat(paramName)) || !isNaN(parseInt(paramName.charAt(0))); + return ( + keywords.some(s => paramName === s) || + invalidSymbols.some(s => paramName.includes(s)) || + !isNaN(parseFloat(paramName)) || + !isNaN(parseInt(paramName.charAt(0))) + ); }; function isPartCharacter(codePoint: number): boolean { @@ -215,10 +205,10 @@ export class Smithy4sRenderer extends ConvenienceRenderer { delimiter === "curly" ? ["{", "}"] : delimiter === "paren" - ? ["(", ")"] - : delimiter === "none" - ? ["", ""] - : ["{", "})"]; + ? ["(", ")"] + : delimiter === "none" + ? ["", ""] + : ["{", "})"]; this.emitLine(line, " ", open); this.indent(f); this.emitLine(close); @@ -236,11 +226,11 @@ export class Smithy4sRenderer extends ConvenienceRenderer { } protected emitArrayType(_: ArrayType, smithyType: Sourcelike): void { - this.emitLine([ "list " , smithyType , " { member : ", "}" ]) + this.emitLine(["list ", smithyType, " { member : ", "}"]); } protected mapType(mapType: MapType, _ = false): Sourcelike { - return mapType.getCombinedName().toString() + "Map" + return mapType.getCombinedName().toString() + "Map"; //return [this.scalaType(mapType.values, withIssues), "Map"]; } @@ -265,15 +255,13 @@ export class Smithy4sRenderer extends ConvenienceRenderer { unionType => { const nullable = nullableFromUnion(unionType); if (nullable !== null) { - return [this.scalaType(nullable, withIssues)]; + return [this.scalaType(nullable, withIssues)]; } return this.nameForNamedType(unionType); } ); } - - protected emitUsageHeader(): void { // To be overridden } @@ -286,11 +274,11 @@ export class Smithy4sRenderer extends ConvenienceRenderer { } this.ensureBlankLine(); - this.emitLine("$version: \"2\""); - this.emitLine("namespace ", this._scalaOptions.packageName); + this.emitLine('$version: "2"'); + this.emitLine("namespace ", this._scalaOptions.packageName); this.ensureBlankLine(); - - this.emitLine("document NullValue"); + + this.emitLine("document NullValue"); this.ensureBlankLine(); } @@ -330,7 +318,6 @@ export class Smithy4sRenderer extends ConvenienceRenderer { this.indent(() => { let count = c.getProperties().size; let first = true; - this.forEachClassProperty(c, "none", (_, jsonName, p) => { const nullable = p.type.kind === "union" && nullableFromUnion(p.type as UnionType) !== null; @@ -338,9 +325,9 @@ export class Smithy4sRenderer extends ConvenienceRenderer { const last = --count === 0; const meta: Array<() => void> = []; - const laterType = p.type.kind === "array" || p.type.kind === "map" - if(laterType) { - emitLater.push(p) + const laterType = p.type.kind === "array" || p.type.kind === "map"; + if (laterType) { + emitLater.push(p); } const description = this.descriptionForClassProperty(c, jsonName); @@ -362,7 +349,7 @@ export class Smithy4sRenderer extends ConvenienceRenderer { nameWithBackticks, " : ", scalaType(p), - + last ? "" : "," ); @@ -372,29 +359,41 @@ export class Smithy4sRenderer extends ConvenienceRenderer { first = false; }); - }); + }); this.emitClassDefinitionMethods(emitLater); } - protected emitClassDefinitionMethods( arrayTypes : ClassProperty[] ) { + protected emitClassDefinitionMethods(arrayTypes: ClassProperty[]) { this.emitLine("}"); - arrayTypes.forEach (p => { - function ignore(_: T): void { - return; - } - matchCompoundType(p.type, - at => { - this.emitLine([ "list ", this.scalaType(at, true) , "{ member: ", this.scalaType(at.items, true), "}" ])}, - ignore, - mt =>{ - this.emitLine([ "map ", this.scalaType(mt, true) , "{ key: String , value: ", this.scalaType(mt.values, true), "}" ]) - }, - ignore, - ignore) - + arrayTypes.forEach(p => { + function ignore(_: T): void { + return; } - ) - + matchCompoundType( + p.type, + at => { + this.emitLine([ + "list ", + this.scalaType(at, true), + "{ member: ", + this.scalaType(at.items, true), + "}" + ]); + }, + ignore, + mt => { + this.emitLine([ + "map ", + this.scalaType(mt, true), + "{ key: String , value: ", + this.scalaType(mt.values, true), + "}" + ]); + }, + ignore, + ignore + ); + }); } protected emitEnumDefinition(e: EnumType, enumName: Name): void { @@ -404,28 +403,26 @@ export class Smithy4sRenderer extends ConvenienceRenderer { this.emitItem(["enum ", enumName, " { "]); let count = e.cases.size; - - this.forEachEnumCase(e, "none", (name, jsonName) => { - // if (!(jsonName == "")) { - /* const backticks = + this.forEachEnumCase(e, "none", (name, jsonName) => { + // if (!(jsonName == "")) { + /* const backticks = shouldAddBacktick(jsonName) || jsonName.includes(" ") || !isNaN(parseInt(jsonName.charAt(0))) if (backticks) {this.emitItem("`")} else */ - this.emitLine(); - - this.emitItem([name, " = \"", jsonName, "\""]); - - // if (backticks) {this.emitItem("`")} - if (--count > 0) this.emitItem([","]); - //} else { - //--count - //} - }); - + this.emitLine(); + + this.emitItem([name, ' = "', jsonName, '"']); + + // if (backticks) {this.emitItem("`")} + if (--count > 0) this.emitItem([","]); + //} else { + //--count + //} + }); + this.ensureBlankLine(); this.emitItem(["}"]); - } protected emitUnionDefinition(u: UnionType, unionName: Name): void { @@ -437,15 +434,14 @@ export class Smithy4sRenderer extends ConvenienceRenderer { const emitLater: Array = []; - this.emitDescription(this.descriptionForType(u)); const [maybeNull, nonNulls] = removeNullFromUnion(u, sortBy); - const theTypes: Array = [] + const theTypes: Array = []; this.forEachUnionMember(u, nonNulls, "none", null, (_, t) => { - const laterType = t.kind === "array" || t.kind === "map" - if(laterType) { - emitLater.push(t) + const laterType = t.kind === "array" || t.kind === "map"; + if (laterType) { + emitLater.push(t); } theTypes.push(this.scalaType(t)); }); @@ -456,29 +452,41 @@ export class Smithy4sRenderer extends ConvenienceRenderer { this.emitLine(["@untagged union ", unionName, " { "]); this.indent(() => { theTypes.forEach((t, i) => { - this.emitLine([String.fromCharCode(i+65), " : ", t]); + this.emitLine([String.fromCharCode(i + 65), " : ", t]); }); }); - this.emitLine("}") + this.emitLine("}"); this.ensureBlankLine(); - emitLater.forEach (p => { + emitLater.forEach(p => { function ignore(_: T): void { return; - } - matchCompoundType(p, - at => { - this.emitLine([ "list ", this.scalaType(at, true) , "{ member: ", this.scalaType(at.items, true), "}" ])}, + } + matchCompoundType( + p, + at => { + this.emitLine([ + "list ", + this.scalaType(at, true), + "{ member: ", + this.scalaType(at.items, true), + "}" + ]); + }, ignore, - mt =>{ - this.emitLine([ "map ", this.scalaType(mt, true) , "{ key: String , value: ", this.scalaType(mt.values, true), "}" ]) + mt => { + this.emitLine([ + "map ", + this.scalaType(mt, true), + "{ key: String , value: ", + this.scalaType(mt.values, true), + "}" + ]); }, - ignore, - ignore) - - } - ) - + ignore, + ignore + ); + }); } protected emitSourceStructure(): void { @@ -502,7 +510,6 @@ export class Smithy4sRenderer extends ConvenienceRenderer { } } - export class SmithyTargetLanguage extends TargetLanguage { constructor() { super("Smithy", ["Smithy"], "smithy"); @@ -534,4 +541,3 @@ export class SmithyTargetLanguage extends TargetLanguage { } } } - diff --git a/packages/quicktype-core/src/language/Swift.ts b/packages/quicktype-core/src/language/Swift.ts index 5abe711b2..5e36c1cfd 100644 --- a/packages/quicktype-core/src/language/Swift.ts +++ b/packages/quicktype-core/src/language/Swift.ts @@ -536,7 +536,7 @@ export class SwiftRenderer extends ConvenienceRenderer { this.emitLineOnce("import Alamofire"); } if (this._options.optionalEnums) { - this.emitLineOnce("import OptionallyDecodable // https://github.com/idrougge/OptionallyDecodable"); + this.emitLineOnce("import OptionallyDecodable // https://github.com/idrougge/OptionallyDecodable"); } this.ensureBlankLine(); } @@ -574,7 +574,10 @@ export class SwiftRenderer extends ConvenienceRenderer { return protocols; } - private getProtocolString(kind: "struct" | "class" | "enum", baseClass: string | undefined = undefined): Sourcelike { + private getProtocolString( + kind: "struct" | "class" | "enum", + baseClass: string | undefined = undefined + ): Sourcelike { let protocols = this.getProtocolsArray(kind); if (baseClass) { protocols.unshift(baseClass); @@ -1416,7 +1419,6 @@ encoder.dateEncodingStrategy = .formatted(formatter)`); if (!this._options.justTypes) { this.emitSupportFunctions4(); } - } private emitAlamofireExtension() { diff --git a/test/fixtures.ts b/test/fixtures.ts index 0f3190f08..f542d2994 100644 --- a/test/fixtures.ts +++ b/test/fixtures.ts @@ -254,7 +254,10 @@ abstract class LanguageFixture extends Fixture { } class JSONFixture extends LanguageFixture { - constructor(language: languages.Language, public name: string = language.name) { + constructor( + language: languages.Language, + public name: string = language.name + ) { super(language); } @@ -568,7 +571,10 @@ class JSONTypeScriptFixture extends JSONToXToYFixture { // This fixture tests generating code from JSON Schema. class JSONSchemaFixture extends LanguageFixture { - constructor(language: languages.Language, readonly name: string = `schema-${language.name}`) { + constructor( + language: languages.Language, + readonly name: string = `schema-${language.name}` + ) { super(language); } @@ -699,7 +705,10 @@ class GraphQLFixture extends LanguageFixture { } class CommandSuccessfulLanguageFixture extends LanguageFixture { - constructor(language: languages.Language, public name: string = language.name) { + constructor( + language: languages.Language, + public name: string = language.name + ) { super(language); } diff --git a/test/fixtures/elm/runner.js b/test/fixtures/elm/runner.js index 61bdded06..3910641cc 100644 --- a/test/fixtures/elm/runner.js +++ b/test/fixtures/elm/runner.js @@ -3,11 +3,15 @@ const fs = require("fs"); let ports = Elm.Main.worker().ports; -ports.toJS.subscribe(function(result) { +ports.toJS.subscribe(function (result) { if (result.startsWith("Error: ")) { - process.stderr.write(result + "\n", function() { process.exit(1); }); + process.stderr.write(result + "\n", function () { + process.exit(1); + }); } else { - process.stdout.write(result + "\n", function() { process.exit(0); }); + process.stdout.write(result + "\n", function () { + process.exit(0); + }); } }); diff --git a/test/fixtures/haskell/package.yaml b/test/fixtures/haskell/package.yaml index b3ac01f87..0f3b20714 100644 --- a/test/fixtures/haskell/package.yaml +++ b/test/fixtures/haskell/package.yaml @@ -2,14 +2,14 @@ name: haskell version: 0.0.1 category: Data dependencies: - - base >= 4.7 && < 5 - - aeson - - bytestring - - text - - unordered-containers - - vector + - base >= 4.7 && < 5 + - aeson + - bytestring + - text + - unordered-containers + - vector executables: - haskell: - source-dirs: . - main: Main.hs + haskell: + source-dirs: . + main: Main.hs diff --git a/test/fixtures/haskell/stack.yaml b/test/fixtures/haskell/stack.yaml index 27f5d399f..ba0d61aae 100644 --- a/test/fixtures/haskell/stack.yaml +++ b/test/fixtures/haskell/stack.yaml @@ -1,6 +1,6 @@ resolver: lts-15.12 packages: - - . + - . # extra-deps: [] # flags: {} # extra-package-dbs: [] diff --git a/test/fixtures/javascript-prop-types/main.js b/test/fixtures/javascript-prop-types/main.js index 2d98efd53..c7ab06679 100644 --- a/test/fixtures/javascript-prop-types/main.js +++ b/test/fixtures/javascript-prop-types/main.js @@ -10,7 +10,7 @@ const obj = JSON.parse(json); const results = checkPropTypes({ obj: TopLevel }, { obj }, "prop", "MyComponent"); if (results) { - console.log("Failure:", results); + console.log("Failure:", results); } else { - console.log("Success"); + console.log("Success"); } diff --git a/test/fixtures/typescript-zod/main.ts b/test/fixtures/typescript-zod/main.ts index f7e16738c..4820c14ef 100644 --- a/test/fixtures/typescript-zod/main.ts +++ b/test/fixtures/typescript-zod/main.ts @@ -2,7 +2,6 @@ import * as TopLevel from "./TopLevel"; import fs from "fs"; import process from "process"; - const sample = process.argv[2]; const json = fs.readFileSync(sample); diff --git a/test/inputs/graphql/github1.graphql b/test/inputs/graphql/github1.graphql index 2bc98ee7f..6c410ac64 100644 --- a/test/inputs/graphql/github1.graphql +++ b/test/inputs/graphql/github1.graphql @@ -1,6 +1,6 @@ query { - viewer { - login - realName: name - } + viewer { + login + realName: name + } } diff --git a/test/inputs/graphql/github2.graphql b/test/inputs/graphql/github2.graphql index cb8889b09..3602f2485 100644 --- a/test/inputs/graphql/github2.graphql +++ b/test/inputs/graphql/github2.graphql @@ -1,11 +1,11 @@ query { - viewer { - login - repositories(first: 10) { - totalCount - nodes { - name - } + viewer { + login + repositories(first: 10) { + totalCount + nodes { + name + } + } } - } } diff --git a/test/inputs/graphql/github3.graphql b/test/inputs/graphql/github3.graphql index 496891445..af9aa9bda 100644 --- a/test/inputs/graphql/github3.graphql +++ b/test/inputs/graphql/github3.graphql @@ -1,12 +1,12 @@ query { - viewer { - login - repository(name: "metapixel") { - pullRequests(first:10) { - nodes { - state + viewer { + login + repository(name: "metapixel") { + pullRequests(first: 10) { + nodes { + state + } + } } - } } - } } diff --git a/test/inputs/graphql/github4.graphql b/test/inputs/graphql/github4.graphql index a154d59a3..cc3a148ef 100644 --- a/test/inputs/graphql/github4.graphql +++ b/test/inputs/graphql/github4.graphql @@ -1,17 +1,17 @@ query { - viewer { - ... UserFragment - repository(name: "metapixel") { - pullRequests(first:10) { - nodes { - state + viewer { + ...UserFragment + repository(name: "metapixel") { + pullRequests(first: 10) { + nodes { + state + } + } } - } } - } } fragment UserFragment on User { - login - name + login + name } diff --git a/test/inputs/graphql/github5.graphql b/test/inputs/graphql/github5.graphql index e25b2b7e2..cfc00a963 100644 --- a/test/inputs/graphql/github5.graphql +++ b/test/inputs/graphql/github5.graphql @@ -1,6 +1,6 @@ query test($more: Boolean!) { - viewer { - login - name @include(if: $more) - } + viewer { + login + name @include(if: $more) + } } diff --git a/test/inputs/graphql/github6.graphql b/test/inputs/graphql/github6.graphql index 704c5dc2e..b9ec5f8dd 100644 --- a/test/inputs/graphql/github6.graphql +++ b/test/inputs/graphql/github6.graphql @@ -1,8 +1,8 @@ query { - resource(url: "https://github.com/quicktype/quicktype") { - url - ... on User { - login + resource(url: "https://github.com/quicktype/quicktype") { + url + ... on User { + login + } } - } } diff --git a/test/inputs/graphql/github7.graphql b/test/inputs/graphql/github7.graphql index 209ad5da9..b90eec781 100644 --- a/test/inputs/graphql/github7.graphql +++ b/test/inputs/graphql/github7.graphql @@ -1,27 +1,27 @@ { - viewer { - login - starredRepositories { - totalCount - } - repositories(first: 3) { - edges { - node { - name - stargazers { - totalCount - } - forks { - totalCount - } - watchers { + viewer { + login + starredRepositories { totalCount - } - issues(states:[OPEN]) { - totalCount - } } - } + repositories(first: 3) { + edges { + node { + name + stargazers { + totalCount + } + forks { + totalCount + } + watchers { + totalCount + } + issues(states: [OPEN]) { + totalCount + } + } + } + } } - } } diff --git a/test/inputs/graphql/github8.graphql b/test/inputs/graphql/github8.graphql index a5299d7cd..e14bb8e0f 100644 --- a/test/inputs/graphql/github8.graphql +++ b/test/inputs/graphql/github8.graphql @@ -1,22 +1,22 @@ { - repository(owner: "quicktype", name: "quicktype") { - nameWithOwner, - n303: issueOrPullRequest(number: 303) { - ... IOPR - }, - n307: issueOrPullRequest(number: 307) { - ... IOPR + repository(owner: "quicktype", name: "quicktype") { + nameWithOwner + n303: issueOrPullRequest(number: 303) { + ...IOPR + } + n307: issueOrPullRequest(number: 307) { + ...IOPR + } } - } } fragment IOPR on IssueOrPullRequest { - ... on Issue { - title - state - } - ... on PullRequest { - title - merged - } + ... on Issue { + title + state + } + ... on PullRequest { + title + merged + } } diff --git a/test/inputs/graphql/github9.graphql b/test/inputs/graphql/github9.graphql index b9460d474..a623a9098 100644 --- a/test/inputs/graphql/github9.graphql +++ b/test/inputs/graphql/github9.graphql @@ -1,14 +1,14 @@ -mutation AddReaction($input: AddReactionInput!){ - addReaction(input: $input){ - clientMutationId - reaction { - content +mutation AddReaction($input: AddReactionInput!) { + addReaction(input: $input) { + clientMutationId + reaction { + content + } + subject { + viewerCanReact + reactionGroups { + content + } + } } - subject { - viewerCanReact - reactionGroups { - content - } - } - } -} \ No newline at end of file +}