Skip to content

Commit f063567

Browse files
committed
Fix the remaining lint issues
1 parent 9010337 commit f063567

File tree

16 files changed

+78
-62
lines changed

16 files changed

+78
-62
lines changed

docs/virtual/matchers/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import {
2-
createAsyncThunk,
3-
createReducer,
4-
PayloadAction,
5-
} from '@reduxjs/toolkit'
1+
import type { PayloadAction } from '@reduxjs/toolkit'
2+
import { createAsyncThunk, createReducer } from '@reduxjs/toolkit'
63

74
export interface Data {
85
isInteresting: boolean

docs/virtual/petstore-api.generated/petstore-api.generated.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export const api = createApi({
123123
}),
124124
}),
125125
})
126+
type AnyNonNullishValue = NonNullable<unknown>
126127
export type UpdatePetApiResponse = /** status 200 Successful operation */ Pet
127128
export type UpdatePetApiArg = {
128129
/** Update an existent pet in the store */
@@ -174,10 +175,9 @@ export type UploadFileApiArg = {
174175
additionalMetadata?: string
175176
body: string
176177
}
177-
export type GetInventoryApiResponse = /** status 200 successful operation */ {
178-
[key: string]: number
179-
}
180-
export type GetInventoryApiArg = {}
178+
export type GetInventoryApiResponse =
179+
/** status 200 successful operation */ Record<string, number>
180+
export type GetInventoryApiArg = AnyNonNullishValue
181181
export type PlaceOrderApiResponse = /** status 200 successful operation */ Order
182182
export type PlaceOrderApiArg = {
183183
order: Order
@@ -211,7 +211,7 @@ export type LoginUserApiArg = {
211211
password?: string
212212
}
213213
export type LogoutUserApiResponse = unknown
214-
export type LogoutUserApiArg = {}
214+
export type LogoutUserApiArg = AnyNonNullishValue
215215
export type GetUserByNameApiResponse =
216216
/** status 200 successful operation */ User
217217
export type GetUserByNameApiArg = {

packages/rtk-query-codegen-openapi/src/bin/cli.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ try {
1313
require('esbuild-runner/register')
1414
}
1515
ts = true
16-
} catch {}
16+
} catch {
17+
/** No-Op */
18+
}
1719

1820
try {
1921
if (!ts) {
@@ -29,9 +31,10 @@ try {
2931

3032
ts = true
3133
}
32-
} catch {}
34+
} catch {
35+
/** No-Op */
36+
}
3337

34-
// tslint:disable-next-line
3538
const meta = require('../../package.json')
3639

3740
program.version(meta.version).usage('</path/to/config.js>').parse(process.argv)

packages/rtk-query-codegen-openapi/src/generate.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import camelCase from 'lodash.camelcase'
22
import path from 'node:path'
33
import ApiGenerator, {
44
getOperationName as _getOperationName,
5-
getReferenceName,
6-
isReference,
7-
supportDeepObjects,
85
createPropertyAssignment,
96
createQuestionToken,
7+
getReferenceName,
8+
isReference,
109
isValidIdentifier,
1110
keywordType,
11+
supportDeepObjects,
1212
} from 'oazapfts/generate'
1313
import type { OpenAPIV3 } from 'openapi-types'
1414
import ts from 'typescript'
@@ -649,7 +649,7 @@ function generatePathExpression(
649649
isFlatArg: boolean,
650650
encodePathParams: boolean,
651651
) {
652-
const expressions: Array<[string, string]> = []
652+
const expressions: [string, string][] = []
653653

654654
const head = path.replace(
655655
/\{(.*?)}(.*?)(?=\{|$)/g,

packages/rtk-query-codegen-openapi/src/generators/react-hooks.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import ts from 'typescript'
21
import { getOperationName } from 'oazapfts/generate'
3-
import { capitalize, isQuery } from '../utils'
2+
import ts from 'typescript'
3+
import { getOverrides } from '../generate'
44
import type {
5-
OperationDefinition,
6-
EndpointOverrides,
75
ConfigFile,
6+
EndpointOverrides,
7+
OperationDefinition,
88
} from '../types'
9-
import { getOverrides } from '../generate'
9+
import { capitalize, isQuery } from '../utils'
1010
import { factory } from '../utils/factory'
1111

1212
type HooksConfigOptions = NonNullable<ConfigFile['hooks']>

packages/rtk-query-codegen-openapi/src/types.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@ type Optional<T, K extends keyof T> = { [k in K]?: NonNullable<T[k]> } & Omit<
1818
T,
1919
K
2020
>
21-
type Id<T> = { [K in keyof T]: T[K] } & {}
21+
22+
/**
23+
* An alias for type `{}`. Represents any value that is not
24+
* `null` or `undefined`. It is mostly used for semantic purposes
25+
* to help distinguish between an empty object type and `{}` as
26+
* they are not the same.
27+
*
28+
* @internal
29+
*/
30+
export type AnyNonNullishValue = NonNullable<unknown>
31+
32+
type Id<T> = { [K in keyof T]: T[K] } & AnyNonNullishValue
2233
type AtLeastOneKey<T> = {
2334
[K in keyof T]-?: Pick<T, K> & Partial<T>
2435
}[keyof T]
@@ -168,8 +179,6 @@ export type ConfigFile =
168179
| Id<Require<CommonOptions & OutputFileOptions, 'outputFile'>>
169180
| Id<
170181
Omit<CommonOptions, 'outputFile'> & {
171-
outputFiles: {
172-
[outputFile: string]: Omit<OutputFileOptions, 'outputFile'>
173-
}
182+
outputFiles: Record<string, Omit<OutputFileOptions, 'outputFile'>>
174183
}
175184
>
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
export const namedBaseQuery = () => {}
1+
export const namedBaseQuery = () => {
2+
/** No-Op */
3+
}
24

3-
export function anotherNamedBaseQuery() {}
5+
export function anotherNamedBaseQuery() {
6+
/** No-Op */
7+
}
48

59
export default namedBaseQuery
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
function customBaseQuery() {}
1+
function customBaseQuery() {
2+
/** No-Op */
3+
}

packages/rtk-query-codegen-openapi/test/fixtures/generated.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { createApi } from '@reduxjs/toolkit/query/react'
21
import { fetchBaseQuery } from '@reduxjs/toolkit/query'
2+
import { createApi } from '@reduxjs/toolkit/query/react'
3+
import type { AnyNonNullishValue } from '../../src/types.js'
34
export const api = createApi({
45
baseQuery: fetchBaseQuery({ baseUrl: '/api/v3' }),
56
tagTypes: [],
@@ -132,7 +133,7 @@ export const api = createApi({
132133
export type GetHealthcheckApiResponse = /** status 200 OK */ {
133134
message: string
134135
}
135-
export type GetHealthcheckApiArg = {}
136+
export type GetHealthcheckApiArg = AnyNonNullishValue
136137
export type UpdatePetApiResponse = /** status 200 Successful operation */ Pet
137138
export type UpdatePetApiArg = {
138139
/** Update an existent pet in the store */
@@ -184,10 +185,9 @@ export type UploadFileApiArg = {
184185
additionalMetadata?: string
185186
body: string
186187
}
187-
export type GetInventoryApiResponse = /** status 200 successful operation */ {
188-
[key: string]: number
189-
}
190-
export type GetInventoryApiArg = {}
188+
export type GetInventoryApiResponse =
189+
/** status 200 successful operation */ Record<string, number>
190+
export type GetInventoryApiArg = AnyNonNullishValue
191191
export type PlaceOrderApiResponse = /** status 200 successful operation */ Order
192192
export type PlaceOrderApiArg = {
193193
order: Order
@@ -221,7 +221,7 @@ export type LoginUserApiArg = {
221221
password?: string
222222
}
223223
export type LogoutUserApiResponse = unknown
224-
export type LogoutUserApiArg = {}
224+
export type LogoutUserApiArg = AnyNonNullishValue
225225
export type GetUserByNameApiResponse =
226226
/** status 200 successful operation */ User
227227
export type GetUserByNameApiArg = {

packages/rtk-query-codegen-openapi/test/fixtures/petstore.yaml.mock.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ openapi: 3.0.2
33
info:
44
title: Swagger Petstore - OpenAPI 3.0
55
description: "This is a sample Pet Store Server based on the OpenAPI 3.0 specification.\
6-
\ You can find out more about\nSwagger at [http://swagger.io](http://swagger.io).\
7-
\ In the third iteration of the pet store, we've switched to the design first\
8-
\ approach!\nYou can now help us improve the API whether it's by making changes\
9-
\ to the definition itself or to the code.\nThat way, with time, we can improve\
10-
\ the API in general, and expose some of the new features in OAS3.\n\nSome useful\
11-
\ links:\n- [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)\n\
6+
You can find out more about\nSwagger at [http://swagger.io](http://swagger.io).\
7+
In the third iteration of the pet store, we've switched to the design first\
8+
approach!\nYou can now help us improve the API whether it's by making changes\
9+
to the definition itself or to the code.\nThat way, with time, we can improve\
10+
the API in general, and expose some of the new features in OAS3.\n\nSome useful\
11+
links:\n- [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)\n\
1212
- [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)"
1313
termsOfService: http://swagger.io/terms/
1414
contact:
@@ -157,7 +157,7 @@ paths:
157157
- pet
158158
summary: Finds Pets by tags
159159
description: "Multiple tags can be provided with comma separated strings. Use\
160-
\ tag1, tag2, tag3 for testing."
160+
tag1, tag2, tag3 for testing."
161161
operationId: findPetsByTags
162162
parameters:
163163
- name: tags

0 commit comments

Comments
 (0)