Skip to content

Commit 8d86601

Browse files
committed
Fix the remaining lint issues
1 parent 6d64dd2 commit 8d86601

File tree

10 files changed

+62
-44
lines changed

10 files changed

+62
-44
lines changed

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

+5-5
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

+6-3
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -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/types.ts

+13-4
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
>
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
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

+7-7
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

+7-7
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

packages/rtk-query-codegen-openapi/test/generateEndpoints.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test('should include default response type in request when includeDefault is set
3232
schemaFile: resolve(__dirname, 'fixtures/petstore.json'),
3333
includeDefault: true,
3434
})
35-
// eslint-disable-next-line no-template-curly-in-string
35+
3636
expect(api).toMatch(
3737
/export type CreateUserApiResponse =[\s\S/*]+status default successful operation[\s/*]+User;/,
3838
)
@@ -197,7 +197,7 @@ describe('option encodePathParams', () => {
197197
...config,
198198
filterEndpoints: ['getOrderById'],
199199
})
200-
// eslint-disable-next-line no-template-curly-in-string
200+
201201
expect(api).toContain(
202202
'`/store/order/${encodeURIComponent(String(queryArg.orderId))}`',
203203
)
@@ -226,7 +226,7 @@ describe('option encodePathParams', () => {
226226
flattenArg: true,
227227
filterEndpoints: ['getOrderById'],
228228
})
229-
// eslint-disable-next-line no-template-curly-in-string
229+
230230
expect(api).toContain(
231231
'`/store/order/${encodeURIComponent(String(queryArg))}`',
232232
)
@@ -238,7 +238,7 @@ describe('option encodePathParams', () => {
238238
encodePathParams: false,
239239
filterEndpoints: ['findPetsByStatus', 'getOrderById'],
240240
})
241-
// eslint-disable-next-line no-template-curly-in-string
241+
242242
expect(api).toContain('`/store/order/${queryArg.orderId}`')
243243
})
244244
})
@@ -266,7 +266,7 @@ describe('option encodeQueryParams', () => {
266266
...config,
267267
filterEndpoints: ['getOrderById'],
268268
})
269-
// eslint-disable-next-line no-template-curly-in-string
269+
270270
expect(api).toContain('`/store/order/${queryArg.orderId}`')
271271
})
272272

@@ -301,7 +301,7 @@ describe('option flattenArg', () => {
301301
...config,
302302
filterEndpoints: ['getOrderById'],
303303
})
304-
// eslint-disable-next-line no-template-curly-in-string
304+
305305
expect(api).toContain('`/store/order/${queryArg}`')
306306
expect(api).toMatch(
307307
/export type GetOrderByIdApiArg =[\s/*]+ID of order that needs to be fetched[\s/*]+number;/,
@@ -471,7 +471,7 @@ test('should use brackets in a querystring urls arg, when the arg contains full
471471
apiFile: './fixtures/emptyApi.ts',
472472
schemaFile: resolve(__dirname, 'fixtures/params.json'),
473473
})
474-
// eslint-disable-next-line no-template-curly-in-string
474+
475475
expect(api).toContain('`/api/v1/list/${queryArg["item.id"]}`')
476476
expect(api).toMatchSnapshot()
477477
})
@@ -482,7 +482,7 @@ test('duplicate parameter names must be prefixed with a path or query prefix', a
482482
apiFile: './fixtures/emptyApi.ts',
483483
schemaFile: resolve(__dirname, 'fixtures/params.json'),
484484
})
485-
// eslint-disable-next-line no-template-curly-in-string
485+
486486
expect(api).toContain('pathSomeName: string')
487487
expect(api).toContain('querySomeName: string')
488488
expect(api).toMatchSnapshot()

website/docusaurus.config.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// site configuration options.
2-
import { resolve } from 'path'
3-
import { linkDocblocks, transpileCodeblocks } from 'remark-typescript-tools'
2+
import type { Options as UmamiOptions } from '@dipakparmar/docusaurus-plugin-umami'
43
import type { Options, ThemeConfig } from '@docusaurus/preset-classic'
54
import type { Config } from '@docusaurus/types'
6-
import type { Options as UmamiOptions } from '@dipakparmar/docusaurus-plugin-umami'
7-
import type { Options as RSDoctorOptions } from '@docusaurus/plugin-rsdoctor'
5+
import { resolve } from 'path'
6+
import { linkDocblocks, transpileCodeblocks } from 'remark-typescript-tools'
7+
import monokaiTheme from './src/js/monokaiTheme.js'
88

99
const config: Config = {
1010
future: {
@@ -76,15 +76,15 @@ const config: Config = {
7676
},
7777
metadata: [{ name: 'twitter:card', content: 'summary' }],
7878
prism: {
79-
theme: require('./src/js/monokaiTheme.js'),
79+
theme: monokaiTheme,
8080
},
8181
image: 'img/redux-logo-landscape.png',
8282
colorMode: {
8383
respectPrefersColorScheme: true,
8484
},
8585
announcementBar: {
8686
id: 'redux-dev-course',
87-
content: `
87+
content: `
8888
<a href="https://redux.dev">
8989
<img
9090
src="/img/course-callout-wide.svg"

0 commit comments

Comments
 (0)