Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix(orval) improve @orval/orval code quality#2936

Merged
melloware merged 12 commits intoorval-labs:masterfrom
ScriptType:fix(orval)-linting
Feb 10, 2026
Merged

Fix(orval) improve @orval/orval code quality#2936
melloware merged 12 commits intoorval-labs:masterfrom
ScriptType:fix(orval)-linting

Conversation

@ScriptType
Copy link
Contributor

#closes #2555

Resolves all 185 ESLint violations (147 errors, 38 warnings) in packages/orval/ and adds the package to CI lint enforcement.

What changed

  • Auto-fixes: prefer-nullish-coalescing, @typescript-eslint/prefer-optional-chain, etc.
  • Unnecessary conditions: Removed dead branches and redundant optional chains where types already guarantee presence
  • Unsafe any operations: Replaced any with proper OpenAPI types from @orval/core (Record<string, unknown> for QueryOptions.options/requestOptions, typed OpenApiSchemaObject/OpenApiParameterObject in spec handling)
  • Remaining warnings: Removed unused vars, converted Array.reduce to for...of loops, removed unnecessary async from test mocks
  • CI: Added yarn workspace orval lint to .github/workflows/tests.yaml, removed --filter=!orval from root turbo lint

Approach

  • Type narrowing (type guards, typeof, in checks) over type assertions
  • No eslint-disable comments added
  • No behavioral changes — all existing tests pass, generated samples unchanged

- Run eslint --fix: 44 auto-fixable violations resolved (import sort,
  no-useless-undefined, no-negated-condition, prefer-string-raw,
  prefer-string-replace-all)
- Convert 9 prefer-nullish-coalescing violations from || to ??
  (options.ts: 8 locations, tsconfig.ts: 1 location)
- All conversions verified safe by type analysis
…-zod-specs.ts

- Replace isObject() ternaries with direct .body access (4 locations)
- Remove unused isObject import
- Replace queryOptions?. with queryOptions. (6 fixes)
- Replace zod?. with zod. in truthy ternary (3 fixes)
- Fix override?.formUrlEncoded in isBoolean branch
- Fix override?.header! in isFunction branch
- Remove dead ?? false from mutator.default expression
…specs, api, client

- write-specs.ts: replace exhaustive else-if with else for zod schema type
- write-specs.ts: remove always-truthy guard on verbOptions
- api.ts: remove always-truthy guard on props (GetterProp[])
- client.ts: remove unreachable !generator guard
…types.ts

- NormalizedQueryOptions.options: any -> Record<string, unknown>
- QueryOptions.options: any -> Record<string, unknown>
- NormalizedOverrideOutput.requestOptions: Record<string, any> -> Record<string, unknown>
- OverrideOutput.requestOptions: Record<string, any> -> Record<string, unknown>
…te-specs

- tsconfig.ts: assert tsconfck returns as Tsconfig (3 unsafe-return/assignment)
- request.ts: type chunk as Buffer, assert JSON.parse as T, reject with Error (5 violations)
- client.ts: replace any with string[], Function with ClientMockBuilder (2 violations)
- write-specs.ts: null->undefined, remove useless default, remove useless switch case (3 violations)
- Change isPackageJson parameter from any to unknown
- Replace Record<string, any> with Record<string, unknown> for yaml.load
- Type fs.readJson return as Record<string, unknown>
- Add CatalogData assertions on return values
- Remove unnecessary optional chain on non-nullish pkg
- Replace 10 'as any' casts on fs.readFile mock values with Buffer.from()
- Eliminates 10 no-explicit-any and 10 no-unsafe-argument violations
- Only deferred require-await violations remain in test file
…compliance

- Change dereferenceExternalRef signature from object to Record<string, unknown>
- Assert x-ext extensions as Record<string, unknown> for typed access
- Replace .sort() with .toSorted() in write-zod-specs index generation
- Add OpenAPI bridge assertions for requestBody and parameters in write-zod-specs
- Use type guard filters for query/header params with OpenApiParameterObject
- Remove unused SchemaGenerationType import from options.ts
…liance

- Cast test results to inline types matching expected structure
- Use Record<string, unknown> for schema access patterns
- Add local type aliases for deeply nested path/response assertions
- Zero any-related violations remaining in import-specs.test.ts
- Remove async from 20 mockImplementation callbacks (require-await)
- Remove unused imports destructure in api.ts (no-unused-vars)
- Convert reduce to for..of loop in api.ts (no-array-reduce)
- Convert reduce to for..of loop in options.ts (no-array-reduce)
- Add yarn workspace orval lint to .github/workflows/tests.yaml lint step
- Remove --filter=!orval from root package.json turbo lint command
@melloware
Copy link
Collaborator

cc @snebjorn !

@ScriptType ScriptType marked this pull request as ready for review February 10, 2026 13:30
@melloware melloware merged commit d8b0706 into orval-labs:master Feb 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve @orval/orval code quality

2 participants

Comments