diff --git a/.prettierignore b/.prettierignore index b28375367..24d0dc128 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ -azure-pipelines.yml package.json test/valid-data/**/*.json +babel.config.cjs +jest.config.cjs diff --git a/.prettierrc.json b/.prettierrc.json index 09e20e9d7..8941818ed 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,5 +1,4 @@ { - "trailingComma": "es5", "printWidth": 120, "tabWidth": 4, "endOfLine": "lf", diff --git a/eslint.config.js b/eslint.config.js index b44d0c100..1963ae3ee 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -74,5 +74,5 @@ export default tseslint.config( }, }, }, - eslintPluginPrettierRecommended + eslintPluginPrettierRecommended, ); diff --git a/factory/formatter.ts b/factory/formatter.ts index 72bbe052b..b77a9b954 100644 --- a/factory/formatter.ts +++ b/factory/formatter.ts @@ -34,7 +34,7 @@ import { VoidTypeFormatter } from "../src/TypeFormatter/VoidTypeFormatter.js"; export type FormatterAugmentor = ( formatter: MutableTypeFormatter, - circularReferenceTypeFormatter: CircularReferenceTypeFormatter + circularReferenceTypeFormatter: CircularReferenceTypeFormatter, ) => void; export function createFormatter(config: CompletedConfig, augmentor?: FormatterAugmentor): TypeFormatter { diff --git a/factory/parser.ts b/factory/parser.ts index ce118f6e9..67dce6ff7 100644 --- a/factory/parser.ts +++ b/factory/parser.ts @@ -76,7 +76,7 @@ export function createParser(program: ts.Program, config: CompletedConfig, augme if (config.jsDoc === "extended") { return new AnnotatedNodeParser( nodeParser, - new ExtendedAnnotationsReader(typeChecker, extraTags, config.markdownDescription) + new ExtendedAnnotationsReader(typeChecker, extraTags, config.markdownDescription), ); } else if (config.jsDoc === "basic") { return new AnnotatedNodeParser(nodeParser, new BasicAnnotationsReader(extraTags)); @@ -149,20 +149,20 @@ export function createParser(program: ts.Program, config: CompletedConfig, augme new InterfaceAndClassNodeParser( typeChecker, withJsDoc(chainNodeParser), - config.additionalProperties - ) - ) - ) - ) + config.additionalProperties, + ), + ), + ), + ), ) .addNodeParser( withCircular( withExpose( withJsDoc( - new TypeLiteralNodeParser(typeChecker, withJsDoc(chainNodeParser), config.additionalProperties) - ) - ) - ) + new TypeLiteralNodeParser(typeChecker, withJsDoc(chainNodeParser), config.additionalProperties), + ), + ), + ), ) .addNodeParser(new ArrayNodeParser(chainNodeParser)); diff --git a/factory/program.ts b/factory/program.ts index b9aa67df7..0e6a7c03a 100644 --- a/factory/program.ts +++ b/factory/program.ts @@ -25,7 +25,7 @@ function loadTsConfigFile(configFile: string) { ts.sys, path.resolve(path.dirname(configFile)), {}, - configFile + configFile, ); parseResult.options.noEmit = true; delete parseResult.options.out; diff --git a/src/AnnotationsReader/ExtendedAnnotationsReader.ts b/src/AnnotationsReader/ExtendedAnnotationsReader.ts index 4b5de96fa..ba8fd57aa 100644 --- a/src/AnnotationsReader/ExtendedAnnotationsReader.ts +++ b/src/AnnotationsReader/ExtendedAnnotationsReader.ts @@ -8,7 +8,7 @@ export class ExtendedAnnotationsReader extends BasicAnnotationsReader { public constructor( private typeChecker: ts.TypeChecker, extraTags?: Set, - private markdownDescription?: boolean + private markdownDescription?: boolean, ) { super(extraTags); } diff --git a/src/ChainNodeParser.ts b/src/ChainNodeParser.ts index 0388009e3..bd8c2c409 100644 --- a/src/ChainNodeParser.ts +++ b/src/ChainNodeParser.ts @@ -11,7 +11,7 @@ export class ChainNodeParser implements SubNodeParser, MutableParser { public constructor( protected typeChecker: ts.TypeChecker, - protected nodeParsers: SubNodeParser[] + protected nodeParsers: SubNodeParser[], ) {} public addNodeParser(nodeParser: SubNodeParser): this { diff --git a/src/Error/DiagnosticError.ts b/src/Error/DiagnosticError.ts index 5b5d9539c..2c8e00608 100644 --- a/src/Error/DiagnosticError.ts +++ b/src/Error/DiagnosticError.ts @@ -4,7 +4,7 @@ import { BaseError } from "./BaseError.js"; export class DiagnosticError extends BaseError { public constructor(private diagnostics: readonly ts.Diagnostic[]) { super( - diagnostics.map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")).join("\n\n") + diagnostics.map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")).join("\n\n"), ); } diff --git a/src/Error/UnknownNodeError.ts b/src/Error/UnknownNodeError.ts index 29289209f..f8ea184fc 100644 --- a/src/Error/UnknownNodeError.ts +++ b/src/Error/UnknownNodeError.ts @@ -4,12 +4,12 @@ import { BaseError } from "./BaseError.js"; export class UnknownNodeError extends BaseError { public constructor( private node: ts.Node, - private reference?: ts.Node + private reference?: ts.Node, ) { super( `Unknown node "${node.getSourceFile() ? node.getFullText() : ""}" of kind "${ ts.SyntaxKind[node.kind] - }"` + }"`, ); } diff --git a/src/ExposeNodeParser.ts b/src/ExposeNodeParser.ts index 2468361fe..baa9ea5b4 100644 --- a/src/ExposeNodeParser.ts +++ b/src/ExposeNodeParser.ts @@ -12,7 +12,7 @@ export class ExposeNodeParser implements SubNodeParser { protected typeChecker: ts.TypeChecker, protected subNodeParser: SubNodeParser, protected expose: "all" | "none" | "export", - protected jsDoc: "none" | "extended" | "basic" + protected jsDoc: "none" | "extended" | "basic", ) {} public supportsNode(node: ts.Node): boolean { diff --git a/src/NodeParser/AnnotatedNodeParser.ts b/src/NodeParser/AnnotatedNodeParser.ts index 189f9ea20..f803aea21 100644 --- a/src/NodeParser/AnnotatedNodeParser.ts +++ b/src/NodeParser/AnnotatedNodeParser.ts @@ -14,7 +14,7 @@ import { AnyType } from "../Type/AnyType.js"; export class AnnotatedNodeParser implements SubNodeParser { public constructor( protected childNodeParser: SubNodeParser, - protected annotationsReader: AnnotationsReader + protected annotationsReader: AnnotationsReader, ) {} public supportsNode(node: ts.Node): boolean { diff --git a/src/NodeParser/CallExpressionParser.ts b/src/NodeParser/CallExpressionParser.ts index 90505a182..26849627d 100644 --- a/src/NodeParser/CallExpressionParser.ts +++ b/src/NodeParser/CallExpressionParser.ts @@ -10,7 +10,7 @@ import { SymbolType } from "../Type/SymbolType.js"; export class CallExpressionParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.CallExpression): boolean { diff --git a/src/NodeParser/ConditionalTypeNodeParser.ts b/src/NodeParser/ConditionalTypeNodeParser.ts index 180e576a5..6e05b1bd2 100644 --- a/src/NodeParser/ConditionalTypeNodeParser.ts +++ b/src/NodeParser/ConditionalTypeNodeParser.ts @@ -10,14 +10,14 @@ import { NeverType } from "../Type/NeverType.js"; class CheckType { constructor( public parameterName: string, - public type: BaseType + public type: BaseType, ) {} } export class ConditionalTypeNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.ConditionalTypeNode): boolean { @@ -36,7 +36,7 @@ export class ConditionalTypeNodeParser implements SubNodeParser { const result = isAssignableTo(extendsType, checkType, inferMap); return this.childNodeParser.createType( result ? node.trueType : node.falseType, - this.createSubContext(node, context, undefined, result ? inferMap : new Map()) + this.createSubContext(node, context, undefined, result ? inferMap : new Map()), ); } @@ -49,7 +49,7 @@ export class ConditionalTypeNodeParser implements SubNodeParser { if (!(trueCheckType instanceof NeverType)) { const result = this.childNodeParser.createType( node.trueType, - this.createSubContext(node, context, new CheckType(checkTypeParameterName, trueCheckType), inferMap) + this.createSubContext(node, context, new CheckType(checkTypeParameterName, trueCheckType), inferMap), ); if (result) { results.push(result); @@ -58,7 +58,7 @@ export class ConditionalTypeNodeParser implements SubNodeParser { if (!(falseCheckType instanceof NeverType)) { const result = this.childNodeParser.createType( node.falseType, - this.createSubContext(node, context, new CheckType(checkTypeParameterName, falseCheckType)) + this.createSubContext(node, context, new CheckType(checkTypeParameterName, falseCheckType)), ); if (result) { results.push(result); @@ -97,7 +97,7 @@ export class ConditionalTypeNodeParser implements SubNodeParser { node: ts.ConditionalTypeNode, parentContext: Context, checkType?: CheckType, - inferMap: Map = new Map() + inferMap: Map = new Map(), ): Context { const subContext = new Context(node); diff --git a/src/NodeParser/ConstructorNodeParser.ts b/src/NodeParser/ConstructorNodeParser.ts index f58025442..4376903bc 100644 --- a/src/NodeParser/ConstructorNodeParser.ts +++ b/src/NodeParser/ConstructorNodeParser.ts @@ -11,7 +11,7 @@ import { getNamedArguments, getTypeName } from "./FunctionNodeParser.js"; export class ConstructorNodeParser implements SubNodeParser { constructor( protected childNodeParser: NodeParser, - protected functions: FunctionOptions + protected functions: FunctionOptions, ) {} public supportsNode(node: ts.TypeNode): boolean { diff --git a/src/NodeParser/EnumNodeParser.ts b/src/NodeParser/EnumNodeParser.ts index 54d33b925..a23a3a49c 100644 --- a/src/NodeParser/EnumNodeParser.ts +++ b/src/NodeParser/EnumNodeParser.ts @@ -19,7 +19,7 @@ export class EnumNodeParser implements SubNodeParser { `enum-${getKey(node, context)}`, members .filter((member: ts.EnumMember) => !isNodeHidden(member)) - .map((member, index) => this.getMemberValue(member, index)) + .map((member, index) => this.getMemberValue(member, index)), ); } diff --git a/src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts b/src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts index 810056e4b..b7e382166 100644 --- a/src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts +++ b/src/NodeParser/ExpressionWithTypeArgumentsNodeParser.ts @@ -6,7 +6,7 @@ import { BaseType } from "../Type/BaseType.js"; export class ExpressionWithTypeArgumentsNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.ExpressionWithTypeArguments): boolean { @@ -18,7 +18,7 @@ export class ExpressionWithTypeArgumentsNodeParser implements SubNodeParser { const aliasedSymbol = this.typeChecker.getAliasedSymbol(typeSymbol); return this.childNodeParser.createType( aliasedSymbol.declarations![0], - this.createSubContext(node, context) + this.createSubContext(node, context), ); } else if (typeSymbol.flags & ts.SymbolFlags.TypeParameter) { return context.getArgument(typeSymbol.name); diff --git a/src/NodeParser/FunctionNodeParser.ts b/src/NodeParser/FunctionNodeParser.ts index 55e05858c..d75003824 100644 --- a/src/NodeParser/FunctionNodeParser.ts +++ b/src/NodeParser/FunctionNodeParser.ts @@ -12,7 +12,7 @@ import { getKey } from "../Utils/nodeKey.js"; export class FunctionNodeParser implements SubNodeParser { constructor( protected childNodeParser: NodeParser, - protected functions: FunctionOptions + protected functions: FunctionOptions, ) {} public supportsNode(node: ts.TypeNode): boolean { @@ -26,7 +26,7 @@ export class FunctionNodeParser implements SubNodeParser { public createType( node: ts.FunctionTypeNode | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction, - context: Context + context: Context, ): BaseType { if (this.functions === "hide") { return new NeverType(); @@ -47,7 +47,7 @@ export function getNamedArguments( | ts.FunctionDeclaration | ts.ArrowFunction | ts.ConstructorTypeNode, - context: Context + context: Context, ) { if (node.parameters.length === 0) { return undefined; @@ -66,7 +66,7 @@ export function getNamedArguments( return new ObjectProperty(node.parameters[index].name.getText(), parameterType, required); }), - false + false, ); } @@ -76,7 +76,7 @@ export function getTypeName( | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction - | ts.ConstructorTypeNode + | ts.ConstructorTypeNode, ): string | undefined { if (ts.isArrowFunction(node) || ts.isFunctionExpression(node) || ts.isFunctionTypeNode(node)) { const parent = node.parent; diff --git a/src/NodeParser/IndexedAccessTypeNodeParser.ts b/src/NodeParser/IndexedAccessTypeNodeParser.ts index e6e2a7745..2544ae1c5 100644 --- a/src/NodeParser/IndexedAccessTypeNodeParser.ts +++ b/src/NodeParser/IndexedAccessTypeNodeParser.ts @@ -16,7 +16,7 @@ import { getTypeByKey } from "../Utils/typeKeys.js"; export class IndexedAccessTypeNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TypeNode): boolean { @@ -36,7 +36,7 @@ export class IndexedAccessTypeNodeParser implements SubNodeParser { ts.isPropertySignature(m) && Boolean(m.type) && ts.isIdentifier(m.name) && - m.name.text === indexType.getValue() + m.name.text === indexType.getValue(), ); return member && this.childNodeParser.createType(member.type, context); @@ -62,7 +62,7 @@ export class IndexedAccessTypeNodeParser implements SubNodeParser { const propertyTypes = indexTypes.map((type) => { if (!(type instanceof LiteralType || type instanceof StringType || type instanceof NumberType)) { throw new LogicError( - `Unexpected type "${type.getId()}" (expected "LiteralType.js" or "StringType.js" or "NumberType.js")` + `Unexpected type "${type.getId()}" (expected "LiteralType.js" or "StringType.js" or "NumberType.js")`, ); } diff --git a/src/NodeParser/InferTypeNodeParser.ts b/src/NodeParser/InferTypeNodeParser.ts index cde18a3d8..141ea9b5b 100644 --- a/src/NodeParser/InferTypeNodeParser.ts +++ b/src/NodeParser/InferTypeNodeParser.ts @@ -7,7 +7,7 @@ import { InferType } from "../Type/InferType.js"; export class InferTypeNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.InferTypeNode): boolean { diff --git a/src/NodeParser/InterfaceAndClassNodeParser.ts b/src/NodeParser/InterfaceAndClassNodeParser.ts index 35f885588..ca8a715b9 100644 --- a/src/NodeParser/InterfaceAndClassNodeParser.ts +++ b/src/NodeParser/InterfaceAndClassNodeParser.ts @@ -14,7 +14,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, protected childNodeParser: NodeParser, - protected readonly additionalProperties: boolean + protected readonly additionalProperties: boolean, ) {} public supportsNode(node: ts.InterfaceDeclaration | ts.ClassDeclaration): boolean { @@ -24,7 +24,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { public createType( node: ts.InterfaceDeclaration | ts.ClassDeclaration, context: Context, - reference?: ReferenceType + reference?: ReferenceType, ): BaseType { if (node.typeParameters?.length) { node.typeParameters.forEach((typeParam) => { @@ -97,13 +97,13 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { ...result, ...baseType.types.map((expression) => this.childNodeParser.createType(expression, context)), ], - [] + [], ); } protected getProperties( node: ts.InterfaceDeclaration | ts.ClassDeclaration, - context: Context + context: Context, ): ObjectProperty[] | undefined { let hasRequiredNever = false; @@ -112,7 +112,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { (members, member) => { if (ts.isConstructorDeclaration(member)) { const params = member.parameters.filter((param) => - ts.isParameterPropertyDeclaration(param, param.parent) + ts.isParameterPropertyDeclaration(param, param.parent), ) as ts.ParameterPropertyDeclaration[]; members.push(...params); } else if (ts.isPropertySignature(member) || ts.isPropertyDeclaration(member)) { @@ -120,7 +120,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { } return members; }, - [] as (ts.PropertyDeclaration | ts.PropertySignature | ts.ParameterPropertyDeclaration)[] + [] as (ts.PropertyDeclaration | ts.PropertySignature | ts.ParameterPropertyDeclaration)[], ) .filter((member) => isPublic(member) && !isStatic(member) && !isNodeHidden(member)) .reduce((entries, member) => { @@ -143,8 +143,8 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { new ObjectProperty( this.getPropertyName(member.name), this.childNodeParser.createType(memberType, context), - !member.questionToken - ) + !member.questionToken, + ), ) .filter((prop) => { const type = prop.getType(); @@ -163,7 +163,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { protected getAdditionalProperties( node: ts.InterfaceDeclaration | ts.ClassDeclaration, - context: Context + context: Context, ): BaseType | boolean { const indexSignature = (node.members as ts.NodeArray).find(ts.isIndexSignatureDeclaration); if (!indexSignature) { diff --git a/src/NodeParser/IntersectionNodeParser.ts b/src/NodeParser/IntersectionNodeParser.ts index 0fb67b110..317018b9e 100644 --- a/src/NodeParser/IntersectionNodeParser.ts +++ b/src/NodeParser/IntersectionNodeParser.ts @@ -13,7 +13,7 @@ import { NeverType } from "../Type/NeverType.js"; export class IntersectionNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.IntersectionTypeNode): boolean { diff --git a/src/NodeParser/MappedTypeNodeParser.ts b/src/NodeParser/MappedTypeNodeParser.ts index eab836e3f..cba966942 100644 --- a/src/NodeParser/MappedTypeNodeParser.ts +++ b/src/NodeParser/MappedTypeNodeParser.ts @@ -22,7 +22,7 @@ import { removeUndefined } from "../Utils/removeUndefined.js"; export class MappedTypeNodeParser implements SubNodeParser { public constructor( protected childNodeParser: NodeParser, - protected readonly additionalProperties: boolean + protected readonly additionalProperties: boolean, ) {} public supportsNode(node: ts.MappedTypeNode): boolean { @@ -40,7 +40,7 @@ export class MappedTypeNodeParser implements SubNodeParser { id, [], this.getProperties(node, keyListType, context), - this.getAdditionalProperties(node, keyListType, context) + this.getAdditionalProperties(node, keyListType, context), ); } else if (keyListType instanceof LiteralType) { // Key type resolves to single known property @@ -53,7 +53,7 @@ export class MappedTypeNodeParser implements SubNodeParser { if (constraintType?.getId() === "number") { const type = this.childNodeParser.createType( node.type!, - this.createSubContext(node, keyListType, context) + this.createSubContext(node, keyListType, context), ); return type instanceof NeverType ? new NeverType() : new ArrayType(type); } @@ -85,7 +85,7 @@ export class MappedTypeNodeParser implements SubNodeParser { throw new LogicError( `Unexpected key type "${ constraintType ? constraintType.getId() : constraintType - }" for type "${node.getText()}" (expected "UnionType" or "StringType")` + }" for type "${node.getText()}" (expected "UnionType" or "StringType")`, ); } } @@ -95,7 +95,7 @@ export class MappedTypeNodeParser implements SubNodeParser { return rawKey; } const key = derefType( - this.childNodeParser.createType(node.nameType, this.createSubContext(node, rawKey, context)) + this.childNodeParser.createType(node.nameType, this.createSubContext(node, rawKey, context)), ); return key; @@ -110,7 +110,7 @@ export class MappedTypeNodeParser implements SubNodeParser { .reduce((result: ObjectProperty[], [key, mappedKey]: [LiteralType, LiteralType]) => { const propertyType = this.childNodeParser.createType( node.type!, - this.createSubContext(node, key, context) + this.createSubContext(node, key, context), ); let newType = derefAnnotatedType(propertyType); @@ -124,7 +124,7 @@ export class MappedTypeNodeParser implements SubNodeParser { const objectProperty = new ObjectProperty( mappedKey.getValue().toString(), preserveAnnotation(propertyType, newType), - !node.questionToken && !hasUndefined + !node.questionToken && !hasUndefined, ); result.push(objectProperty); @@ -139,7 +139,7 @@ export class MappedTypeNodeParser implements SubNodeParser { .map((value: EnumValue) => { const type = this.childNodeParser.createType( node.type!, - this.createSubContext(node, new LiteralType(value!), context) + this.createSubContext(node, new LiteralType(value!), context), ); return new ObjectProperty(value!.toString(), type, !node.questionToken); @@ -149,7 +149,7 @@ export class MappedTypeNodeParser implements SubNodeParser { protected getAdditionalProperties( node: ts.MappedTypeNode, keyListType: UnionType, - context: Context + context: Context, ): BaseType | boolean { const key = keyListType.getTypes().filter((type) => !(type instanceof LiteralType))[0]; if (key) { @@ -165,7 +165,7 @@ export class MappedTypeNodeParser implements SubNodeParser { protected createSubContext( node: ts.MappedTypeNode, key: LiteralType | StringType, - parentContext: Context + parentContext: Context, ): Context { const subContext = new Context(node); diff --git a/src/NodeParser/ObjectLiteralExpressionNodeParser.ts b/src/NodeParser/ObjectLiteralExpressionNodeParser.ts index 409ef001d..30dc25889 100644 --- a/src/NodeParser/ObjectLiteralExpressionNodeParser.ts +++ b/src/NodeParser/ObjectLiteralExpressionNodeParser.ts @@ -19,8 +19,8 @@ export class ObjectLiteralExpressionNodeParser implements SubNodeParser { new ObjectProperty( t.name!.getText(), this.childNodeParser.createType((t as any).initializer, context), - !(t as any).questionToken - ) + !(t as any).questionToken, + ), ); return new ObjectType(`object-${getKey(node, context)}`, [], properties, false); diff --git a/src/NodeParser/PrefixUnaryExpressionNodeParser.ts b/src/NodeParser/PrefixUnaryExpressionNodeParser.ts index ec11bb1bd..13e11ec12 100644 --- a/src/NodeParser/PrefixUnaryExpressionNodeParser.ts +++ b/src/NodeParser/PrefixUnaryExpressionNodeParser.ts @@ -28,7 +28,7 @@ export class PrefixUnaryExpressionNodeParser implements SubNodeParser { } } else { throw new Error( - `Expected operand to be "LiteralType" but is "${operand ? operand.constructor.name : operand}"` + `Expected operand to be "LiteralType" but is "${operand ? operand.constructor.name : operand}"`, ); } } diff --git a/src/NodeParser/PropertyAccessExpressionParser.ts b/src/NodeParser/PropertyAccessExpressionParser.ts index ce13e8cb8..2dec5c6bf 100644 --- a/src/NodeParser/PropertyAccessExpressionParser.ts +++ b/src/NodeParser/PropertyAccessExpressionParser.ts @@ -6,7 +6,7 @@ import { BaseType } from "../Type/BaseType.js"; export class PropertyAccessExpressionParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.PropertyAccessExpression): boolean { diff --git a/src/NodeParser/StringTemplateLiteralNodeParser.ts b/src/NodeParser/StringTemplateLiteralNodeParser.ts index e0273ee70..0ecf642f4 100644 --- a/src/NodeParser/StringTemplateLiteralNodeParser.ts +++ b/src/NodeParser/StringTemplateLiteralNodeParser.ts @@ -28,7 +28,7 @@ export class StringTemplateLiteralNodeParser implements SubNodeParser { const suffix = span.literal.text; const type = this.childNodeParser.createType(span.type, context); return extractLiterals(type).map((value) => value + suffix); - }) + }), ); const expandedLiterals = expand(matrix); diff --git a/src/NodeParser/TupleNodeParser.ts b/src/NodeParser/TupleNodeParser.ts index cd07bf2b7..281e8aa6e 100644 --- a/src/NodeParser/TupleNodeParser.ts +++ b/src/NodeParser/TupleNodeParser.ts @@ -7,7 +7,7 @@ import { TupleType } from "../Type/TupleType.js"; export class TupleNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TupleTypeNode): boolean { @@ -18,7 +18,7 @@ export class TupleNodeParser implements SubNodeParser { return new TupleType( node.elements.map((item) => { return this.childNodeParser.createType(item, context); - }) + }), ); } } diff --git a/src/NodeParser/TypeAliasNodeParser.ts b/src/NodeParser/TypeAliasNodeParser.ts index 4a23c6008..5787c04a3 100644 --- a/src/NodeParser/TypeAliasNodeParser.ts +++ b/src/NodeParser/TypeAliasNodeParser.ts @@ -10,7 +10,7 @@ import { getKey } from "../Utils/nodeKey.js"; export class TypeAliasNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TypeAliasDeclaration): boolean { diff --git a/src/NodeParser/TypeLiteralNodeParser.ts b/src/NodeParser/TypeLiteralNodeParser.ts index fb6c52a46..4c1b4a5ea 100644 --- a/src/NodeParser/TypeLiteralNodeParser.ts +++ b/src/NodeParser/TypeLiteralNodeParser.ts @@ -12,7 +12,7 @@ export class TypeLiteralNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, protected childNodeParser: NodeParser, - protected readonly additionalProperties: boolean + protected readonly additionalProperties: boolean, ) {} public supportsNode(node: ts.TypeLiteralNode): boolean { @@ -40,7 +40,7 @@ export class TypeLiteralNodeParser implements SubNodeParser { const properties = node.members .filter( (element): element is PropertySignature | MethodSignature => - ts.isPropertySignature(element) || ts.isMethodSignature(element) + ts.isPropertySignature(element) || ts.isMethodSignature(element), ) .filter((propertyNode) => !isNodeHidden(propertyNode)) .map( @@ -48,8 +48,8 @@ export class TypeLiteralNodeParser implements SubNodeParser { new ObjectProperty( this.getPropertyName(propertyNode.name), this.childNodeParser.createType(propertyNode.type!, context), - !propertyNode.questionToken - ) + !propertyNode.questionToken, + ), ) .filter((prop) => { const type = prop.getType(); diff --git a/src/NodeParser/TypeReferenceNodeParser.ts b/src/NodeParser/TypeReferenceNodeParser.ts index 3cd57a0dd..eb90ee253 100644 --- a/src/NodeParser/TypeReferenceNodeParser.ts +++ b/src/NodeParser/TypeReferenceNodeParser.ts @@ -16,7 +16,7 @@ const invalidTypes: Record = { export class TypeReferenceNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TypeReferenceNode): boolean { @@ -73,7 +73,7 @@ export class TypeReferenceNodeParser implements SubNodeParser { return this.childNodeParser.createType( typeSymbol.declarations!.filter((n: ts.Declaration) => !invalidTypes[n.kind])[0], - this.createSubContext(node, context) + this.createSubContext(node, context), ); } diff --git a/src/NodeParser/TypeofNodeParser.ts b/src/NodeParser/TypeofNodeParser.ts index f1a55422d..cd5ee6200 100644 --- a/src/NodeParser/TypeofNodeParser.ts +++ b/src/NodeParser/TypeofNodeParser.ts @@ -13,7 +13,7 @@ import { FunctionType } from "../Type/FunctionType.js"; export class TypeofNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.TypeQueryNode): boolean { diff --git a/src/NodeParser/UnionNodeParser.ts b/src/NodeParser/UnionNodeParser.ts index d2bf44775..656418c0a 100644 --- a/src/NodeParser/UnionNodeParser.ts +++ b/src/NodeParser/UnionNodeParser.ts @@ -9,7 +9,7 @@ import { NeverType } from "../Type/NeverType.js"; export class UnionNodeParser implements SubNodeParser { public constructor( protected typeChecker: ts.TypeChecker, - protected childNodeParser: NodeParser + protected childNodeParser: NodeParser, ) {} public supportsNode(node: ts.UnionTypeNode): boolean { diff --git a/src/SchemaGenerator.ts b/src/SchemaGenerator.ts index b452a89b3..723aaa7c9 100644 --- a/src/SchemaGenerator.ts +++ b/src/SchemaGenerator.ts @@ -17,7 +17,7 @@ export class SchemaGenerator { protected readonly program: ts.Program, protected readonly nodeParser: NodeParser, protected readonly typeFormatter: TypeFormatter, - protected readonly config?: Config + protected readonly config?: Config, ) {} public createSchema(fullName?: string): Schema { @@ -132,7 +132,7 @@ export class SchemaGenerator { protected appendTypes( sourceFiles: readonly ts.SourceFile[], typeChecker: ts.TypeChecker, - types: Map + types: Map, ): void { for (const sourceFile of sourceFiles) { this.inspectNode(sourceFile, typeChecker, types); diff --git a/src/TopRefNodeParser.ts b/src/TopRefNodeParser.ts index 1ed4d2b7d..dec37f697 100644 --- a/src/TopRefNodeParser.ts +++ b/src/TopRefNodeParser.ts @@ -7,7 +7,7 @@ export class TopRefNodeParser implements NodeParser { public constructor( protected childNodeParser: NodeParser, protected fullName: string | undefined, - protected topRef: boolean + protected topRef: boolean, ) {} public createType(node: ts.Node, context: Context): BaseType { diff --git a/src/Type/AliasType.ts b/src/Type/AliasType.ts index 8d6d84765..1f43799bf 100644 --- a/src/Type/AliasType.ts +++ b/src/Type/AliasType.ts @@ -3,7 +3,7 @@ import { BaseType } from "./BaseType.js"; export class AliasType extends BaseType { public constructor( private id: string, - private type: BaseType + private type: BaseType, ) { super(); } diff --git a/src/Type/AnnotatedType.ts b/src/Type/AnnotatedType.ts index a3cfa3828..1f328703a 100644 --- a/src/Type/AnnotatedType.ts +++ b/src/Type/AnnotatedType.ts @@ -9,7 +9,7 @@ export class AnnotatedType extends BaseType { public constructor( private type: BaseType, private annotations: Annotations, - private nullable: boolean + private nullable: boolean, ) { super(); } diff --git a/src/Type/ConstructorType.ts b/src/Type/ConstructorType.ts index 4220ca3c0..ec220872b 100644 --- a/src/Type/ConstructorType.ts +++ b/src/Type/ConstructorType.ts @@ -7,7 +7,7 @@ export class ConstructorType extends BaseType { constructor( node?: ts.ConstructorTypeNode, - protected namedArguments?: ObjectType + protected namedArguments?: ObjectType, ) { super(); diff --git a/src/Type/DefinitionType.ts b/src/Type/DefinitionType.ts index b1478a76f..2020945a1 100644 --- a/src/Type/DefinitionType.ts +++ b/src/Type/DefinitionType.ts @@ -3,7 +3,7 @@ import { BaseType } from "./BaseType.js"; export class DefinitionType extends BaseType { public constructor( private name: string | undefined, - private type: BaseType + private type: BaseType, ) { super(); } diff --git a/src/Type/EnumType.ts b/src/Type/EnumType.ts index dde8dff3e..d9795c459 100644 --- a/src/Type/EnumType.ts +++ b/src/Type/EnumType.ts @@ -9,7 +9,7 @@ export class EnumType extends BaseType { public constructor( private id: string, - private values: readonly EnumValue[] + private values: readonly EnumValue[], ) { super(); this.types = values.map((value) => (value == null ? new NullType() : new LiteralType(value))); diff --git a/src/Type/FunctionType.ts b/src/Type/FunctionType.ts index 6db156033..169dac7ad 100644 --- a/src/Type/FunctionType.ts +++ b/src/Type/FunctionType.ts @@ -7,7 +7,7 @@ export class FunctionType extends BaseType { constructor( node?: ts.FunctionTypeNode | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction, - protected namedArguments?: ObjectType + protected namedArguments?: ObjectType, ) { super(); diff --git a/src/Type/ObjectType.ts b/src/Type/ObjectType.ts index b39e1c71d..a68aefa1a 100644 --- a/src/Type/ObjectType.ts +++ b/src/Type/ObjectType.ts @@ -5,7 +5,7 @@ export class ObjectProperty { public constructor( private name: string, private type: BaseType, - private required: boolean + private required: boolean, ) {} public getName(): string { @@ -26,7 +26,7 @@ export class ObjectType extends BaseType { private properties: readonly ObjectProperty[], private additionalProperties: BaseType | boolean, // whether the object is `object` - private nonPrimitive: boolean = false + private nonPrimitive: boolean = false, ) { super(); } diff --git a/src/Type/RestType.ts b/src/Type/RestType.ts index c558966f9..ac1e3b4c2 100644 --- a/src/Type/RestType.ts +++ b/src/Type/RestType.ts @@ -6,7 +6,7 @@ import { TupleType } from "./TupleType.js"; export class RestType extends BaseType { public constructor( private item: ArrayType | InferType | TupleType, - private title: string | null = null + private title: string | null = null, ) { super(); } diff --git a/src/Type/UnionType.ts b/src/Type/UnionType.ts index 9544152e7..2d36da255 100644 --- a/src/Type/UnionType.ts +++ b/src/Type/UnionType.ts @@ -17,7 +17,7 @@ export class UnionType extends BaseType { flatTypes.push(type); } return flatTypes; - }, [] as BaseType[]) + }, [] as BaseType[]), ); } diff --git a/src/TypeFormatter/AnnotatedTypeFormatter.ts b/src/TypeFormatter/AnnotatedTypeFormatter.ts index 4b0c62c92..9012cc15f 100644 --- a/src/TypeFormatter/AnnotatedTypeFormatter.ts +++ b/src/TypeFormatter/AnnotatedTypeFormatter.ts @@ -62,8 +62,8 @@ export class AnnotatedTypeFormatter implements SubTypeFormatter { } else { throw new Error( `Cannot assign discriminator tag to type: ${JSON.stringify( - derefed - )}. This tag can only be assigned to union types.` + derefed, + )}. This tag can only be assigned to union types.`, ); } } diff --git a/src/TypeFormatter/DefinitionTypeFormatter.ts b/src/TypeFormatter/DefinitionTypeFormatter.ts index 456a3c70e..f068e352d 100644 --- a/src/TypeFormatter/DefinitionTypeFormatter.ts +++ b/src/TypeFormatter/DefinitionTypeFormatter.ts @@ -8,7 +8,7 @@ import { uniqueArray } from "../Utils/uniqueArray.js"; export class DefinitionTypeFormatter implements SubTypeFormatter { public constructor( protected childTypeFormatter: TypeFormatter, - protected encodeRefs: boolean + protected encodeRefs: boolean, ) {} public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/FunctionTypeFormatter.ts b/src/TypeFormatter/FunctionTypeFormatter.ts index cc31b35c9..596661be2 100644 --- a/src/TypeFormatter/FunctionTypeFormatter.ts +++ b/src/TypeFormatter/FunctionTypeFormatter.ts @@ -8,7 +8,7 @@ import { TypeFormatter } from "../TypeFormatter.js"; export class FunctionTypeFormatter implements SubTypeFormatter { constructor( protected childTypeFormatter: TypeFormatter, - protected functions: FunctionOptions + protected functions: FunctionOptions, ) {} public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/IntersectionTypeFormatter.ts b/src/TypeFormatter/IntersectionTypeFormatter.ts index 751cae76d..4554896b5 100644 --- a/src/TypeFormatter/IntersectionTypeFormatter.ts +++ b/src/TypeFormatter/IntersectionTypeFormatter.ts @@ -35,7 +35,7 @@ export class IntersectionTypeFormatter implements SubTypeFormatter { nonArrayLikeTypes.reduce(getAllOfDefinitionReducer(this.childTypeFormatter), { type: "object", additionalProperties: false, - }) + }), ); } @@ -46,7 +46,7 @@ export class IntersectionTypeFormatter implements SubTypeFormatter { return uniqueArray( type .getTypes() - .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []) + .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []), ); } } diff --git a/src/TypeFormatter/ObjectTypeFormatter.ts b/src/TypeFormatter/ObjectTypeFormatter.ts index 6a6044d08..afda61dd7 100644 --- a/src/TypeFormatter/ObjectTypeFormatter.ts +++ b/src/TypeFormatter/ObjectTypeFormatter.ts @@ -39,7 +39,7 @@ export class ObjectTypeFormatter implements SubTypeFormatter { .getBaseTypes() .reduce( (result: BaseType[], baseType) => [...result, ...this.childTypeFormatter.getChildren(baseType)], - [] + [], ); const childrenOfAdditionalProps = @@ -65,7 +65,7 @@ export class ObjectTypeFormatter implements SubTypeFormatter { if (additionalProperties === false) { objectProperties = objectProperties.filter( - (property) => !(derefType(property.getType()) instanceof NeverType) + (property) => !(derefType(property.getType()) instanceof NeverType), ); } diff --git a/src/TypeFormatter/ReferenceTypeFormatter.ts b/src/TypeFormatter/ReferenceTypeFormatter.ts index 16c4d0876..23913b92b 100644 --- a/src/TypeFormatter/ReferenceTypeFormatter.ts +++ b/src/TypeFormatter/ReferenceTypeFormatter.ts @@ -8,7 +8,7 @@ import { TypeFormatter } from "../TypeFormatter.js"; export class ReferenceTypeFormatter implements SubTypeFormatter { public constructor( protected childTypeFormatter: TypeFormatter, - protected encodeRefs: boolean + protected encodeRefs: boolean, ) {} public supportsType(type: BaseType): boolean { diff --git a/src/TypeFormatter/TupleTypeFormatter.ts b/src/TypeFormatter/TupleTypeFormatter.ts index a27020a95..ee471b6b0 100644 --- a/src/TypeFormatter/TupleTypeFormatter.ts +++ b/src/TypeFormatter/TupleTypeFormatter.ts @@ -84,7 +84,7 @@ export class TupleTypeFormatter implements SubTypeFormatter { type .getTypes() .filter(notNever) - .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []) + .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []), ); } } diff --git a/src/TypeFormatter/UnionTypeFormatter.ts b/src/TypeFormatter/UnionTypeFormatter.ts index 7f0dfea9c..66fcfda0d 100644 --- a/src/TypeFormatter/UnionTypeFormatter.ts +++ b/src/TypeFormatter/UnionTypeFormatter.ts @@ -15,7 +15,7 @@ type DiscriminatorType = "json-schema" | "open-api"; export class UnionTypeFormatter implements SubTypeFormatter { public constructor( protected childTypeFormatter: TypeFormatter, - private discriminatorType?: DiscriminatorType + private discriminatorType?: DiscriminatorType, ) {} public supportsType(type: BaseType): boolean { @@ -41,8 +41,8 @@ export class UnionTypeFormatter implements SubTypeFormatter { if (undefinedIndex != -1) { throw new Error( `Cannot find discriminator keyword "${discriminator}" in type ${JSON.stringify( - type.getTypes()[undefinedIndex] - )}.` + type.getTypes()[undefinedIndex], + )}.`, ); } @@ -66,7 +66,7 @@ export class UnionTypeFormatter implements SubTypeFormatter { const duplicates = kindValues.filter((item, index) => kindValues.indexOf(item) !== index); if (duplicates.length > 0) { throw new Error( - `Duplicate discriminator values: ${duplicates.join(", ")} in type ${JSON.stringify(type.getName())}.` + `Duplicate discriminator values: ${duplicates.join(", ")} in type ${JSON.stringify(type.getName())}.`, ); } @@ -153,7 +153,7 @@ export class UnionTypeFormatter implements SubTypeFormatter { return uniqueArray( type .getTypes() - .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []) + .reduce((result: BaseType[], item) => [...result, ...this.childTypeFormatter.getChildren(item)], []), ); } } diff --git a/src/Utils/allOfDefinition.ts b/src/Utils/allOfDefinition.ts index e10388670..7da418110 100644 --- a/src/Utils/allOfDefinition.ts +++ b/src/Utils/allOfDefinition.ts @@ -33,7 +33,7 @@ export function getAllOfDefinitionReducer(childTypeFormatter: TypeFormatter) { for (const prop of addProps.anyOf as Definition[]) { if (prop.type) { additionalTypes = additionalTypes.concat( - Array.isArray(prop.type) ? prop.type : [prop.type] + Array.isArray(prop.type) ? prop.type : [prop.type], ); } else { additionalProps.push(prop); @@ -41,7 +41,7 @@ export function getAllOfDefinitionReducer(childTypeFormatter: TypeFormatter) { } } else if (addProps.type) { additionalTypes = additionalTypes.concat( - Array.isArray(addProps.type) ? addProps.type : [addProps.type] + Array.isArray(addProps.type) ? addProps.type : [addProps.type], ); } else { additionalProps.push(addProps); diff --git a/src/Utils/deepMerge.ts b/src/Utils/deepMerge.ts index e16b4fd9c..30bfa68af 100644 --- a/src/Utils/deepMerge.ts +++ b/src/Utils/deepMerge.ts @@ -13,7 +13,7 @@ import { intersectionOfArrays } from "./intersectionOfArrays.js"; */ export function deepMerge( a: { [key: string]: JSONSchema7Definition }, - b: { [key: string]: JSONSchema7Definition } + b: { [key: string]: JSONSchema7Definition }, ): { [x: string]: JSONSchema7Definition } { const output = { ...structuredClone(a), ...structuredClone(b) }; diff --git a/src/Utils/isAssignableTo.ts b/src/Utils/isAssignableTo.ts index 223e2b6e6..0ec183989 100644 --- a/src/Utils/isAssignableTo.ts +++ b/src/Utils/isAssignableTo.ts @@ -91,7 +91,7 @@ export function isAssignableTo( target: BaseType, source: BaseType, inferMap: Map = new Map(), - insideTypes: Set = new Set() + insideTypes: Set = new Set(), ): boolean { // Dereference source and target source = derefType(source); @@ -203,7 +203,7 @@ export function isAssignableTo( // Check if target has properties in common with source const inCommon = targetMembers.some((targetMember) => - sourceMembers.some((sourceMember) => targetMember.getName() === sourceMember.getName()) + sourceMembers.some((sourceMember) => targetMember.getName() === sourceMember.getName()), ); return ( @@ -221,7 +221,7 @@ export function isAssignableTo( targetMember.getType(), sourceMember.getType(), inferMap, - new Set(insideTypes).add(source).add(target) + new Set(insideTypes).add(source).add(target), ); }) ); @@ -271,7 +271,7 @@ export function isAssignableTo( targetMember.getType(), new TupleType(remaining), inferMap, - insideTypes + insideTypes, ); } // The type cannot be assigned if more than one source diff --git a/src/Utils/narrowType.ts b/src/Utils/narrowType.ts index 83215972f..13b060a67 100644 --- a/src/Utils/narrowType.ts +++ b/src/Utils/narrowType.ts @@ -20,7 +20,7 @@ export function narrowType( type: BaseType, // TODO: remove the next line // eslint-disable-next-line no-shadow - predicate: (type: BaseType) => boolean + predicate: (type: BaseType) => boolean, ): BaseType { const derefed = derefType(type); if (derefed instanceof UnionType || derefed instanceof EnumType) { diff --git a/src/Utils/removeUnreachable.ts b/src/Utils/removeUnreachable.ts index 7caa67eb7..f8a4967fc 100644 --- a/src/Utils/removeUnreachable.ts +++ b/src/Utils/removeUnreachable.ts @@ -7,7 +7,7 @@ const DEFINITION_OFFSET = "#/definitions/".length; function addReachable( definition: Definition | JSONSchema7Definition, definitions: StringMap, - reachable: Set + reachable: Set, ) { if (typeof definition === "boolean") { return; @@ -65,7 +65,7 @@ function addReachable( export function removeUnreachable( rootTypeDefinition: Definition | undefined, - definitions: StringMap + definitions: StringMap, ): StringMap { if (!rootTypeDefinition) { return definitions; diff --git a/src/Utils/typeKeys.ts b/src/Utils/typeKeys.ts index 5ade6ee97..1053f1ede 100644 --- a/src/Utils/typeKeys.ts +++ b/src/Utils/typeKeys.ts @@ -25,7 +25,7 @@ export function getTypeKeys(type: BaseType): LiteralType[] { if (type instanceof IntersectionType || type instanceof UnionType) { return uniqueLiterals( - type.getTypes().reduce((result: LiteralType[], subType) => [...result, ...getTypeKeys(subType)], []) + type.getTypes().reduce((result: LiteralType[], subType) => [...result, ...getTypeKeys(subType)], []), ); } @@ -39,8 +39,8 @@ export function getTypeKeys(type: BaseType): LiteralType[] { .getBaseTypes() .reduce( (result: LiteralType[], parentType) => [...result, ...getTypeKeys(parentType)], - objectProperties - ) + objectProperties, + ), ); } diff --git a/test/config.test.ts b/test/config.test.ts index fe91bbcb3..a9fc245ab 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -25,7 +25,7 @@ function assertSchema( userConfig: Config & { type: string }, tsconfig?: boolean, formatterAugmentor?: FormatterAugmentor, - parserAugmentor?: ParserAugmentor + parserAugmentor?: ParserAugmentor, ) { return () => { const config: CompletedConfig = { @@ -44,7 +44,7 @@ function assertSchema( program, createParser(program, config, parserAugmentor), createFormatter(config, formatterAugmentor), - config + config, ); const schema = generator.createSchema(config.type); @@ -160,7 +160,7 @@ describe("config", () => { expose: "all", topRef: true, jsDoc: "none", - }) + }), ); it( "expose-all-topref-true-not-exported", @@ -169,7 +169,7 @@ describe("config", () => { expose: "all", topRef: true, jsDoc: "none", - }) + }), ); it( @@ -179,7 +179,7 @@ describe("config", () => { expose: "all", topRef: false, jsDoc: "none", - }) + }), ); it( "expose-all-topref-false-not-exported", @@ -188,7 +188,7 @@ describe("config", () => { expose: "all", topRef: false, jsDoc: "none", - }) + }), ); it( @@ -198,7 +198,7 @@ describe("config", () => { expose: "none", topRef: true, jsDoc: "none", - }) + }), ); it( "expose-none-topref-false", @@ -207,7 +207,7 @@ describe("config", () => { expose: "none", topRef: false, jsDoc: "none", - }) + }), ); it( @@ -217,7 +217,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "none", - }) + }), ); it( "expose-export-topref-false", @@ -226,7 +226,7 @@ describe("config", () => { expose: "export", topRef: false, jsDoc: "none", - }) + }), ); it( @@ -236,7 +236,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "none", - }) + }), ); it( "jsdoc-complex-basic", @@ -245,7 +245,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "basic", - }) + }), ); it( "jsdoc-complex-extended", @@ -254,7 +254,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( "jsdoc-description-only", @@ -263,7 +263,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( @@ -273,7 +273,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( @@ -283,7 +283,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( @@ -293,7 +293,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( @@ -303,7 +303,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); it( "jsdoc-inheritance-exclude", @@ -312,7 +312,7 @@ describe("config", () => { expose: "export", topRef: true, jsDoc: "extended", - }) + }), ); // ensure that skipping type checking doesn't alter the JSON schema output @@ -324,7 +324,7 @@ describe("config", () => { topRef: true, jsDoc: "extended", skipTypeCheck: true, - }) + }), ); it( "markdown-description", @@ -335,7 +335,7 @@ describe("config", () => { jsDoc: "extended", sortProps: true, markdownDescription: true, - }) + }), ); it( "tsconfig-support", @@ -347,8 +347,8 @@ describe("config", () => { topRef: false, jsDoc: "none", }, - true - ) + true, + ), ); it( @@ -359,7 +359,7 @@ describe("config", () => { encodeRefs: false, topRef: true, jsDoc: "none", - }) + }), ); it( @@ -367,7 +367,7 @@ describe("config", () => { assertSchema("additional-properties", { type: "MyObject", additionalProperties: true, - }) + }), ); it( @@ -375,13 +375,13 @@ describe("config", () => { assertSchema("arrow-function-parameters", { type: "myFunction", expose: "all", - }) + }), ); it( "function-parameters-all", assertSchema("function-parameters-all", { type: "*", - }) + }), ); it( @@ -392,8 +392,8 @@ describe("config", () => { type: "MyObject", }, false, - (formatter) => formatter.addTypeFormatter(new ExampleFunctionTypeFormatter()) - ) + (formatter) => formatter.addTypeFormatter(new ExampleFunctionTypeFormatter()), + ), ); it( @@ -404,8 +404,8 @@ describe("config", () => { type: "MyObject", }, false, - (formatter) => formatter.addTypeFormatter(new ExampleEnumTypeFormatter()) - ) + (formatter) => formatter.addTypeFormatter(new ExampleEnumTypeFormatter()), + ), ); it( @@ -417,8 +417,8 @@ describe("config", () => { }, false, (formatter, circularReferenceTypeFormatter) => - formatter.addTypeFormatter(new ExampleDefinitionOverrideFormatter(circularReferenceTypeFormatter)) - ) + formatter.addTypeFormatter(new ExampleDefinitionOverrideFormatter(circularReferenceTypeFormatter)), + ), ); it( @@ -430,8 +430,8 @@ describe("config", () => { }, false, undefined, - (parser) => parser.addNodeParser(new ExampleConstructorParser()) - ) + (parser) => parser.addNodeParser(new ExampleConstructorParser()), + ), ); it( @@ -443,8 +443,8 @@ describe("config", () => { }, false, undefined, - (parser) => parser.addNodeParser(new ExampleNullParser()) - ) + (parser) => parser.addNodeParser(new ExampleNullParser()), + ), ); it( @@ -452,7 +452,7 @@ describe("config", () => { assertSchema("functions-hide", { type: "MyType", functions: "hide", - }) + }), ); it( @@ -460,6 +460,6 @@ describe("config", () => { assertSchema("functions-comment", { type: "MyType", functions: "comment", - }) + }), ); }); diff --git a/test/config/arrow-function-parameters/main.ts b/test/config/arrow-function-parameters/main.ts index 4db486f29..72faf3912 100644 --- a/test/config/arrow-function-parameters/main.ts +++ b/test/config/arrow-function-parameters/main.ts @@ -9,7 +9,7 @@ export const myFunction = ( * @description Inline parameter description */ optionalArgument?: string, - optionalArgumentWithDefault: number = 42 + optionalArgumentWithDefault: number = 42, ) => { return "whatever"; }; diff --git a/test/config/function-parameters-all/main.ts b/test/config/function-parameters-all/main.ts index b5e9d90b0..60b10043c 100644 --- a/test/config/function-parameters-all/main.ts +++ b/test/config/function-parameters-all/main.ts @@ -4,7 +4,7 @@ export const myFunction = ( /** * @description Inline parameter description */ - requiredString: String + requiredString: String, ) => { return "whatever"; }; diff --git a/test/invalid-data.test.ts b/test/invalid-data.test.ts index 16bd1b68c..aa82d2d6d 100644 --- a/test/invalid-data.test.ts +++ b/test/invalid-data.test.ts @@ -22,7 +22,7 @@ function assertSchema(name: string, type: string, message: string) { const generator: SchemaGenerator = new SchemaGenerator( program, createParser(program, config), - createFormatter(config) + createFormatter(config), ); expect(() => generator.createSchema(type)).toThrow(message); @@ -41,8 +41,8 @@ describe("invalid-data", () => { "MyType", 'Cannot find discriminator keyword "type" in type ' + '{"name":"B","type":{"id":"interface-1119825560-40-63-1119825560-0-124",' + - '"baseTypes":[],"properties":[],"additionalProperties":false,"nonPrimitive":false}}.' - ) + '"baseTypes":[],"properties":[],"additionalProperties":false,"nonPrimitive":false}}.', + ), ); it( "non-union-discriminator", @@ -53,11 +53,11 @@ describe("invalid-data", () => { '{"id":"interface-2103469249-0-76-2103469249-0-77","baseTypes":[],' + '"properties":[{"name":"name","type":{},"required":true}],' + '"additionalProperties":false,"nonPrimitive":false}. ' + - "This tag can only be assigned to union types." - ) + "This tag can only be assigned to union types.", + ), ); it( "duplicate-discriminator", - assertSchema("duplicate-discriminator", "MyType", 'Duplicate discriminator values: A in type "(A|B)".') + assertSchema("duplicate-discriminator", "MyType", 'Duplicate discriminator values: A in type "(A|B)".'), ); }); diff --git a/test/unit/deepMerge.test.ts b/test/unit/deepMerge.test.ts index e78c2289f..3ec460ff0 100644 --- a/test/unit/deepMerge.test.ts +++ b/test/unit/deepMerge.test.ts @@ -6,7 +6,7 @@ describe("deepMerge", () => { flag: { type: "boolean", const: true }, }); expect( - deepMerge({ flag: { type: "boolean", enum: [true] } }, { flag: { type: "boolean", enum: [true, false] } }) + deepMerge({ flag: { type: "boolean", enum: [true] } }, { flag: { type: "boolean", enum: [true, false] } }), ).toEqual({ flag: { type: "boolean", const: true } }); }); @@ -15,7 +15,7 @@ describe("deepMerge", () => { flag: { type: "boolean", const: false }, }); expect( - deepMerge({ flag: { type: "boolean", const: false } }, { flag: { type: "boolean", enum: [true, false] } }) + deepMerge({ flag: { type: "boolean", const: false } }, { flag: { type: "boolean", enum: [true, false] } }), ).toEqual({ flag: { type: "boolean", const: false } }); }); @@ -24,12 +24,12 @@ describe("deepMerge", () => { flag: { type: "number", enum: [1, 2] }, }); expect( - deepMerge({ flag: { type: "number", enum: [1, 2, 3] } }, { flag: { type: "number", enum: [1, 3] } }) + deepMerge({ flag: { type: "number", enum: [1, 2, 3] } }, { flag: { type: "number", enum: [1, 3] } }), ).toEqual({ flag: { type: "number", enum: [1, 3] }, }); expect( - deepMerge({ flag: { type: "number", enum: [1, 2] } }, { flag: { type: "number", enum: [1, 3] } }) + deepMerge({ flag: { type: "number", enum: [1, 2] } }, { flag: { type: "number", enum: [1, 3] } }), ).toEqual({ flag: { type: "number", const: 1 }, }); diff --git a/test/unit/isAssignableTo.test.ts b/test/unit/isAssignableTo.test.ts index 27dab7f28..f05744ee4 100644 --- a/test/unit/isAssignableTo.test.ts +++ b/test/unit/isAssignableTo.test.ts @@ -113,8 +113,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true), - new AnyType() - ) + new AnyType(), + ), ).toBe(true); expect(isAssignableTo(new BooleanType(), new AnyType())).toBe(true); expect(isAssignableTo(new NumberType(), new AnyType())).toBe(true); @@ -133,8 +133,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true), - new NeverType() - ) + new NeverType(), + ), ).toBe(true); expect(isAssignableTo(new BooleanType(), new NeverType())).toBe(true); expect(isAssignableTo(new NumberType(), new NeverType())).toBe(true); @@ -153,8 +153,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new AnyType(), - new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true) - ) + new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true), + ), ).toBe(true); expect(isAssignableTo(new AnyType(), new BooleanType())).toBe(true); expect(isAssignableTo(new AnyType(), new NumberType())).toBe(true); @@ -173,8 +173,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new UnknownType(), - new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true) - ) + new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true), + ), ).toBe(true); expect(isAssignableTo(new UnknownType(), new BooleanType())).toBe(true); expect(isAssignableTo(new UnknownType(), new NumberType())).toBe(true); @@ -194,8 +194,8 @@ describe("isAssignableTo", () => { expect( isAssignableTo( new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], false), - new UnknownType() - ) + new UnknownType(), + ), ).toBe(false); expect(isAssignableTo(new BooleanType(), new UnknownType())).toBe(false); expect(isAssignableTo(new NumberType(), new UnknownType())).toBe(false); @@ -230,13 +230,13 @@ describe("isAssignableTo", () => { }); it("lets tuple type to be assigned to array type if item types match", () => { expect( - isAssignableTo(new ArrayType(new StringType()), new TupleType([new StringType(), new StringType()])) + isAssignableTo(new ArrayType(new StringType()), new TupleType([new StringType(), new StringType()])), ).toBe(true); expect( - isAssignableTo(new ArrayType(new NumberType()), new TupleType([new StringType(), new StringType()])) + isAssignableTo(new ArrayType(new NumberType()), new TupleType([new StringType(), new StringType()])), ).toBe(false); expect( - isAssignableTo(new ArrayType(new StringType()), new TupleType([new StringType(), new NumberType()])) + isAssignableTo(new ArrayType(new StringType()), new TupleType([new StringType(), new NumberType()])), ).toBe(false); }); it("lets array types to be assigned to array-like object", () => { @@ -244,25 +244,25 @@ describe("isAssignableTo", () => { "fixedLengthArrayLike", [], [new ObjectProperty("length", new LiteralType(2), true)], - false + false, ); const nonFixedLengthArrayLike = new ObjectType( "nonFixedLengthArrayLike", [], [new ObjectProperty("length", new NumberType(), true)], - false + false, ); const optionalLengthArrayLike = new ObjectType( "optionalLengthArrayLike", [], [new ObjectProperty("length", new NumberType(), false)], - false + false, ); const nonArrayLike = new ObjectType( "nonArrayLike", [], [new ObjectProperty("foo", new NumberType(), true)], - false + false, ); const arrayType = new ArrayType(new StringType()); @@ -280,59 +280,59 @@ describe("isAssignableTo", () => { }); it("lets only compatible tuple type to be assigned to tuple type", () => { expect( - isAssignableTo(new TupleType([new StringType(), new StringType()]), new ArrayType(new StringType())) + isAssignableTo(new TupleType([new StringType(), new StringType()]), new ArrayType(new StringType())), ).toBe(false); expect(isAssignableTo(new TupleType([new StringType(), new StringType()]), new StringType())).toBe(false); expect( isAssignableTo( new TupleType([new StringType(), new StringType()]), - new TupleType([new StringType(), new NumberType()]) - ) + new TupleType([new StringType(), new NumberType()]), + ), ).toBe(false); expect( isAssignableTo( new TupleType([new StringType(), new StringType()]), - new TupleType([new StringType(), new StringType()]) - ) + new TupleType([new StringType(), new StringType()]), + ), ).toBe(true); expect( isAssignableTo( new TupleType([new StringType(), new OptionalType(new StringType())]), - new TupleType([new StringType()]) - ) + new TupleType([new StringType()]), + ), ).toBe(true); expect( isAssignableTo( new TupleType([new StringType(), new OptionalType(new StringType())]), - new TupleType([new StringType(), new StringType()]) - ) + new TupleType([new StringType(), new StringType()]), + ), ).toBe(true); expect( isAssignableTo( new TupleType([new StringType(), new InferType("T")]), - new TupleType([new StringType(), new NumberType(), new StringType()]) - ) + new TupleType([new StringType(), new NumberType(), new StringType()]), + ), ).toBe(false); expect( isAssignableTo( new TupleType([new StringType(), new InferType("T")]), - new TupleType([new StringType(), new NumberType()]) - ) + new TupleType([new StringType(), new NumberType()]), + ), ).toBe(true); expect( - isAssignableTo(new TupleType([new StringType(), new InferType("T")]), new TupleType([new StringType()])) + isAssignableTo(new TupleType([new StringType(), new InferType("T")]), new TupleType([new StringType()])), ).toBe(false); expect( isAssignableTo( new TupleType([new StringType(), new RestType(new InferType("T"))]), - new TupleType([new StringType()]) - ) + new TupleType([new StringType()]), + ), ).toBe(true); expect( isAssignableTo( new TupleType([new StringType(), new RestType(new InferType("T"))]), - new TupleType([new StringType(), new NumberType(), new StringType()]) - ) + new TupleType([new StringType(), new NumberType(), new StringType()]), + ), ).toBe(true); }); it("lets anything except null and undefined to be assigned to empty object type", () => { @@ -344,7 +344,7 @@ describe("isAssignableTo", () => { expect(isAssignableTo(empty, new NeverType())).toBe(true); expect(isAssignableTo(empty, new NullType())).toBe(false); expect( - isAssignableTo(empty, new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true)) + isAssignableTo(empty, new ObjectType("obj", [], [new ObjectProperty("foo", new StringType(), true)], true)), ).toBe(true); expect(isAssignableTo(empty, new BooleanType())).toBe(true); expect(isAssignableTo(empty, new NumberType())).toBe(true); @@ -370,7 +370,7 @@ describe("isAssignableTo", () => { "a", [], [new ObjectProperty("a", new StringType(), false), new ObjectProperty("b", new StringType(), false)], - false + false, ); const typeB = new ObjectType("b", [], [new ObjectProperty("b", new StringType(), false)], false); expect(isAssignableTo(typeB, typeA)).toBe(true); @@ -394,7 +394,7 @@ describe("isAssignableTo", () => { "ab", [], [new ObjectProperty("a", new StringType(), true), new ObjectProperty("b", new StringType(), true)], - false + false, ); const aAndB = new IntersectionType([a, b]); expect(isAssignableTo(a, aAndB)).toBe(true); @@ -433,7 +433,7 @@ describe("isAssignableTo", () => { "interface-src/test.ts-0-53-src/test.ts-0-317", [], [new ObjectProperty("a", new StringType(), true)], - false + false, ); const innerDefinition = new DefinitionType("NumericValueRef", objectType); const innerUnion = new UnionType([new NumberType(), innerDefinition]); diff --git a/test/utils.ts b/test/utils.ts index b3454e270..c0c9dd459 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -46,7 +46,7 @@ export function assertValidSchema( */ ajvOptions?: AjvOptions; mainTsOnly?: boolean; - } + }, ) { return (): void => { const config: CompletedConfig = { diff --git a/test/valid-data-annotations.test.ts b/test/valid-data-annotations.test.ts index 35492baa4..620772522 100644 --- a/test/valid-data-annotations.test.ts +++ b/test/valid-data-annotations.test.ts @@ -14,28 +14,28 @@ describe("valid-data-annotations", () => { "customMultilineProperty", "customUnquotedProperty", ], - }) + }), ); it( "annotation-empty-basic", - assertValidSchema("annotation-empty", "MyObject", { jsDoc: "basic", extraTags: ["customEmptyAnnotation"] }) + assertValidSchema("annotation-empty", "MyObject", { jsDoc: "basic", extraTags: ["customEmptyAnnotation"] }), ); it( "annotation-empty-extended", - assertValidSchema("annotation-empty", "MyObject", { extraTags: ["customEmptyAnnotation"] }) + assertValidSchema("annotation-empty", "MyObject", { extraTags: ["customEmptyAnnotation"] }), ); it( "annotation-deprecated-basic", - assertValidSchema("annotation-deprecated", "MyObject", { jsDoc: "basic", extraTags: ["deprecationMessage"] }) + assertValidSchema("annotation-deprecated", "MyObject", { jsDoc: "basic", extraTags: ["deprecationMessage"] }), ); it( "annotation-deprecated-extended", - assertValidSchema("annotation-deprecated", "MyObject", { extraTags: ["deprecationMessage"] }) + assertValidSchema("annotation-deprecated", "MyObject", { extraTags: ["deprecationMessage"] }), ); it( "annotation-description-override", - assertValidSchema("annotation-description-override", "MyObject", { extraTags: ["markdownDescription"] }) + assertValidSchema("annotation-description-override", "MyObject", { extraTags: ["markdownDescription"] }), ); it("annotation-comment", assertValidSchema("annotation-comment", "MyObject")); @@ -86,6 +86,6 @@ describe("valid-data-annotations", () => { it( "discriminator", - assertValidSchema("discriminator", "Animal", { jsDoc: "basic", discriminatorType: "open-api" }) + assertValidSchema("discriminator", "Animal", { jsDoc: "basic", discriminatorType: "open-api" }), ); }); diff --git a/test/valid-data-other.test.ts b/test/valid-data-other.test.ts index cfb42fa49..309c1c18b 100644 --- a/test/valid-data-other.test.ts +++ b/test/valid-data-other.test.ts @@ -17,7 +17,7 @@ describe("valid-data-other", () => { it("function-parameters-required", assertValidSchema("function-parameters-required", "myFunction")); it( "function-parameters-variable-assignment", - assertValidSchema("function-parameters-variable-assignment", "myFunction") + assertValidSchema("function-parameters-variable-assignment", "myFunction"), ); it("function-function-syntax", assertValidSchema("function-function-syntax", "myFunction")); @@ -29,7 +29,7 @@ describe("valid-data-other", () => { it("string-template-expression-literals", assertValidSchema("string-template-expression-literals", "MyObject")); it( "string-template-expression-literals-import", - assertValidSchema("string-template-expression-literals-import", "MyObject") + assertValidSchema("string-template-expression-literals-import", "MyObject"), ); it("namespace-deep-1", assertValidSchema("namespace-deep-1", "RootNamespace.Def")); @@ -85,7 +85,7 @@ describe("valid-data-other", () => { assertValidSchema("object-required", "MyObject", undefined, { ...objectRequiredSamples, ajvOptions: { $data: true }, - }) + }), ); it("re-export-with-asterisk", assertValidSchema("re-export-with-asterisk", "*", undefined, { mainTsOnly: true })); }); diff --git a/test/valid-data-struct.test.ts b/test/valid-data-struct.test.ts index 5d51c8368..0e8b7a27f 100644 --- a/test/valid-data-struct.test.ts +++ b/test/valid-data-struct.test.ts @@ -10,7 +10,7 @@ describe("valid-data-struct", () => { it("literal-object-type", assertValidSchema("literal-object-type", "MyType")); it( "literal-object-type-with-computed-props", - assertValidSchema("literal-object-type-with-computed-props", "MyType") + assertValidSchema("literal-object-type-with-computed-props", "MyType"), ); it("literal-array-type", assertValidSchema("literal-array-type", "MyType")); it("literal-index-type", assertValidSchema("literal-index-type", "MyType")); diff --git a/test/valid-data-type.test.ts b/test/valid-data-type.test.ts index 11c0a5720..d91be0ac2 100644 --- a/test/valid-data-type.test.ts +++ b/test/valid-data-type.test.ts @@ -4,7 +4,7 @@ describe("valid-data-type", () => { it("type-aliases-primitive", assertValidSchema("type-aliases-primitive", "MyString")); it( "type-aliases-primitive-with-id", - assertValidSchema("type-aliases-primitive-with-id", "MyString", { jsDoc: "none", schemaId: "testId" }) + assertValidSchema("type-aliases-primitive-with-id", "MyString", { jsDoc: "none", schemaId: "testId" }), ); it("type-aliases-object", assertValidSchema("type-aliases-object", "MyAlias")); it("type-aliases-mixed", assertValidSchema("type-aliases-mixed", "MyObject")); @@ -15,11 +15,11 @@ describe("valid-data-type", () => { it("type-aliases-recursive-export", assertValidSchema("type-aliases-recursive-export", "MyObject")); it( "type-aliases-recursive-generics-anonymous", - assertValidSchema("type-aliases-recursive-generics-anonymous", "MyAlias") + assertValidSchema("type-aliases-recursive-generics-anonymous", "MyAlias"), ); it( "type-aliases-recursive-generics-export", - assertValidSchema("type-aliases-recursive-generics-export", "MyAlias") + assertValidSchema("type-aliases-recursive-generics-export", "MyAlias"), ); it("type-aliases-tuple", assertValidSchema("type-aliases-tuple", "MyTuple")); @@ -44,19 +44,19 @@ describe("valid-data-type", () => { it("type-intersection-partial-conflict-ref", assertValidSchema("type-intersection-partial-conflict", "MyType")); it( "type-intersection-partial-conflict-union", - assertValidSchema("type-intersection-partial-conflict-union", "MyType") + assertValidSchema("type-intersection-partial-conflict-union", "MyType"), ); it( "type-intersection-partial-conflict-union-alias", - assertValidSchema("type-intersection-partial-conflict-union-alias", "MyType") + assertValidSchema("type-intersection-partial-conflict-union-alias", "MyType"), ); it( "type-intersection-recursive-interface", - assertValidSchema("type-intersection-recursive-interface", "Intersection") + assertValidSchema("type-intersection-recursive-interface", "Intersection"), ); it( "type-intersection-union-recursive-interface", - assertValidSchema("type-intersection-union-recursive-interface", "Intersection") + assertValidSchema("type-intersection-union-recursive-interface", "Intersection"), ); it("type-intersection-union", assertValidSchema("type-intersection-union", "MyObject")); it("type-intersection-union-enum", assertValidSchema("type-intersection-union-enum", "MyObject")); diff --git a/test/valid-data/class-jsdoc/main.ts b/test/valid-data/class-jsdoc/main.ts index 592a0b4e5..329e5d4db 100644 --- a/test/valid-data/class-jsdoc/main.ts +++ b/test/valid-data/class-jsdoc/main.ts @@ -16,6 +16,6 @@ export class MyObject { */ public constructor( public a: string, - public b: number + public b: number, ) {} } diff --git a/test/valid-data/class-single/main.ts b/test/valid-data/class-single/main.ts index 628e13d7f..c66202ca8 100644 --- a/test/valid-data/class-single/main.ts +++ b/test/valid-data/class-single/main.ts @@ -24,7 +24,7 @@ export class MyObject { c: number, // Test that types can be inferred public propC = 42, - public propD?: string + public propD?: string, ) { this.privateProp = false; } diff --git a/test/valid-data/function-parameters-jsdoc/main.ts b/test/valid-data/function-parameters-jsdoc/main.ts index fe406a7b6..003172036 100644 --- a/test/valid-data/function-parameters-jsdoc/main.ts +++ b/test/valid-data/function-parameters-jsdoc/main.ts @@ -2,7 +2,7 @@ export const myFunction = ( /** * @description Inline parameter description */ - requiredString: string + requiredString: string, ) => { return "whatever"; }; diff --git a/ts-json-schema-generator.ts b/ts-json-schema-generator.ts index 14048e832..bdfc59bdf 100644 --- a/ts-json-schema-generator.ts +++ b/ts-json-schema-generator.ts @@ -14,26 +14,26 @@ const args = new Command() .option("-i, --id ", "$id for generated schema") .option("-f, --tsconfig ", "Custom tsconfig.json path") .addOption( - new Option("-e, --expose ", "Type exposing").choices(["all", "none", "export"]).default("export") + new Option("-e, --expose ", "Type exposing").choices(["all", "none", "export"]).default("export"), ) .addOption( new Option("-j, --jsDoc ", "Read JsDoc annotations") .choices(["none", "basic", "extended"]) - .default("extended") + .default("extended"), ) .addOption( new Option("--markdown-description", "Generate `markdownDescription` in addition to `description`.").implies({ jsDoc: "extended", - }) + }), ) .addOption( new Option( "--functions ", - "How to handle functions. `fail` will throw an error. `comment` will add a comment. `hide` will treat the function like a NeverType or HiddenType." + "How to handle functions. `fail` will throw an error. `comment` will add a comment. `hide` will treat the function like a NeverType or HiddenType.", ) .choices(["fail", "comment", "hide"]) - .default("comment") + .default("comment"), ) .option("--minify", "Minify generated schema", false) .option("--unstable", "Do not sort properties") @@ -46,7 +46,7 @@ const args = new Command() "--validation-keywords [value]", "Provide additional validation keywords to include", (value: string, list: string[]) => list.concat(value), - [] + [], ) .option("--additional-properties", "Allow additional properties for objects with no index signature", false) .version(pkg.version)