Skip to content

Commit 361bbf2

Browse files
author
Thomas Dashney
committed
remove I interface prefix and update eslint rule
1 parent 1fa021d commit 361bbf2

File tree

14 files changed

+57
-57
lines changed

14 files changed

+57
-57
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"rules": {
4040
"prettier/prettier": 1,
4141
"@typescript-eslint/explicit-function-return-type": 0,
42-
"@typescript-eslint/interface-name-prefix": [1, {"prefixWithI": "always"}],
42+
"@typescript-eslint/interface-name-prefix": [1, {"prefixWithI": "never"}],
4343
"@typescript-eslint/no-empty-interface": 0,
4444
"@typescript-eslint/no-explicit-any": 0,
4545
"@typescript-eslint/no-unused-vars": 0,

src/api/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {createSubscription, genCacheUpdateEvent, getParamsId} from './lib'
77
import {ApiRequestManager} from './request-manager'
88
import {
99
ApiRequestMethod,
10+
ApiRequestOptions,
1011
IApiParseResponseJson,
11-
IApiRequestOptions,
1212
IApiRequestParams,
1313
IApiSerializeRequestJson,
1414
ResponseBody
@@ -55,7 +55,7 @@ export class Api {
5555
*/
5656
request = <TResponseBody extends ResponseBody>(
5757
params: IApiRequestParams<ApiRequestMethod, TResponseBody>,
58-
options: IApiRequestOptions = {}
58+
options: ApiRequestOptions = {}
5959
): Promise<TResponseBody> => {
6060
const {fetchPolicy = DEFAULT_FETCH_POLICY} = options
6161

src/api/request-fetcher/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {ApiError} from '../errors'
22
import {
33
ApiResponseType,
4-
IRequestFetcher,
5-
IRequestFetcherParams,
4+
RequestFetcher,
5+
RequestFetcherParams,
66
ResponseBody
77
} from '../typings'
88

@@ -13,9 +13,9 @@ import {
1313
* - Throwing ApiErrors for non-200 level errors
1414
* - Parsing response bodies
1515
*/
16-
export class ApiRequestFetcher implements IRequestFetcher {
16+
export class ApiRequestFetcher implements RequestFetcher {
1717
getResponse = async (
18-
params: IRequestFetcherParams
18+
params: RequestFetcherParams
1919
): Promise<{
2020
responseBody: ResponseBody | null
2121
responseType: ApiResponseType | null
@@ -37,7 +37,7 @@ export class ApiRequestFetcher implements IRequestFetcher {
3737
/**
3838
* Generates a `Request` instance to be passed directly to `fetch`
3939
*/
40-
private createRequest(params: IRequestFetcherParams): Request {
40+
private createRequest(params: RequestFetcherParams): Request {
4141
return new Request(params.url, {
4242
method: params.method,
4343
body: params.body,
@@ -50,7 +50,7 @@ export class ApiRequestFetcher implements IRequestFetcher {
5050
*/
5151
private async parseResponseBody(
5252
response: Response,
53-
params: IRequestFetcherParams
53+
params: RequestFetcherParams
5454
): Promise<{
5555
responseBody: ResponseBody | null
5656
responseType: ApiResponseType | null

src/api/request-manager/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import {applyHeaders, createSubscription, getParamsId} from '../lib'
77
import {ApiRequestFetcher} from '../request-fetcher'
88
import {
99
ApiRequestMethod,
10+
ApiRequestOptions,
1011
IApiParseResponseJson,
11-
IApiRequestOptions,
1212
IApiRequestParams,
1313
IApiSerializeRequestJson,
14-
IRequestFetcher,
1514
RequestBody,
15+
RequestFetcher,
1616
ResponseBody
1717
} from '../typings'
1818

@@ -38,7 +38,7 @@ export class ApiRequestManager {
3838

3939
private emitter = new EventEmitter()
4040

41-
private requestFetcher: IRequestFetcher
41+
private requestFetcher: RequestFetcher
4242

4343
private serializeRequestJson: IApiSerializeRequestJson
4444

@@ -66,7 +66,7 @@ export class ApiRequestManager {
6666
* through this transformation function before returning the response
6767
*/
6868
parseResponseJson?: IApiParseResponseJson
69-
requestFetcher?: IRequestFetcher
69+
requestFetcher?: RequestFetcher
7070
}) {
7171
this.baseUrl = params.baseUrl || ''
7272
this.requestFetcher = params.requestFetcher || new ApiRequestFetcher()
@@ -84,7 +84,7 @@ export class ApiRequestManager {
8484
*/
8585
getResponseBody = <TResponseBody extends ResponseBody>(
8686
params: IApiRequestParams<ApiRequestMethod, TResponseBody>,
87-
options: IApiRequestOptions
87+
options: ApiRequestOptions
8888
): Promise<TResponseBody | null> => {
8989
if (params.method !== 'GET') {
9090
// only cache in-progress requests for GET requests
@@ -111,7 +111,7 @@ export class ApiRequestManager {
111111

112112
private async createGetPromise(
113113
params: IApiRequestParams,
114-
options: IApiRequestOptions,
114+
options: ApiRequestOptions,
115115
id: symbol
116116
): Promise<ResponseBody | null> {
117117
const paramsId = getParamsId(params)
@@ -167,7 +167,7 @@ export class ApiRequestManager {
167167

168168
private fetchResponseBody = async (
169169
params: IApiRequestParams,
170-
options: IApiRequestOptions
170+
options: ApiRequestOptions
171171
): Promise<ResponseBody | null> => {
172172
const {fetchPolicy = DEFAULT_FETCH_POLICY} = options
173173
try {

src/api/typings.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@ export type RequestBody = BodyInit | object
99
export type ResponseBody = Blob | object | string
1010
export type ApiResponseType = 'json' | 'text' | 'blob'
1111

12-
interface IApiCommonRequestParams<TMethod extends ApiRequestMethod> {
12+
interface ApiCommonRequestParams<TMethod extends ApiRequestMethod> {
1313
url: string
1414
method: TMethod
1515
headers?: ApiHeaders
1616
responseType?: ApiResponseType
1717
}
1818

19-
export interface IApiGetDeleteRequestParams<
19+
export interface ApiGetDeleteRequestParams<
2020
TMethod extends GetDeleteRequestMethod,
2121
TResponseBody extends ResponseBody = never
22-
> extends IApiCommonRequestParams<TMethod> {}
22+
> extends ApiCommonRequestParams<TMethod> {}
2323

24-
export interface IApiMutationRequestParams<
24+
export interface ApiMutationRequestParams<
2525
TMethod extends PostPutPatchRequestMethod,
2626
TResponseBody extends ResponseBody = never
27-
> extends IApiCommonRequestParams<TMethod> {
27+
> extends ApiCommonRequestParams<TMethod> {
2828
body?: RequestBody
2929
}
3030

3131
export type IApiRequestParams<
3232
TMethod extends ApiRequestMethod = ApiRequestMethod,
3333
TResponseBody extends ResponseBody = ResponseBody
3434
> = TMethod extends GetDeleteRequestMethod
35-
? IApiGetDeleteRequestParams<TMethod, TResponseBody>
35+
? ApiGetDeleteRequestParams<TMethod, TResponseBody>
3636
: TMethod extends PostPutPatchRequestMethod
37-
? IApiMutationRequestParams<TMethod, TResponseBody>
37+
? ApiMutationRequestParams<TMethod, TResponseBody>
3838
: never
3939

4040
export type IApiSerializeRequestJson = (body: object) => object
@@ -69,7 +69,7 @@ export type ApiRequestFetchPolicy =
6969
*/
7070
| 'cache-and-fetch'
7171

72-
export interface IApiRequestOptions {
72+
export interface ApiRequestOptions {
7373
/**
7474
* Specifies how the request interacts with the cache
7575
*/
@@ -85,17 +85,17 @@ export interface IApiRequestOptions {
8585
forceNewFetch?: boolean
8686
}
8787

88-
export interface IRequestFetcherParams {
88+
export interface RequestFetcherParams {
8989
url: string
9090
method: ApiRequestMethod
9191
body?: BodyInit
9292
headers?: Headers
9393
responseType?: ApiResponseType
9494
}
9595

96-
export interface IRequestFetcher {
96+
export interface RequestFetcher {
9797
getResponse(
98-
params: IRequestFetcherParams
98+
params: RequestFetcherParams
9999
): Promise<{
100100
responseBody: ResponseBody | null
101101
responseType: ApiResponseType | null

src/endpoints/index.spec.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import {
22
ApiParam,
3+
EndpointCreateRequestInit,
34
HttpEndpoints,
4-
IEndpointCreateRequestInit,
55
RestEndpoints
66
} from './'
77

88
describe('HttpEndpoints', () => {
99
class Endpoints extends HttpEndpoints {
1010
static basePath = '/base'
1111

12-
static GET(init: Omit<IEndpointCreateRequestInit, 'body'>) {
12+
static GET(init: Omit<EndpointCreateRequestInit, 'body'>) {
1313
return super._get('/endpoint', init)
1414
}
1515

16-
static POST(init: IEndpointCreateRequestInit = {}) {
16+
static POST(init: EndpointCreateRequestInit = {}) {
1717
return super._post('/endpoint', init)
1818
}
1919

20-
static PUT(init: IEndpointCreateRequestInit = {}) {
20+
static PUT(init: EndpointCreateRequestInit = {}) {
2121
return super._put('/endpoint', init)
2222
}
2323

24-
static PATCH(init: IEndpointCreateRequestInit = {}) {
24+
static PATCH(init: EndpointCreateRequestInit = {}) {
2525
return super._patch('/endpoint', init)
2626
}
2727

28-
static DELETE(init: IEndpointCreateRequestInit = {}) {
28+
static DELETE(init: EndpointCreateRequestInit = {}) {
2929
return super._delete('/endpoint', init)
3030
}
3131
}
@@ -98,7 +98,7 @@ describe('HttpEndpoints', () => {
9898
})
9999

100100
describe('RestEndpoints', () => {
101-
interface IModel {
101+
interface Model {
102102
name: string
103103
}
104104

@@ -109,19 +109,19 @@ describe('RestEndpoints', () => {
109109
return super._list(query)
110110
}
111111

112-
static create(body: IModel) {
112+
static create(body: Model) {
113113
return super._create(body)
114114
}
115115

116116
static findById(id: ApiParam) {
117117
return super._findById(id)
118118
}
119119

120-
static update(id: ApiParam, body: Partial<IModel>) {
120+
static update(id: ApiParam, body: Partial<Model>) {
121121
return super._update(id, body)
122122
}
123123

124-
static partialUpdate(id: ApiParam, body: Partial<IModel>) {
124+
static partialUpdate(id: ApiParam, body: Partial<Model>) {
125125
return super._partialUpdate(id, body)
126126
}
127127

src/endpoints/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010

1111
export type ApiQueryParams = Record<string, string | number | boolean>
1212

13-
export interface IEndpointCreateRequestInit {
13+
export interface EndpointCreateRequestInit {
1414
query?: ApiQueryParams
1515
headers?: ApiHeaders
1616
body?: RequestBody
@@ -55,7 +55,7 @@ export class HttpEndpoints {
5555
*/
5656
protected static _get<TResponseBody extends ResponseBody = ResponseBody>(
5757
path: string,
58-
requestInit?: Omit<IEndpointCreateRequestInit, 'body'>
58+
requestInit?: Omit<EndpointCreateRequestInit, 'body'>
5959
) {
6060
return this._createRequest<'GET', TResponseBody>('GET', path, requestInit)
6161
}
@@ -68,7 +68,7 @@ export class HttpEndpoints {
6868
*/
6969
protected static _post<TResponseBody extends ResponseBody = ResponseBody>(
7070
path: string,
71-
requestInit?: IEndpointCreateRequestInit
71+
requestInit?: EndpointCreateRequestInit
7272
) {
7373
return this._createRequest<'POST', TResponseBody>('POST', path, requestInit)
7474
}
@@ -81,7 +81,7 @@ export class HttpEndpoints {
8181
*/
8282
protected static _put<TResponseBody extends ResponseBody = ResponseBody>(
8383
path: string,
84-
requestInit?: IEndpointCreateRequestInit
84+
requestInit?: EndpointCreateRequestInit
8585
) {
8686
return this._createRequest<'PUT', TResponseBody>('PUT', path, requestInit)
8787
}
@@ -94,7 +94,7 @@ export class HttpEndpoints {
9494
*/
9595
protected static _patch<TResponseBody extends ResponseBody = ResponseBody>(
9696
path: string,
97-
requestInit?: IEndpointCreateRequestInit
97+
requestInit?: EndpointCreateRequestInit
9898
) {
9999
return this._createRequest<'PATCH', TResponseBody>(
100100
'PATCH',
@@ -111,7 +111,7 @@ export class HttpEndpoints {
111111
*/
112112
protected static _delete<TResponseBody extends ResponseBody = ResponseBody>(
113113
path: string,
114-
requestInit?: IEndpointCreateRequestInit
114+
requestInit?: EndpointCreateRequestInit
115115
) {
116116
return this._createRequest<'DELETE', TResponseBody>(
117117
'DELETE',
@@ -152,7 +152,7 @@ export class HttpEndpoints {
152152
>(
153153
method: TMethod,
154154
path: string,
155-
requestInit: IEndpointCreateRequestInit = {}
155+
requestInit: EndpointCreateRequestInit = {}
156156
): IApiRequestParams<TMethod, TResponseBody> {
157157
let url = this.buildPath(path)
158158

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export * from './react/context'
66
export {
77
ApiParam,
88
ApiQueryParams,
9-
IEndpointCreateRequestInit,
9+
EndpointCreateRequestInit as IEndpointCreateRequestInit,
1010
HttpEndpoints,
1111
RestEndpoints,
1212
dynamicPath

src/react/context.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import {Api} from '../api'
44

55
export const ApiContext = createContext<Api>(new Api())
66

7-
export interface IApiProviderProps {
7+
export interface ApiProviderProps {
88
api: Api
99
}
1010

11-
export const ApiProvider: React.FC<IApiProviderProps> = function ApiProvider(
11+
export const ApiProvider: React.FC<ApiProviderProps> = function ApiProvider(
1212
props
1313
) {
1414
return (

src/react/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export * from './use-api'
22
export * from './use-api-query/index'
3-
export {withApi, IWithApiProps} from './with-api'
3+
export {withApi, WithApiProps as IWithApiProps} from './with-api'

src/react/use-api-query/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import {useApi} from '../use-api'
1212
import {useApiQueryActions} from './actions'
1313
import {useApiQueryReducer} from './reducer'
1414

15-
interface IUseApiQueryData<TResponseBody extends ResponseBody> {
15+
interface UseApiQueryData<TResponseBody extends ResponseBody> {
1616
data: TResponseBody | undefined | null
1717
loading: boolean
1818
error: Error | null
1919
}
2020

21-
export interface IUseApiQueryActions<TResponseBody extends ResponseBody> {
21+
export interface UseApiQueryActions<TResponseBody extends ResponseBody> {
2222
/**
2323
* Sets the response data of the Api request manually.
2424
*
@@ -76,7 +76,7 @@ export function useApiQuery<TResponseBody extends ResponseBody>(
7676
*/
7777
dontReinitialize?: boolean
7878
} = {}
79-
): [IUseApiQueryData<TResponseBody>, IUseApiQueryActions<TResponseBody>] {
79+
): [UseApiQueryData<TResponseBody>, UseApiQueryActions<TResponseBody>] {
8080
const api = useApi()
8181
const fetchPolicy = opts.fetchPolicy || api.defaultFetchPolicy
8282
const paramsId = params && getParamsId(params)

0 commit comments

Comments
 (0)