fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: cleaner length syntax

Lubos afba377b 5399f767

+236 -237
+1 -1
examples/openapi-ts-axios/src/client/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/codegen-core/src/config/load.ts
··· 28 28 29 29 const fileConfigs = fileConfig instanceof Array ? fileConfig : [fileConfig]; 30 30 const mergedConfigs = fileConfigs.map((config) => mergeConfigs<T>(config, userConfig)); 31 - const foundConfig = fileConfigs.some((config) => Object.keys(config).length > 0); 31 + const foundConfig = fileConfigs.some((config) => Object.keys(config).length); 32 32 33 33 return { configFile: loadedConfigFile, configs: mergedConfigs, foundConfig }; 34 34 }
+1 -1
packages/codegen-core/src/logger.ts
··· 77 77 if (!event.end) { 78 78 event.end = performance.mark(idEnd(event.id)); 79 79 } 80 - if (event.events.length > 0) { 80 + if (event.events.length) { 81 81 this.endAllEvents(event.events); 82 82 } 83 83 }
+2 -2
packages/json-schema-ref-parser/src/bundle.ts
··· 445 445 const ensureContainer = ( 446 446 type: 'schemas' | 'parameters' | 'requestBodies' | 'responses' | 'headers', 447 447 ) => { 448 - const isOas3 = !!(root && typeof root === 'object' && typeof root.openapi === 'string'); 449 - const isOas2 = !!(root && typeof root === 'object' && typeof root.swagger === 'string'); 448 + const isOas3 = Boolean(root && typeof root === 'object' && typeof root.openapi === 'string'); 449 + const isOas2 = Boolean(root && typeof root === 'object' && typeof root.swagger === 'string'); 450 450 451 451 if (isOas3) { 452 452 if (!root.components || typeof root.components !== 'object') {
+8 -8
packages/json-schema-ref-parser/src/index.ts
··· 117 117 118 118 await resolveExternal(this, this.options); 119 119 const errors = JSONParserErrorGroup.getParserErrors(this); 120 - if (errors.length > 0) { 120 + if (errors.length) { 121 121 throw new JSONParserErrorGroup(this); 122 122 } 123 123 _bundle(this, this.options); 124 124 const errors2 = JSONParserErrorGroup.getParserErrors(this); 125 - if (errors2.length > 0) { 125 + if (errors2.length) { 126 126 throw new JSONParserErrorGroup(this); 127 127 } 128 128 return this.schema!; ··· 148 148 149 149 await resolveExternal(this, this.options); 150 150 const errors = JSONParserErrorGroup.getParserErrors(this); 151 - if (errors.length > 0) { 151 + if (errors.length) { 152 152 throw new JSONParserErrorGroup(this); 153 153 } 154 154 _bundle(this, this.options); 155 155 // Merged root is ready for bundling 156 156 157 157 const errors2 = JSONParserErrorGroup.getParserErrors(this); 158 - if (errors2.length > 0) { 158 + if (errors2.length) { 159 159 throw new JSONParserErrorGroup(this); 160 160 } 161 161 return this.schema!; ··· 297 297 298 298 public mergeMany(): JSONSchema { 299 299 const schemas = this.schemaMany || []; 300 - if (schemas.length === 0) { 300 + if (!schemas.length) { 301 301 throw ono('mergeMany called with no schemas. Did you run parseMany?'); 302 302 } 303 303 ··· 335 335 } 336 336 } 337 337 } 338 - if (Object.keys(infoAccumulator).length > 0) { 338 + if (Object.keys(infoAccumulator).length) { 339 339 merged.info = infoAccumulator; 340 340 } 341 341 ··· 356 356 } 357 357 } 358 358 } 359 - if (servers.length > 0) { 359 + if (servers.length) { 360 360 merged.servers = servers; 361 361 } 362 362 ··· 568 568 } 569 569 } 570 570 571 - if (tags.length > 0) { 571 + if (tags.length) { 572 572 merged.tags = tags; 573 573 } 574 574
+2 -2
packages/json-schema-ref-parser/src/pointer.ts
··· 140 140 } 141 141 } 142 142 143 - if (errors.length > 0) { 143 + if (errors.length) { 144 144 throw errors.length === 1 145 145 ? errors[0] 146 146 : new AggregateError(errors, 'Multiple missing pointer errors'); ··· 171 171 const tokens = Pointer.parse(this.path); 172 172 let token; 173 173 174 - if (tokens.length === 0) { 174 + if (!tokens.length) { 175 175 // There are no tokens, replace the entire object with the new value 176 176 this.value = value; 177 177 return value;
+1 -1
packages/json-schema-ref-parser/src/ref.ts
··· 152 152 value !== null && 153 153 '$ref' in value && 154 154 typeof value.$ref === 'string' && 155 - value.$ref.length > 0 155 + Boolean(value.$ref.length) 156 156 ); 157 157 } 158 158
+1 -1
packages/json-schema-ref-parser/src/refs.ts
··· 224 224 225 225 // Filter the paths by type 226 226 types = Array.isArray(types[0]) ? types[0] : Array.prototype.slice.call(types); 227 - if (types.length > 0 && types[0]) { 227 + if (types.length && types[0]) { 228 228 paths = paths.filter((key) => types.includes($refs[key]!.pathType as string)); 229 229 } 230 230
+2 -2
packages/openapi-python/src/cli/adapter.ts
··· 12 12 if (cli.dryRun !== undefined) config.dryRun = cli.dryRun; 13 13 14 14 const plugins: ToArray<UserConfig['plugins']> = []; 15 - if (cli.plugins instanceof Array && cli.plugins.length > 0) { 15 + if (cli.plugins instanceof Array && cli.plugins.length) { 16 16 plugins.push(...cli.plugins); 17 17 } 18 18 // if (cli.client) plugins.push(cli.client); 19 - if (plugins.length > 0) config.plugins = plugins; 19 + if (plugins.length) config.plugins = plugins; 20 20 21 21 if (cli.debug || cli.silent || cli.logs || cli.logFile !== undefined) { 22 22 config.logs = {
+1 -1
packages/openapi-python/src/generate.ts
··· 63 63 const configErrors = jobs.flatMap((job) => 64 64 job.errors.map((error) => ({ error, jobIndex: job.index })), 65 65 ); 66 - if (configErrors.length > 0) { 66 + if (configErrors.length) { 67 67 throw new ConfigValidationError(configErrors); 68 68 } 69 69
+1 -1
packages/openapi-python/src/plugins/@hey-api/sdk/v1/node.ts
··· 119 119 const method = operation.method.toLowerCase(); 120 120 const opParameters = operationParameters({ operation, plugin }); 121 121 122 - if (plugin.config.paramsStructure === 'flat' && opParameters.fields.length > 0) { 122 + if (plugin.config.paramsStructure === 'flat' && opParameters.fields.length) { 123 123 const paramNames = opParameters.parameters.map((parameter) => parameter.name.toString()); 124 124 125 125 const fieldsList = $.list();
+1 -1
packages/openapi-python/src/plugins/pydantic/shared/export.ts
··· 117 117 ...(needsAlias && !field.fieldConstraints?.alias && { alias: originalName }), 118 118 }; 119 119 120 - if (Object.keys(constraints).length > 0) { 120 + if (Object.keys(constraints).length) { 121 121 const fieldCall = createFieldCall(constraints, plugin, { 122 122 required: !field.isOptional, 123 123 });
+4 -2
packages/openapi-python/src/plugins/pydantic/v2/processor.ts
··· 15 15 (ctx) => 16 16 ctx.schema.type === 'object' && 17 17 ctx.schema.properties !== undefined && 18 - Object.keys(ctx.schema.properties).length > 0, 18 + Boolean(Object.keys(ctx.schema.properties).length), 19 19 (ctx) => 20 - ctx.schema.type === 'enum' && ctx.schema.items !== undefined && ctx.schema.items.length > 0, 20 + ctx.schema.type === 'enum' && 21 + ctx.schema.items !== undefined && 22 + Boolean(ctx.schema.items.length), 21 23 plugin.config['~hooks']?.schemas?.shouldExtract, 22 24 plugin.context.config.parser.hooks.schemas?.shouldExtract, 23 25 ];
+2 -2
packages/openapi-python/src/plugins/pydantic/v2/toAst/array.ts
··· 11 11 const { applyModifiers, childResults, plugin } = ctx; 12 12 const any = plugin.external('typing.Any'); 13 13 14 - if (childResults.length === 0) { 14 + if (!childResults.length) { 15 15 return { 16 16 type: $('list').slice(any), 17 17 }; ··· 70 70 71 71 return { 72 72 ...baseResult, 73 - fieldConstraints: Object.keys(fieldConstraints).length > 0 ? fieldConstraints : undefined, 73 + fieldConstraints: Object.keys(fieldConstraints).length ? fieldConstraints : undefined, 74 74 }; 75 75 } 76 76
+2 -2
packages/openapi-python/src/plugins/pydantic/v2/toAst/enum.ts
··· 50 50 const { plugin } = ctx; 51 51 const { enumMembers } = ctx.nodes.items(ctx); 52 52 53 - if (enumMembers.length === 0) { 53 + if (!enumMembers.length) { 54 54 return { 55 55 type: plugin.external('typing.Any'), 56 56 }; ··· 59 59 const mode = plugin.config.enums ?? 'enum'; 60 60 61 61 if (mode === 'literal') { 62 - if (enumMembers.length === 0) { 62 + if (!enumMembers.length) { 63 63 return { 64 64 type: plugin.external('typing.Any'), 65 65 };
+8 -9
packages/openapi-python/src/plugins/pydantic/v2/toAst/intersection.ts
··· 14 14 function baseNode(ctx: IntersectionResolverContext): PydanticType { 15 15 const { applyModifiers, childResults, plugin } = ctx; 16 16 17 - if (childResults.length === 0) { 17 + if (!childResults.length) { 18 18 return { 19 19 type: plugin.external('typing.Any'), 20 20 }; ··· 60 60 61 61 let type: VarType; 62 62 63 - if (baseClasses.length > 0 && mergedFields.length === 0) { 63 + if (baseClasses.length && !mergedFields.length) { 64 64 type = baseClasses[0]!; 65 - } else if (mergedFields.length > 0) { 65 + } else if (mergedFields.length) { 66 66 // TODO: replace 67 67 type = '__INTERSECTION_PLACEHOLDER__'; 68 68 } else { ··· 151 151 152 152 return { 153 153 ...resolved, 154 - baseClasses: baseClasses.length > 0 ? baseClasses : undefined, 154 + baseClasses: baseClasses.length ? baseClasses : undefined, 155 155 childResults, 156 - fieldConstraints: 157 - Object.keys(constraints).length > 0 158 - ? { ...constraints, ...resolved.fieldConstraints } 159 - : resolved.fieldConstraints, 160 - mergedFields: mergedFields.length > 0 ? mergedFields : undefined, 156 + fieldConstraints: Object.keys(constraints).length 157 + ? { ...constraints, ...resolved.fieldConstraints } 158 + : resolved.fieldConstraints, 159 + mergedFields: mergedFields.length ? mergedFields : undefined, 161 160 }; 162 161 }
+4 -4
packages/openapi-python/src/plugins/pydantic/v2/toAst/tuple.ts
··· 13 13 const tuple = plugin.external('typing.Tuple'); 14 14 const any = plugin.external('typing.Any'); 15 15 16 - if (childResults.length === 0) { 16 + if (!childResults.length) { 17 17 return { 18 18 type: $(tuple).slice(), 19 19 }; ··· 28 28 } 29 29 } 30 30 31 - if (itemTypes.length === 0) { 31 + if (!itemTypes.length) { 32 32 return { 33 33 type: $(tuple).slice(any, '...'), 34 34 }; ··· 57 57 58 58 return { 59 59 ...baseResult, 60 - fieldConstraints: Object.keys(fieldConstraints).length > 0 ? fieldConstraints : undefined, 60 + fieldConstraints: Object.keys(fieldConstraints).length ? fieldConstraints : undefined, 61 61 }; 62 62 } 63 63 ··· 76 76 77 77 const childResults: Array<PydanticResult> = []; 78 78 79 - if (schema.items && schema.items.length > 0) { 79 + if (schema.items && schema.items.length) { 80 80 for (let i = 0; i < schema.items.length; i++) { 81 81 const item = schema.items[i]!; 82 82 const result = walk(item, childContext(walkerCtx, 'items', i));
+4 -5
packages/openapi-python/src/plugins/pydantic/v2/toAst/union.ts
··· 22 22 23 23 isNullable = isNullable || childResults.some((r) => r.meta.nullable); 24 24 25 - if (nonNullResults.length === 0) { 25 + if (!nonNullResults.length) { 26 26 return { 27 27 type: 'None', 28 28 }; ··· 103 103 return { 104 104 ...resolved, 105 105 childResults, 106 - fieldConstraints: 107 - Object.keys(constraints).length > 0 108 - ? { ...constraints, ...resolved.fieldConstraints } 109 - : resolved.fieldConstraints, 106 + fieldConstraints: Object.keys(constraints).length 107 + ? { ...constraints, ...resolved.fieldConstraints } 108 + : resolved.fieldConstraints, 110 109 isNullable, 111 110 }; 112 111 }
+2 -2
packages/openapi-python/src/py-compiler/printer.ts
··· 249 249 case PyNodeKind.ImportStatement: { 250 250 const fromPrefix = node.isFrom ? `from ${node.module} ` : ''; 251 251 if (fromPrefix) { 252 - if (node.names && node.names.length > 0) { 252 + if (node.names && node.names.length) { 253 253 const imports = node.names 254 254 .map(({ alias, name }) => (alias ? `${name} as ${alias}` : name)) 255 255 .join(', '); ··· 258 258 parts.push(printLine(`${fromPrefix}import *`)); 259 259 } 260 260 } else { 261 - if (node.names && node.names.length > 0) { 261 + if (node.names && node.names.length) { 262 262 const imports = node.names 263 263 .map(({ alias, name }) => (alias ? `${name} as ${alias}` : name)) 264 264 .join(', ');
+3 -3
packages/openapi-python/src/py-dsl/decl/class.ts
··· 47 47 48 48 /** Returns true when all required builder calls are present. */ 49 49 get isValid(): boolean { 50 - return this.missingRequiredCalls().length === 0; 50 + return !this.missingRequiredCalls().length; 51 51 } 52 52 53 53 /** Returns true if the class has any members. */ 54 54 get hasBody(): boolean { 55 - return this.body.length > 0; 55 + return Boolean(this.body.length); 56 56 } 57 57 58 58 /** Adds one or more class members (fields, methods, etc.). */ ··· 107 107 108 108 $validate(): asserts this { 109 109 const missing = this.missingRequiredCalls(); 110 - if (missing.length === 0) return; 110 + if (!missing.length) return; 111 111 throw new Error(`Class declaration missing ${missing.join(' and ')}`); 112 112 } 113 113
+2 -2
packages/openapi-python/src/py-dsl/decl/func.ts
··· 50 50 51 51 /** Returns true when all required builder calls are present. */ 52 52 get isValid(): boolean { 53 - return this.missingRequiredCalls().length === 0; 53 + return !this.missingRequiredCalls().length; 54 54 } 55 55 56 56 override toAst() { ··· 68 68 69 69 $validate(): asserts this { 70 70 const missing = this.missingRequiredCalls(); 71 - if (missing.length === 0) return; 71 + if (!missing.length) return; 72 72 throw new Error(`Function declaration missing ${missing.join(' and ')}`); 73 73 } 74 74
+2 -2
packages/openapi-python/src/py-dsl/decl/param.ts
··· 41 41 } 42 42 43 43 get isValid(): boolean { 44 - return this.missingRequiredCalls().length === 0; 44 + return !this.missingRequiredCalls().length; 45 45 } 46 46 47 47 /** Sets the parameter type. */ ··· 61 61 62 62 $validate(): asserts this { 63 63 const missing = this.missingRequiredCalls(); 64 - if (missing.length === 0) return; 64 + if (!missing.length) return; 65 65 throw new Error(`Parameter missing ${missing.join(' and ')}`); 66 66 } 67 67
+2 -2
packages/openapi-python/src/py-dsl/expr/attr.ts
··· 31 31 32 32 /** Returns true when all required builder calls are present. */ 33 33 get isValid(): boolean { 34 - return this.missingRequiredCalls().length === 0; 34 + return !this.missingRequiredCalls().length; 35 35 } 36 36 37 37 override toAst() { ··· 50 50 left: MaybePyDsl<py.Expression>; 51 51 } { 52 52 const missing = this.missingRequiredCalls(); 53 - if (missing.length === 0) return; 53 + if (!missing.length) return; 54 54 throw new Error(`Attribute access missing ${missing.join(' and ')}`); 55 55 } 56 56
+2 -2
packages/openapi-python/src/py-dsl/expr/binary.ts
··· 54 54 55 55 /** Returns true when all required builder calls are present. */ 56 56 get isValid(): boolean { 57 - return this.missingRequiredCalls().length === 0; 57 + return !this.missingRequiredCalls().length; 58 58 } 59 59 60 60 and(right: MaybePyDsl<py.Expression>): this { ··· 149 149 _right: MaybePyDsl<py.Expression>; 150 150 } { 151 151 const missing = this.missingRequiredCalls(); 152 - if (missing.length === 0) return; 152 + if (!missing.length) return; 153 153 throw new Error(`Binary expression missing ${missing.join(' and ')}`); 154 154 } 155 155
+2 -2
packages/openapi-python/src/py-dsl/expr/call.ts
··· 32 32 33 33 /** Returns true when all required builder calls are present. */ 34 34 get isValid(): boolean { 35 - return this.missingRequiredCalls().length === 0; 35 + return !this.missingRequiredCalls().length; 36 36 } 37 37 38 38 override toAst() { ··· 45 45 _callee: MaybePyDsl<py.Expression>; 46 46 } { 47 47 const missing = this.missingRequiredCalls(); 48 - if (missing.length === 0) return; 48 + if (!missing.length) return; 49 49 throw new Error(`Call expression missing ${missing.join(' and ')}`); 50 50 } 51 51
+1 -1
packages/openapi-python/src/py-dsl/mixins/decorator.ts
··· 40 40 41 41 protected $decorators(): ReadonlyArray<py.Expression> { 42 42 return this._decorators.map((decorator) => 43 - decorator.args.length > 0 43 + decorator.args.length 44 44 ? py.factory.createCallExpression( 45 45 this.$node(decorator.name), 46 46 decorator.args.map((arg) => this.$node(arg)),
+2 -2
packages/openapi-python/src/py-dsl/mixins/modifiers.ts
··· 77 77 78 78 abstract class Async extends Mixed { 79 79 protected async(condition?: boolean): this { 80 - const cond = arguments.length === 0 ? true : Boolean(condition); 80 + const cond = !arguments.length ? true : Boolean(condition); 81 81 return this._m('async', cond); 82 82 } 83 83 } ··· 109 109 * @returns The target object for chaining. 110 110 */ 111 111 protected export(condition?: boolean): this { 112 - const cond = arguments.length === 0 ? true : Boolean(condition); 112 + const cond = !arguments.length ? true : Boolean(condition); 113 113 this.exported = cond; 114 114 // TODO: remove this side-effect once planner handles exported flag 115 115 if (this.symbol) this.symbol.setExported(cond);
+3 -3
packages/openapi-python/src/py-dsl/stmt/for.ts
··· 54 54 55 55 /** Returns true when all required builder calls are present. */ 56 56 get isValid(): boolean { 57 - return this.missingRequiredCalls().length === 0; 57 + return !this.missingRequiredCalls().length; 58 58 } 59 59 60 60 body(...items: Array<DoExpr>): this { ··· 87 87 _target: MaybePyDsl<py.Expression>; 88 88 } { 89 89 const missing = this.missingRequiredCalls(); 90 - if (missing.length === 0) return; 90 + if (!missing.length) return; 91 91 throw new Error(`For statement missing ${missing.join(' and ')}`); 92 92 } 93 93 ··· 95 95 const missing: Array<string> = []; 96 96 if (!this._target) missing.push('target'); 97 97 if (!this._iterable) missing.push('iterable'); 98 - if (!this._body || this._body.length === 0) missing.push('body'); 98 + if (!this._body || !this._body.length) missing.push('body'); 99 99 return missing; 100 100 } 101 101 }
+3 -3
packages/openapi-python/src/py-dsl/stmt/if.ts
··· 39 39 40 40 /** Returns true when all required builder calls are present. */ 41 41 get isValid(): boolean { 42 - return this.missingRequiredCalls().length === 0; 42 + return !this.missingRequiredCalls().length; 43 43 } 44 44 45 45 condition(condition: IfCondition): this { ··· 69 69 _condition: IfCondition; 70 70 } { 71 71 const missing = this.missingRequiredCalls(); 72 - if (missing.length === 0) return; 72 + if (!missing.length) return; 73 73 throw new Error(`If statement missing ${missing.join(' and ')}`); 74 74 } 75 75 76 76 private missingRequiredCalls(): ReadonlyArray<string> { 77 77 const missing: Array<string> = []; 78 78 if (!this._condition) missing.push('.condition()'); 79 - if (this._do.length === 0) missing.push('.do()'); 79 + if (!this._do.length) missing.push('.do()'); 80 80 return missing; 81 81 } 82 82 }
+3 -3
packages/openapi-python/src/py-dsl/stmt/try.ts
··· 80 80 81 81 /** Returns true when all required builder calls are present. */ 82 82 get isValid(): boolean { 83 - return this.missingRequiredCalls().length === 0; 83 + return !this.missingRequiredCalls().length; 84 84 } 85 85 86 86 /** ··· 200 200 _try: Array<DoExpr>; 201 201 } { 202 202 const missing = this.missingRequiredCalls(); 203 - if (missing.length === 0) return; 203 + if (!missing.length) return; 204 204 throw new Error(`Try statement missing ${missing.join(' and ')}`); 205 205 } 206 206 207 207 private missingRequiredCalls(): ReadonlyArray<string> { 208 208 const missing: Array<string> = []; 209 - if (!this._try || this._try.length === 0) missing.push('.try()'); 209 + if (!this._try || !this._try.length) missing.push('.try()'); 210 210 return missing; 211 211 } 212 212
+2 -2
packages/openapi-python/src/py-dsl/stmt/var.ts
··· 32 32 33 33 /** Returns true when all required builder calls are present. */ 34 34 get isValid(): boolean { 35 - return this.missingRequiredCalls().length === 0; 35 + return !this.missingRequiredCalls().length; 36 36 } 37 37 38 38 /** Sets the type annotation for the variable. */ ··· 52 52 53 53 $validate(): asserts this { 54 54 const missing = this.missingRequiredCalls(); 55 - if (missing.length === 0) return; 55 + if (!missing.length) return; 56 56 throw new Error(`Variable assignment missing ${missing.join(' and ')}`); 57 57 } 58 58
+3 -3
packages/openapi-python/src/py-dsl/stmt/while.ts
··· 47 47 48 48 /** Returns true when all required builder calls are present. */ 49 49 get isValid(): boolean { 50 - return this.missingRequiredCalls().length === 0; 50 + return !this.missingRequiredCalls().length; 51 51 } 52 52 53 53 body(...items: Array<DoExpr>): this { ··· 78 78 _condition: MaybePyDsl<py.Expression>; 79 79 } { 80 80 const missing = this.missingRequiredCalls(); 81 - if (missing.length === 0) return; 81 + if (!missing.length) return; 82 82 throw new Error(`While statement missing ${missing.join(' and ')}`); 83 83 } 84 84 85 85 private missingRequiredCalls(): ReadonlyArray<string> { 86 86 const missing: Array<string> = []; 87 87 if (!this._condition) missing.push('condition'); 88 - if (!this._body || this._body.length === 0) missing.push('body'); 88 + if (!this._body || !this._body.length) missing.push('body'); 89 89 return missing; 90 90 } 91 91 }
+3 -3
packages/openapi-python/src/py-dsl/stmt/with.ts
··· 49 49 50 50 /** Returns true when all required builder calls are present. */ 51 51 get isValid(): boolean { 52 - return this.missingRequiredCalls().length === 0; 52 + return !this.missingRequiredCalls().length; 53 53 } 54 54 55 55 body(...items: Array<DoExpr>): this { ··· 95 95 _body: Array<DoExpr>; 96 96 } { 97 97 const missing = this.missingRequiredCalls(); 98 - if (missing.length === 0) return; 98 + if (!missing.length) return; 99 99 throw new Error(`With statement missing ${missing.join(' and ')}`); 100 100 } 101 101 102 102 private missingRequiredCalls(): ReadonlyArray<string> { 103 103 const missing: Array<string> = []; 104 104 if (!this._items.length) missing.push('items'); 105 - if (!this._body || this._body.length === 0) missing.push('.body()'); 105 + if (!this._body || !this._body.length) missing.push('.body()'); 106 106 return missing; 107 107 } 108 108 }
+2 -2
packages/openapi-python/src/py-dsl/utils/context.ts
··· 60 60 // function getAccessChainForNode(node: PyDsl): NodeChain { 61 61 // const structuralChain = [...getStructuralChainForNode(node, new Set())]; 62 62 // const accessChain = structuralToAccessChain(structuralChain); 63 - // if (accessChain.length === 0) { 63 + // if (!accessChain.length) { 64 64 // // I _think_ this should not happen, but it does and this fix works for now. 65 65 // // I assume this will cause issues with imports in some cases, investigate 66 66 // // when it actually happens. ··· 84 84 // if (getScope(parent) !== getScope(node)) continue; 85 85 86 86 // const chain = getStructuralChainForNode(parent, visited); 87 - // if (chain.length > 0) return [...chain, node]; 87 + // if (chain.length) return [...chain, node]; 88 88 // } 89 89 // } 90 90
+1 -1
packages/openapi-python/src/py-dsl/utils/render-utils.ts
··· 82 82 pathSegments.push(moduleName); 83 83 } 84 84 85 - modulePath = pathSegments.length > 0 ? leadingDots + pathSegments.join('.') : leadingDots; 85 + modulePath = pathSegments.length ? leadingDots + pathSegments.join('.') : leadingDots; 86 86 87 87 return [2, parentCount, modulePath]; 88 88 }
+1 -1
packages/openapi-python/src/py-dsl/utils/render.ts
··· 176 176 alias: imp.localName !== imp.sourceName ? imp.localName : undefined, 177 177 name: imp.sourceName, 178 178 })); 179 - return py.factory.createImportStatement(group.modulePath, names, group.imports.length > 0); 179 + return py.factory.createImportStatement(group.modulePath, names, Boolean(group.imports.length)); 180 180 } 181 181 182 182 private getExports(ctx: RenderContext): Exports {
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/preact-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/preact-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/import-file-extension-ts/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-node16-sdk/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/preact-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/client/utils.gen.ts
··· 130 130 const instanceBaseUrl = options.axios?.defaults?.baseURL; 131 131 132 132 const baseUrl = 133 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 133 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 134 134 135 135 return getUrl({ 136 136 baseUrl: baseUrl as string,
+2 -2
packages/openapi-ts/src/cli/adapter.ts
··· 12 12 if (cli.dryRun !== undefined) config.dryRun = cli.dryRun; 13 13 14 14 const plugins: ToArray<UserConfig['plugins']> = []; 15 - if (cli.plugins instanceof Array && cli.plugins.length > 0) { 15 + if (cli.plugins instanceof Array && cli.plugins.length) { 16 16 plugins.push(...cli.plugins); 17 17 } 18 18 if (cli.client) plugins.push(cli.client); 19 - if (plugins.length > 0) config.plugins = plugins; 19 + if (plugins.length) config.plugins = plugins; 20 20 21 21 if (cli.debug || cli.silent || cli.logs || cli.logFile === false) { 22 22 config.logs = {
+1 -1
packages/openapi-ts/src/generate.ts
··· 63 63 const configErrors = jobs.flatMap((job) => 64 64 job.errors.map((error) => ({ error, jobIndex: job.index })), 65 65 ); 66 - if (configErrors.length > 0) { 66 + if (configErrors.length) { 67 67 throw new ConfigValidationError(configErrors); 68 68 } 69 69
+1 -1
packages/openapi-ts/src/plugins/@hey-api/client-axios/bundle/utils.ts
··· 128 128 const instanceBaseUrl = options.axios?.defaults?.baseURL; 129 129 130 130 const baseUrl = 131 - !!options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 131 + options.baseURL && typeof options.baseURL === 'string' ? options.baseURL : instanceBaseUrl; 132 132 133 133 return getUrl({ 134 134 baseUrl: baseUrl as string,
+1 -1
packages/openapi-ts/src/plugins/@hey-api/typescript/shared/operation.ts
··· 99 99 100 100 dataRequired.push('url'); 101 101 102 - if (dataRequired.length > 0) { 102 + if (dataRequired.length) { 103 103 data.required = dataRequired; 104 104 } 105 105
+1 -1
packages/openapi-ts/src/plugins/@hey-api/typescript/v1/plugin.ts
··· 96 96 97 97 createClientOptions({ nodeIndex: nodeClientIndex, plugin, servers }); 98 98 99 - if (webhooks.length > 0) { 99 + if (webhooks.length) { 100 100 const symbol = plugin.registerSymbol( 101 101 buildSymbolIn({ 102 102 meta: {
+2 -2
packages/openapi-ts/src/plugins/@hey-api/typescript/v1/toAst/enum.ts
··· 63 63 const { schema } = ctx; 64 64 const items = schema.items ?? []; 65 65 66 - if (items.length === 0) { 66 + if (!items.length) { 67 67 return $.type('never'); 68 68 } 69 69 70 70 const literalTypes = items 71 71 .filter((item) => item.const !== undefined) 72 72 .map((item) => $.type.fromValue(item.const)); 73 - return literalTypes.length > 0 ? $.type.or(...literalTypes) : $.type('string'); 73 + return literalTypes.length ? $.type.or(...literalTypes) : $.type('string'); 74 74 } 75 75 76 76 function enumResolver(ctx: EnumResolverContext): Type {
+3 -4
packages/openapi-ts/src/plugins/@hey-api/typescript/v1/toAst/object.ts
··· 54 54 } 55 55 } 56 56 57 - const hasPatterns = 58 - !!schema.patternProperties && Object.keys(schema.patternProperties).length > 0; 57 + const hasPatterns = schema.patternProperties && Object.keys(schema.patternProperties).length; 59 58 60 59 const addPropsRaw = schema.additionalProperties; 61 60 const addPropsObj = 62 61 addPropsRaw !== false && addPropsRaw ? (addPropsRaw as IR.SchemaObject) : undefined; 63 62 const shouldCreateIndex = 64 - hasPatterns || (!!addPropsObj && (addPropsObj.type !== 'never' || !indexSchemas.length)); 63 + hasPatterns || (addPropsObj && (addPropsObj.type !== 'never' || !indexSchemas.length)); 65 64 66 65 if (shouldCreateIndex) { 67 66 const addProps = addPropsObj; ··· 82 81 indexSchemas.push({ type: 'undefined' }); 83 82 } 84 83 85 - if (indexSchemas.length > 0) { 84 + if (indexSchemas.length) { 86 85 const unionSchema: IR.SchemaObject = 87 86 indexSchemas.length === 1 88 87 ? indexSchemas[0]!
+1 -1
packages/openapi-ts/src/plugins/@hey-api/typescript/v1/walker.ts
··· 157 157 resourceId: $ref, 158 158 }); 159 159 160 - if (schema.omit && schema.omit.length > 0) { 160 + if (schema.omit && schema.omit.length) { 161 161 const omittedKeys = 162 162 schema.omit.length === 1 163 163 ? $.type.literal(schema.omit[0]!)
+1 -1
packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts
··· 118 118 }) => { 119 119 const config = plugin.config.queryKeys; 120 120 let tagsExpression: ReturnType<typeof $.array> | undefined; 121 - if (config.tags && operation.tags && operation.tags.length > 0) { 121 + if (config.tags && operation.tags && operation.tags.length) { 122 122 tagsExpression = $.array(...operation.tags.map((tag) => $.literal(tag))); 123 123 } 124 124
+1 -1
packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts
··· 62 62 }); 63 63 // Optionally include tags when configured 64 64 let tagsExpr: ReturnType<typeof $.array> | undefined; 65 - if (plugin.config.queryKeys.tags && operation.tags && operation.tags.length > 0) { 65 + if (plugin.config.queryKeys.tags && operation.tags && operation.tags.length) { 66 66 tagsExpr = $.array(...operation.tags.map((t) => $.literal(t))); 67 67 } 68 68 keyExpression = $(symbolCreateQueryKey).call(
+1 -1
packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts
··· 109 109 }) => { 110 110 const config = isInfinite ? plugin.config.infiniteQueryKeys : plugin.config.queryKeys; 111 111 let tagsArray: TsDsl<ts.ArrayLiteralExpression> | undefined; 112 - if (config.tags && operation.tags && operation.tags.length > 0) { 112 + if (config.tags && operation.tags && operation.tags.length) { 113 113 tagsArray = $.array().elements(...operation.tags); 114 114 } 115 115 const symbolCreateQueryKey = plugin.referenceSymbol({
+1 -1
packages/openapi-ts/src/plugins/orpc/contracts/node.ts
··· 73 73 (o, v) => o.prop('successStatus', $.literal(v)), 74 74 ) 75 75 .$if(operation.summary, (o, v) => o.prop('summary', $.literal(v))) 76 - .$if(tags.length > 0 && tags, (o, v) => o.prop('tags', $.fromValue(v))), 76 + .$if(Boolean(tags.length) && tags, (o, v) => o.prop('tags', $.fromValue(v))), 77 77 ); 78 78 79 79 if (hasInput(operation) && plugin.config.validator.input) {
+4 -4
packages/openapi-ts/src/plugins/orpc/shared/operation.ts
··· 2 2 3 3 export function hasInput(operation: IR.OperationObject): boolean { 4 4 const hasPathParams = Boolean( 5 - operation.parameters?.path && Object.keys(operation.parameters.path).length > 0, 5 + operation.parameters?.path && Object.keys(operation.parameters.path).length, 6 6 ); 7 7 const hasQueryParams = Boolean( 8 - operation.parameters?.query && Object.keys(operation.parameters.query).length > 0, 8 + operation.parameters?.query && Object.keys(operation.parameters.query).length, 9 9 ); 10 10 const hasHeaderParams = Boolean( 11 - operation.parameters?.header && Object.keys(operation.parameters.header).length > 0, 11 + operation.parameters?.header && Object.keys(operation.parameters.header).length, 12 12 ); 13 13 const hasBody = Boolean(operation.body); 14 14 return hasPathParams || hasQueryParams || hasHeaderParams || hasBody; ··· 34 34 } 35 35 36 36 export function getTags(operation: IR.OperationObject, defaultTag: string): ReadonlyArray<string> { 37 - return operation.tags && operation.tags.length > 0 ? [...operation.tags] : [defaultTag]; 37 + return operation.tags && operation.tags.length ? [...operation.tags] : [defaultTag]; 38 38 }
+1 -1
packages/openapi-ts/src/plugins/valibot/shared/pipes.ts
··· 35 35 if (!(pipes instanceof Array)) { 36 36 return pipes; 37 37 } 38 - if (pipes.length === 0) { 38 + if (!pipes.length) { 39 39 const v = plugin.external('valibot.v'); 40 40 return $(v).attr(identifiers.schemas.unknown).call(); 41 41 }
+1 -1
packages/openapi-ts/src/plugins/valibot/v1/toAst/intersection.ts
··· 12 12 const { applyModifiers, childResults, plugin, symbols } = ctx; 13 13 const { v } = symbols; 14 14 15 - if (childResults.length === 0) { 15 + if (!childResults.length) { 16 16 return $(v).attr(identifiers.schemas.any).call(); 17 17 } 18 18
+1 -1
packages/openapi-ts/src/plugins/valibot/v1/toAst/union.ts
··· 20 20 } 21 21 }); 22 22 23 - if (nonNullItems.length === 0) { 23 + if (!nonNullItems.length) { 24 24 return $(v).attr(identifiers.schemas.null).call(); 25 25 } 26 26
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/enum.ts
··· 51 51 const { z } = symbols; 52 52 const { allStrings, enumMembers, literalMembers } = ctx.nodes.items(ctx); 53 53 54 - if (allStrings && enumMembers.length > 0) { 54 + if (allStrings && enumMembers.length) { 55 55 return $(z) 56 56 .attr(identifiers.enum) 57 57 .call($.array(...enumMembers));
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/number.ts
··· 92 92 const maxNode = ctx.nodes.max(ctx); 93 93 if (maxNode) checks.push(maxNode); 94 94 95 - if (checks.length > 0) { 95 + if (checks.length) { 96 96 ctx.chain.current = ctx.chain.current.attr(identifiers.check).call(...checks); 97 97 } 98 98
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/object.ts
··· 29 29 30 30 if ( 31 31 !schema.additionalProperties || 32 - (schema.properties && Object.keys(schema.properties).length > 0) 32 + (schema.properties && Object.keys(schema.properties).length) 33 33 ) { 34 34 return; 35 35 }
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/string.ts
··· 111 111 const patternNode = ctx.nodes.pattern(ctx); 112 112 if (patternNode) checks.push(patternNode); 113 113 114 - if (checks.length > 0) { 114 + if (checks.length) { 115 115 ctx.chain.current = ctx.chain.current.attr(identifiers.check).call(...checks); 116 116 } 117 117
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/tuple.ts
··· 17 17 18 18 const tupleFn = $(z).attr(identifiers.tuple); 19 19 20 - if (childResults.length === 0) { 20 + if (!childResults.length) { 21 21 return tupleFn.call($.array()); 22 22 } 23 23
+1 -1
packages/openapi-ts/src/plugins/zod/mini/walker.ts
··· 329 329 }); 330 330 331 331 let expression: Chain; 332 - if (nonNullItems.length === 0) { 332 + if (!nonNullItems.length) { 333 333 expression = $(z).attr(identifiers.null).call(); 334 334 } else if (nonNullItems.length === 1) { 335 335 expression = nonNullItems[0]!.expression;
+1 -1
packages/openapi-ts/src/plugins/zod/v3/toAst/enum.ts
··· 50 50 const { z } = symbols; 51 51 const { allStrings, enumMembers, literalMembers } = ctx.nodes.items(ctx); 52 52 53 - if (allStrings && enumMembers.length > 0) { 53 + if (allStrings && enumMembers.length) { 54 54 return $(z) 55 55 .attr(identifiers.enum) 56 56 .call($.array(...enumMembers));
+1 -1
packages/openapi-ts/src/plugins/zod/v3/toAst/object.ts
··· 25 25 26 26 if ( 27 27 !schema.additionalProperties || 28 - (schema.properties && Object.keys(schema.properties).length > 0) 28 + (schema.properties && Object.keys(schema.properties).length) 29 29 ) { 30 30 return; 31 31 }
+1 -1
packages/openapi-ts/src/plugins/zod/v3/toAst/tuple.ts
··· 17 17 18 18 const tupleFn = $(z).attr(identifiers.tuple); 19 19 20 - if (childResults.length === 0) { 20 + if (!childResults.length) { 21 21 return tupleFn.call($.array()); 22 22 } 23 23
+1 -1
packages/openapi-ts/src/plugins/zod/v3/walker.ts
··· 326 326 }); 327 327 328 328 let expression: Chain; 329 - if (nonNullItems.length === 0) { 329 + if (!nonNullItems.length) { 330 330 expression = $(z).attr(identifiers.null).call(); 331 331 } else if (nonNullItems.length === 1) { 332 332 expression = nonNullItems[0]!.expression;
+1 -1
packages/openapi-ts/src/plugins/zod/v4/toAst/enum.ts
··· 51 51 const { z } = symbols; 52 52 const { allStrings, enumMembers, literalMembers } = ctx.nodes.items(ctx); 53 53 54 - if (allStrings && enumMembers.length > 0) { 54 + if (allStrings && enumMembers.length) { 55 55 return $(z) 56 56 .attr(identifiers.enum) 57 57 .call($.array(...enumMembers));
+1 -1
packages/openapi-ts/src/plugins/zod/v4/toAst/intersection.ts
··· 18 18 const { childResults, symbols } = ctx; 19 19 const { z } = symbols; 20 20 21 - if (childResults.length === 0) { 21 + if (!childResults.length) { 22 22 return $(z).attr(identifiers.never).call(); 23 23 } 24 24
+1 -1
packages/openapi-ts/src/plugins/zod/v4/toAst/object.ts
··· 29 29 30 30 if ( 31 31 !schema.additionalProperties || 32 - (schema.properties && Object.keys(schema.properties).length > 0) 32 + (schema.properties && Object.keys(schema.properties).length) 33 33 ) { 34 34 return; 35 35 }
+1 -1
packages/openapi-ts/src/plugins/zod/v4/toAst/tuple.ts
··· 17 17 18 18 const tupleFn = $(z).attr(identifiers.tuple); 19 19 20 - if (childResults.length === 0) { 20 + if (!childResults.length) { 21 21 return tupleFn.call($.array()); 22 22 } 23 23
+2 -2
packages/openapi-ts/src/plugins/zod/v4/toAst/union.ts
··· 15 15 const { childResults, schemas, symbols } = ctx; 16 16 const { z } = symbols; 17 17 18 - if (childResults.length === 0) { 18 + if (!childResults.length) { 19 19 return $(z).attr(identifiers.null).call(); 20 20 } 21 21 ··· 28 28 }); 29 29 30 30 let expression: Chain; 31 - if (nonNullItems.length === 0) { 31 + if (!nonNullItems.length) { 32 32 expression = $(z).attr(identifiers.null).call(); 33 33 } else if (nonNullItems.length === 1) { 34 34 expression = nonNullItems[0]!.expression;
+1 -1
packages/openapi-ts/src/plugins/zod/v4/walker.ts
··· 338 338 }); 339 339 340 340 let expression: Chain; 341 - if (nonNullItems.length === 0) { 341 + if (!nonNullItems.length) { 342 342 expression = $(z).attr(identifiers.null).call(); 343 343 } else if (nonNullItems.length === 1) { 344 344 expression = nonNullItems[0]!.expression;
+1 -1
packages/openapi-ts/src/ts-dsl/decl/class.ts
··· 51 51 52 52 /** Returns true if the class has any members. */ 53 53 get hasBody(): boolean { 54 - return this.body.length > 0; 54 + return Boolean(this.body.length); 55 55 } 56 56 57 57 /** Adds one or more class members (fields, methods, etc.). */
+2 -2
packages/openapi-ts/src/ts-dsl/decl/func.ts
··· 85 85 86 86 /** Returns true when all required builder calls are present. */ 87 87 get isValid(): boolean { 88 - return this.missingRequiredCalls().length === 0; 88 + return !this.missingRequiredCalls().length; 89 89 } 90 90 91 91 /** Switches the function to an arrow function form. */ ··· 158 158 159 159 $validate(): asserts this { 160 160 const missing = this.missingRequiredCalls(); 161 - if (missing.length === 0) return; 161 + if (!missing.length) return; 162 162 throw new Error(`Function ${this.mode} missing ${missing.join(' and ')}`); 163 163 } 164 164
+2 -2
packages/openapi-ts/src/ts-dsl/decl/param.ts
··· 41 41 42 42 /** Returns true when all required builder calls are present. */ 43 43 get isValid(): boolean { 44 - return this.missingRequiredCalls().length === 0; 44 + return !this.missingRequiredCalls().length; 45 45 } 46 46 47 47 /** Sets the parameter type. */ ··· 64 64 65 65 $validate(): asserts this { 66 66 const missing = this.missingRequiredCalls(); 67 - if (missing.length === 0) return; 67 + if (!missing.length) return; 68 68 throw new Error(`Parameter missing ${missing.join(' and ')}`); 69 69 } 70 70
+2 -2
packages/openapi-ts/src/ts-dsl/decl/pattern.ts
··· 25 25 26 26 /** Returns true when all required builder calls are present. */ 27 27 get isValid(): boolean { 28 - return this.missingRequiredCalls().length === 0; 28 + return !this.missingRequiredCalls().length; 29 29 } 30 30 31 31 /** Defines an array pattern (e.g., `[a, b, c]`). */ ··· 85 85 | { kind: 'object'; values: Record<string, string> }; 86 86 } { 87 87 const missing = this.missingRequiredCalls(); 88 - if (missing.length === 0) return; 88 + if (!missing.length) return; 89 89 throw new Error(`Binding pattern missing ${missing.join(' and ')}`); 90 90 } 91 91
+2 -2
packages/openapi-ts/src/ts-dsl/expr/binary.ts
··· 52 52 53 53 /** Returns true when all required builder calls are present. */ 54 54 get isValid(): boolean { 55 - return this.missingRequiredCalls().length === 0; 55 + return !this.missingRequiredCalls().length; 56 56 } 57 57 58 58 /** Logical AND — `this && expr` */ ··· 152 152 _op: Op; 153 153 } { 154 154 const missing = this.missingRequiredCalls(); 155 - if (missing.length === 0) return; 155 + if (!missing.length) return; 156 156 throw new Error(`Binary expression missing ${missing.join(' and ')}`); 157 157 } 158 158
+2 -2
packages/openapi-ts/src/ts-dsl/expr/postfix.ts
··· 28 28 29 29 /** Returns true when all required builder calls are present. */ 30 30 get isValid(): boolean { 31 - return this.missingRequiredCalls().length === 0; 31 + return !this.missingRequiredCalls().length; 32 32 } 33 33 34 34 /** Sets the operator to MinusMinusToken for decrement (`--`). */ ··· 65 65 _op: PostfixOp; 66 66 } { 67 67 const missing = this.missingRequiredCalls(); 68 - if (missing.length === 0) return; 68 + if (!missing.length) return; 69 69 throw new Error(`Postfix unary expression missing ${missing.join(' and ')}`); 70 70 } 71 71
+2 -2
packages/openapi-ts/src/ts-dsl/expr/prefix.ts
··· 28 28 29 29 /** Returns true when all required builder calls are present. */ 30 30 get isValid(): boolean { 31 - return this.missingRequiredCalls().length === 0; 31 + return !this.missingRequiredCalls().length; 32 32 } 33 33 34 34 /** Sets the operand (the expression being prefixed). */ ··· 65 65 _op: PrefixOp; 66 66 } { 67 67 const missing = this.missingRequiredCalls(); 68 - if (missing.length === 0) return; 68 + if (!missing.length) return; 69 69 throw new Error(`Prefix unary expression missing ${missing.join(' and ')}`); 70 70 } 71 71
+2 -2
packages/openapi-ts/src/ts-dsl/expr/prop.ts
··· 49 49 } 50 50 51 51 get isValid(): boolean { 52 - return this.missingRequiredCalls().length === 0; 52 + return !this.missingRequiredCalls().length; 53 53 } 54 54 55 55 value(value: Expr | Stmt | ((p: ObjectPropTsDsl) => void)) { ··· 104 104 kind: ObjectPropKind; 105 105 } { 106 106 const missing = this.missingRequiredCalls(); 107 - if (missing.length === 0) return; 107 + if (!missing.length) return; 108 108 throw new Error( 109 109 `Object property${this._meta.name ? ` "${this._meta.name}"` : ''} missing ${missing.join(' and ')}`, 110 110 );
+2 -2
packages/openapi-ts/src/ts-dsl/expr/template.ts
··· 57 57 } 58 58 } 59 59 60 - if (normalized.length === 0 || typeof normalized[0] !== 'string') { 60 + if (!normalized.length || typeof normalized[0] !== 'string') { 61 61 normalized.unshift(''); 62 62 } 63 63 ··· 81 81 while (normalized.length) { 82 82 const expr = normalized.shift() as ts.Expression; 83 83 const next = typeof normalized[0] === 'string' ? (normalized.shift() as string) : ''; 84 - const isLast = normalized.length === 0; 84 + const isLast = !normalized.length; 85 85 spans.push( 86 86 ts.factory.createTemplateSpan( 87 87 expr,
+2 -2
packages/openapi-ts/src/ts-dsl/expr/ternary.ts
··· 27 27 28 28 /** Returns true when all required builder calls are present. */ 29 29 get isValid(): boolean { 30 - return this.missingRequiredCalls().length === 0; 30 + return !this.missingRequiredCalls().length; 31 31 } 32 32 33 33 condition(condition: string | MaybeTsDsl<ts.Expression>) { ··· 62 62 _then: string | MaybeTsDsl<ts.Expression>; 63 63 } { 64 64 const missing = this.missingRequiredCalls(); 65 - if (missing.length === 0) return; 65 + if (!missing.length) return; 66 66 throw new Error(`Ternary expression missing ${missing.join(' and ')}`); 67 67 } 68 68
+12 -12
packages/openapi-ts/src/ts-dsl/mixins/modifiers.ts
··· 111 111 112 112 abstract class Abstract extends Mixed { 113 113 protected abstract(condition?: boolean): this { 114 - const cond = arguments.length === 0 ? true : Boolean(condition); 114 + const cond = !arguments.length ? true : Boolean(condition); 115 115 return this._m('abstract', cond); 116 116 } 117 117 } ··· 137 137 138 138 abstract class Async extends Mixed { 139 139 protected async(condition?: boolean): this { 140 - const cond = arguments.length === 0 ? true : Boolean(condition); 140 + const cond = !arguments.length ? true : Boolean(condition); 141 141 return this._m('async', cond); 142 142 } 143 143 } ··· 163 163 164 164 abstract class Const extends Mixed { 165 165 protected const(condition?: boolean): this { 166 - const cond = arguments.length === 0 ? true : Boolean(condition); 166 + const cond = !arguments.length ? true : Boolean(condition); 167 167 return this._m('const', cond); 168 168 } 169 169 } ··· 189 189 190 190 abstract class Declare extends Mixed { 191 191 protected declare(condition?: boolean): this { 192 - const cond = arguments.length === 0 ? true : Boolean(condition); 192 + const cond = !arguments.length ? true : Boolean(condition); 193 193 return this._m('declare', cond); 194 194 } 195 195 } ··· 221 221 * @returns The target object for chaining. 222 222 */ 223 223 protected default(condition?: boolean): this { 224 - const cond = arguments.length === 0 ? true : Boolean(condition); 224 + const cond = !arguments.length ? true : Boolean(condition); 225 225 return this._m('default', cond); 226 226 } 227 227 } ··· 253 253 * @returns The target object for chaining. 254 254 */ 255 255 protected export(condition?: boolean): this { 256 - const cond = arguments.length === 0 ? true : Boolean(condition); 256 + const cond = !arguments.length ? true : Boolean(condition); 257 257 this.exported = cond; 258 258 // TODO: remove this side-effect once planner handles exported flag 259 259 if (this.symbol) this.symbol.setExported(cond); ··· 282 282 283 283 abstract class Override extends Mixed { 284 284 protected override(condition?: boolean): this { 285 - const cond = arguments.length === 0 ? true : Boolean(condition); 285 + const cond = !arguments.length ? true : Boolean(condition); 286 286 return this._m('override', cond); 287 287 } 288 288 } ··· 308 308 309 309 abstract class Private extends Mixed { 310 310 protected private(condition?: boolean): this { 311 - const cond = arguments.length === 0 ? true : Boolean(condition); 311 + const cond = !arguments.length ? true : Boolean(condition); 312 312 return this._m('private', cond); 313 313 } 314 314 } ··· 334 334 335 335 abstract class Protected extends Mixed { 336 336 protected protected(condition?: boolean): this { 337 - const cond = arguments.length === 0 ? true : Boolean(condition); 337 + const cond = !arguments.length ? true : Boolean(condition); 338 338 return this._m('protected', cond); 339 339 } 340 340 } ··· 360 360 361 361 abstract class Public extends Mixed { 362 362 protected public(condition?: boolean): this { 363 - const cond = arguments.length === 0 ? true : Boolean(condition); 363 + const cond = !arguments.length ? true : Boolean(condition); 364 364 return this._m('public', cond); 365 365 } 366 366 } ··· 386 386 387 387 abstract class Readonly extends Mixed { 388 388 protected readonly(condition?: boolean): this { 389 - const cond = arguments.length === 0 ? true : Boolean(condition); 389 + const cond = !arguments.length ? true : Boolean(condition); 390 390 return this._m('readonly', cond); 391 391 } 392 392 } ··· 412 412 413 413 abstract class Static extends Mixed { 414 414 protected static(condition?: boolean): this { 415 - const cond = arguments.length === 0 ? true : Boolean(condition); 415 + const cond = !arguments.length ? true : Boolean(condition); 416 416 return this._m('static', cond); 417 417 } 418 418 }
+2 -2
packages/openapi-ts/src/ts-dsl/mixins/optional.ts
··· 20 20 } 21 21 22 22 protected optional(condition?: boolean): this { 23 - this._optional = arguments.length === 0 ? true : Boolean(condition); 23 + this._optional = !arguments.length ? true : Boolean(condition); 24 24 return this; 25 25 } 26 26 27 27 protected required(condition?: boolean): this { 28 - this._optional = arguments.length === 0 ? false : !condition; 28 + this._optional = !arguments.length ? false : !condition; 29 29 return this; 30 30 } 31 31 }
+2 -2
packages/openapi-ts/src/ts-dsl/stmt/for.ts
··· 53 53 54 54 /** Returns true when all required builder calls are present. */ 55 55 get isValid(): boolean { 56 - return this.missingRequiredCalls().length === 0; 56 + return !this.missingRequiredCalls().length; 57 57 } 58 58 59 59 /** Enables async iteration (`for await...of`). Can only be called on for...of. */ ··· 147 147 _variableOrInit: VarTsDsl; 148 148 } { 149 149 const missing = this.missingRequiredCalls(); 150 - if (missing.length === 0) return; 150 + if (!missing.length) return; 151 151 throw new Error( 152 152 `For${this._mode === 'for' ? '' : `...${this._mode}`} statement missing ${missing.join(' and ')}`, 153 153 );
+3 -3
packages/openapi-ts/src/ts-dsl/stmt/if.ts
··· 39 39 40 40 /** Returns true when all required builder calls are present. */ 41 41 get isValid(): boolean { 42 - return this.missingRequiredCalls().length === 0; 42 + return !this.missingRequiredCalls().length; 43 43 } 44 44 45 45 condition(condition: IfCondition): this { ··· 65 65 _condition: IfCondition; 66 66 } { 67 67 const missing = this.missingRequiredCalls(); 68 - if (missing.length === 0) return; 68 + if (!missing.length) return; 69 69 throw new Error(`If statement missing ${missing.join(' and ')}`); 70 70 } 71 71 72 72 private missingRequiredCalls(): ReadonlyArray<string> { 73 73 const missing: Array<string> = []; 74 74 if (!this._condition) missing.push('.condition()'); 75 - if (this._do.length === 0) missing.push('.do()'); 75 + if (!this._do.length) missing.push('.do()'); 76 76 return missing; 77 77 } 78 78 }
+3 -3
packages/openapi-ts/src/ts-dsl/stmt/try.ts
··· 56 56 57 57 /** Returns true when all required builder calls are present. */ 58 58 get isValid(): boolean { 59 - return this.missingRequiredCalls().length === 0; 59 + return !this.missingRequiredCalls().length; 60 60 } 61 61 62 62 catch(...items: Array<DoExpr>): this { ··· 97 97 _try: Array<DoExpr>; 98 98 } { 99 99 const missing = this.missingRequiredCalls(); 100 - if (missing.length === 0) return; 100 + if (!missing.length) return; 101 101 throw new Error(`Try statement missing ${missing.join(' and ')}`); 102 102 } 103 103 104 104 private missingRequiredCalls(): ReadonlyArray<string> { 105 105 const missing: Array<string> = []; 106 - if (!this._try || this._try.length === 0) missing.push('.try()'); 106 + if (!this._try || !this._try.length) missing.push('.try()'); 107 107 return missing; 108 108 } 109 109 }
+2 -2
packages/openapi-ts/src/ts-dsl/stmt/var.ts
··· 38 38 39 39 /** Returns true when all required builder calls are present. */ 40 40 get isValid(): boolean { 41 - return this.missingRequiredCalls().length === 0; 41 + return !this.missingRequiredCalls().length; 42 42 } 43 43 44 44 const(): this { ··· 83 83 84 84 $validate(): asserts this { 85 85 const missing = this.missingRequiredCalls(); 86 - if (missing.length === 0) return; 86 + if (!missing.length) return; 87 87 throw new Error(`Variable declaration missing ${missing.join(' and ')}`); 88 88 } 89 89
+2 -2
packages/openapi-ts/src/ts-dsl/token.ts
··· 55 55 _kind: K; 56 56 } { 57 57 const missing = this.missingRequiredCalls(); 58 - if (missing.length === 0) return; 58 + if (!missing.length) return; 59 59 throw new Error(`Token missing ${missing.join(' and ')}`); 60 60 } 61 61 ··· 67 67 68 68 /** Returns true when all required builder calls are present. */ 69 69 get isValid(): boolean { 70 - return this.missingRequiredCalls().length === 0; 70 + return !this.missingRequiredCalls().length; 71 71 } 72 72 }
+2 -2
packages/openapi-ts/src/ts-dsl/type/alias.ts
··· 37 37 38 38 /** Returns true when all required builder calls are present. */ 39 39 get isValid(): boolean { 40 - return this.missingRequiredCalls().length === 0; 40 + return !this.missingRequiredCalls().length; 41 41 } 42 42 43 43 /** Sets the type expression on the right-hand side of `= ...`. */ ··· 61 61 value: Value; 62 62 } { 63 63 const missing = this.missingRequiredCalls(); 64 - if (missing.length === 0) return; 64 + if (!missing.length) return; 65 65 const name = this.name.toString(); 66 66 throw new Error(`Type alias${name ? ` "${name}"` : ''} missing ${missing.join(' and ')}`); 67 67 }
+2 -2
packages/openapi-ts/src/ts-dsl/type/attr.ts
··· 39 39 40 40 /** Returns true when all required builder calls are present. */ 41 41 get isValid(): boolean { 42 - return this.missingRequiredCalls().length === 0; 42 + return !this.missingRequiredCalls().length; 43 43 } 44 44 45 45 base(base?: Base | Ref<Base>): this { ··· 70 70 _right: Ref<Right>; 71 71 } { 72 72 const missing = this.missingRequiredCalls(); 73 - if (missing.length === 0) return; 73 + if (!missing.length) return; 74 74 throw new Error(`Type attribute missing ${missing.join(' and ')}`); 75 75 } 76 76
+2 -2
packages/openapi-ts/src/ts-dsl/type/expr.ts
··· 41 41 42 42 /** Returns true when all required builder calls are present. */ 43 43 get isValid(): boolean { 44 - return this.missingRequiredCalls().length === 0; 44 + return !this.missingRequiredCalls().length; 45 45 } 46 46 47 47 /** Accesses a nested type (e.g., `Foo.Bar`). */ ··· 64 64 _exprInput: Ref<TypeExprExpr>; 65 65 } { 66 66 const missing = this.missingRequiredCalls(); 67 - if (missing.length === 0) return; 67 + if (!missing.length) return; 68 68 throw new Error(`Type expression missing ${missing.join(' and ')}`); 69 69 } 70 70
+2 -2
packages/openapi-ts/src/ts-dsl/type/func.ts
··· 19 19 20 20 /** Returns true when all required builder calls are present. */ 21 21 get isValid(): boolean { 22 - return this.missingRequiredCalls().length === 0; 22 + return !this.missingRequiredCalls().length; 23 23 } 24 24 25 25 override toAst() { ··· 34 34 35 35 $validate(): asserts this { 36 36 const missing = this.missingRequiredCalls(); 37 - if (missing.length === 0) return; 37 + if (!missing.length) return; 38 38 throw new Error(`Function type missing ${missing.join(' and ')}`); 39 39 } 40 40
+2 -2
packages/openapi-ts/src/ts-dsl/type/idx-sig.ts
··· 42 42 43 43 /** Returns true when all required builder calls are present. */ 44 44 get isValid(): boolean { 45 - return this.missingRequiredCalls().length === 0; 45 + return !this.missingRequiredCalls().length; 46 46 } 47 47 48 48 /** Sets the key type: `[name: T]` */ ··· 80 80 _type: TypeIdxSigType; 81 81 } { 82 82 const missing = this.missingRequiredCalls(); 83 - if (missing.length === 0) return; 83 + if (!missing.length) return; 84 84 const name = this.name.toString(); 85 85 throw new Error(`Index signature${name ? ` "${name}"` : ''} missing ${missing.join(' and ')}`); 86 86 }
+2 -2
packages/openapi-ts/src/ts-dsl/type/idx.ts
··· 33 33 34 34 /** Returns true when all required builder calls are present. */ 35 35 get isValid(): boolean { 36 - return this.missingRequiredCalls().length === 0; 36 + return !this.missingRequiredCalls().length; 37 37 } 38 38 39 39 base(base: Base): this { ··· 56 56 _index: Index; 57 57 } { 58 58 const missing = this.missingRequiredCalls(); 59 - if (missing.length === 0) return; 59 + if (!missing.length) return; 60 60 throw new Error(`Indexed access type missing ${missing.join(' and ')}`); 61 61 } 62 62
+2 -2
packages/openapi-ts/src/ts-dsl/type/mapped.ts
··· 35 35 36 36 /** Returns true when all required builder calls are present. */ 37 37 get isValid(): boolean { 38 - return this.missingRequiredCalls().length === 0; 38 + return !this.missingRequiredCalls().length; 39 39 } 40 40 41 41 /** Sets the key constraint: `[K in Constraint]` */ ··· 96 96 _type: string | MaybeTsDsl<ts.TypeNode>; 97 97 } { 98 98 const missing = this.missingRequiredCalls(); 99 - if (missing.length === 0) return; 99 + if (!missing.length) return; 100 100 const name = this.name.toString(); 101 101 throw new Error(`Mapped type${name ? ` "${name}"` : ''} missing ${missing.join(' and ')}`); 102 102 }
+1 -1
packages/openapi-ts/src/ts-dsl/type/operator.ts
··· 79 79 _type: Type; 80 80 } { 81 81 const missing = this.missingRequiredCalls(); 82 - if (missing.length === 0) return; 82 + if (!missing.length) return; 83 83 throw new Error(`Type operator missing ${missing.join(' and ')}`); 84 84 } 85 85
+2 -2
packages/openapi-ts/src/ts-dsl/type/prop.ts
··· 44 44 45 45 /** Returns true when all required builder calls are present. */ 46 46 get isValid(): boolean { 47 - return this.missingRequiredCalls().length === 0; 47 + return !this.missingRequiredCalls().length; 48 48 } 49 49 50 50 /** Sets the property type. */ ··· 69 69 _type: Ref<TypePropType>; 70 70 } { 71 71 const missing = this.missingRequiredCalls(); 72 - if (missing.length === 0) return; 72 + if (!missing.length) return; 73 73 const name = this.name.toString(); 74 74 throw new Error(`Type property${name ? ` "${name}"` : ''} missing ${missing.join(' and ')}`); 75 75 }
+2 -2
packages/openapi-ts/src/ts-dsl/type/template.ts
··· 49 49 } 50 50 } 51 51 52 - if (normalized.length === 0 || typeof normalized[0] !== 'string') { 52 + if (!normalized.length || typeof normalized[0] !== 'string') { 53 53 normalized.unshift(''); 54 54 } 55 55 ··· 73 73 while (normalized.length) { 74 74 const type = normalized.shift() as ts.TypeNode; 75 75 const next = typeof normalized[0] === 'string' ? (normalized.shift() as string) : ''; 76 - const isLast = normalized.length === 0; 76 + const isLast = !normalized.length; 77 77 spans.push( 78 78 ts.factory.createTemplateLiteralTypeSpan( 79 79 type,
+2 -2
packages/openapi-ts/src/ts-dsl/utils/context.ts
··· 59 59 function getAccessChainForNode(node: TsDsl): NodeChain { 60 60 const structuralChain = [...getStructuralChainForNode(node, new Set())]; 61 61 const accessChain = structuralToAccessChain(structuralChain); 62 - if (accessChain.length === 0) { 62 + if (!accessChain.length) { 63 63 // I _think_ this should not happen, but it does and this fix works for now. 64 64 // I assume this will cause issues with imports in some cases, investigate 65 65 // when it actually happens. ··· 83 83 if (getScope(parent) !== getScope(node)) continue; 84 84 85 85 const chain = getStructuralChainForNode(parent, visited); 86 - if (chain.length > 0) return [...chain, node]; 86 + if (chain.length) return [...chain, node]; 87 87 } 88 88 } 89 89
+1 -1
packages/openapi-ts/src/ts-dsl/utils/render.ts
··· 163 163 group.kind === 'default' ? $.id(group.localName ?? '').toAst() : undefined, 164 164 group.kind === 'namespace' 165 165 ? ts.factory.createNamespaceImport($.id(group.localName ?? '').toAst()) 166 - : specifiers.length > 0 166 + : specifiers.length 167 167 ? ts.factory.createNamedImports(specifiers) 168 168 : undefined, 169 169 );
+2 -2
packages/shared/src/graph/walk.ts
··· 10 10 const walkDeclarations: WalkFn = (graph, callback, options) => { 11 11 const pointers = Array.from(graph.nodes.keys()); 12 12 13 - if (options?.preferGroups && options.preferGroups.length > 0) { 13 + if (options?.preferGroups && options.preferGroups.length) { 14 14 // emit nodes that match each preferred group in order, preserving insertion order 15 15 const emitted = new Set<string>(); 16 16 if (options.matchPointerToGroup) { ··· 137 137 138 138 // prefer specified groups when safe 139 139 let finalOrder = order; 140 - if (options?.preferGroups && options.preferGroups.length > 0) { 140 + if (options?.preferGroups && options.preferGroups.length) { 141 141 // build group priority map (lower = earlier) 142 142 const groupPriority = new Map<string, number>(); 143 143 for (let i = 0; i < options.preferGroups.length; i++) {
+2 -2
packages/shared/src/openApi/3.0.x/parser/schema.ts
··· 518 518 oneOf ? () => oneOf.some((o) => '$ref' in o && o.$ref === state.$ref) : undefined, 519 519 ); 520 520 521 - if (values.length === 0) { 521 + if (!values.length) { 522 522 continue; 523 523 } 524 524 ··· 574 574 }); 575 575 576 576 // Use allValues if we found children, otherwise use the original values 577 - const finalValues = allValues.length > 0 ? allValues : values; 577 + const finalValues = allValues.length ? allValues : values; 578 578 579 579 // Detect the actual type of the discriminator property 580 580 const propertyType = findDiscriminatorPropertyType({
+2 -2
packages/shared/src/openApi/3.1.x/parser/schema.ts
··· 613 613 oneOf ? () => oneOf.some((o) => '$ref' in o && o.$ref === state.$ref) : undefined, 614 614 ); 615 615 616 - if (values.length === 0) { 616 + if (!values.length) { 617 617 continue; 618 618 } 619 619 ··· 670 670 }); 671 671 672 672 // Use allValues if we found children, otherwise use the original values 673 - const finalValues = allValues.length > 0 ? allValues : values; 673 + const finalValues = allValues.length ? allValues : values; 674 674 675 675 // Detect the actual type of the discriminator property 676 676 const propertyType = findDiscriminatorPropertyType({
+2 -2
packages/shared/src/openApi/shared/locations/operation.ts
··· 49 49 path?: OperationPathStrategy; 50 50 }): OperationStructureStrategy => 51 51 (operation) => { 52 - const tags = operation.tags && operation.tags.length > 0 ? operation.tags : [config.fallback]; 52 + const tags = operation.tags && operation.tags.length ? operation.tags : [config.fallback]; 53 53 const path = config.path ?? OperationPath.id(); 54 54 const pathSegments = path(operation); 55 55 return tags.map((tag) => [tag, ...pathSegments]); ··· 142 142 if (!operation.operationId) return fallback(operation); 143 143 const delimiters = config?.delimiters ?? /[./]/; 144 144 const segments = operation.operationId.split(delimiters).filter(Boolean); 145 - return segments.length === 0 ? fallback(operation) : segments; 145 + return !segments.length ? fallback(operation) : segments; 146 146 }, 147 147 148 148 /**
+1 -1
packages/shared/src/openApi/shared/transforms/propertiesRequiredByDefault.ts
··· 82 82 !('required' in nodeInfo.node) 83 83 ) { 84 84 const propKeys = Object.keys(nodeInfo.node.properties as Record<string, unknown>); 85 - if (propKeys.length > 0) { 85 + if (propKeys.length) { 86 86 (nodeInfo.node as Record<string, unknown>).required = propKeys; 87 87 } 88 88 }
+1 -1
packages/shared/src/openApi/shared/transforms/schemas.ts
··· 73 73 schemasObj[newName] = schema; 74 74 } 75 75 76 - if (Object.keys(renameMap).length > 0) { 76 + if (Object.keys(renameMap).length) { 77 77 rewriteRefs(spec, renameMap); 78 78 } 79 79 };