Skip to content

Commit af29972

Browse files
committed
make eslint manual fixes
1 parent 41e3905 commit af29972

10 files changed

Lines changed: 18 additions & 17 deletions

File tree

src/async-data/AsyncView.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactElement, ReactNode } from 'react'
1+
import { ReactNode } from 'react'
22
import { isFunction } from '../util'
33

44
type LoadingFunction = () => ReactNode
@@ -36,8 +36,7 @@ type Props<Data, Error> = {
3636

3737
const AsyncView = <Data, Error>(
3838
props: Props<Data, Error>,
39-
// The `ReactElement<any, any> | null` type is for React 17 compatibility (see type FunctionComponent). With React 18 it can be a ReactNode and we can remove the Fragment wrappers.
40-
): ReactElement<any, any> | null => {
39+
): ReactNode | null => {
4140
const {
4241
data,
4342
error,

src/async-data/asyncState.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ var AsyncState
1616
* inference.
1717
*/
1818
const getAsyncState = (data, error) => {
19-
if (error != null && error != undefined) {
19+
if (error !== null && error !== undefined) {
2020
return AsyncState.FINISHED_WITH_ERROR
21-
} else if (data != null && data != undefined) {
21+
} else if (data !== null && data !== undefined) {
2222
return AsyncState.FINISHED_WITH_SUCCESS
2323
} else {
2424
return AsyncState.FETCHING

src/async-data/asyncState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ enum AsyncState {
1515
* inference.
1616
*/
1717
const getAsyncState = (data: unknown, error: unknown): AsyncState => {
18-
if (error != null && error != undefined) {
18+
if (error !== null && error !== undefined) {
1919
return AsyncState.FINISHED_WITH_ERROR
20-
} else if (data != null && data != undefined) {
20+
} else if (data !== null && data !== undefined) {
2121
return AsyncState.FINISHED_WITH_SUCCESS
2222
} else {
2323
return AsyncState.FETCHING

src/location-provider/getCurrentLocation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ const getCurrentLocation = (highAccuracy = false) => {
44
resolve(position)
55
}
66
const errorCallback = (error) => {
7-
reject(error.message)
7+
reject(new Error(error.message))
88
}
99
if (navigator.geolocation) {
1010
navigator.geolocation.getCurrentPosition(successCallback, errorCallback, {
1111
enableHighAccuracy: highAccuracy,
1212
})
1313
} else {
14-
reject('Geolocation not supported')
14+
reject(new Error('Geolocation not supported'))
1515
}
1616
})
1717
}

src/location-provider/getCurrentLocation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ const getCurrentLocation = (
77
}
88

99
const errorCallback = (error: GeolocationPositionError) => {
10-
reject(error.message)
10+
reject(new Error(error.message))
1111
}
1212

13+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1314
if (navigator.geolocation) {
1415
navigator.geolocation.getCurrentPosition(successCallback, errorCallback, {
1516
enableHighAccuracy: highAccuracy,
1617
})
1718
} else {
18-
reject('Geolocation not supported')
19+
reject(new Error('Geolocation not supported'))
1920
}
2021
})
2122
}

src/useInterval/useInterval.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useRef } from 'react'
22

3-
type Callback = () => unknown | void
3+
type Callback = () => unknown
44
type Delay = number | null
55

66
const useInterval = (callback: Callback, delay: Delay): void => {

src/useMatchMediaQuery/__test__/useMatchMediaQuery.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { RenderResult, render } from '@testing-library/react'
22
import isMatching from 'css-mediaquery'
3-
import React from 'react'
43
import { useMatchMediaQuery } from '../useMatchMediaQuery'
54

65
beforeEach(() => {
76
// mock window.matchMedia (use 'css-mediaquery')
8-
window.matchMedia = jest.fn().mockImplementation((query) => {
7+
window.matchMedia = jest.fn().mockImplementation((query: string) => {
98
return {
109
addListener: jest.fn(),
1110
media: query,

src/useMatchMediaQuery/useMatchMediaQuery.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useEffect, useState } from 'react'
22

33
function useMatchMediaQuery(query: string): boolean | undefined {
4+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
45
if (typeof window !== 'object' || !window.matchMedia) {
56
return
67
}
@@ -18,12 +19,14 @@ function useMatchMediaQuery(query: string): boolean | undefined {
1819
setMatches(media.matches)
1920
}
2021

22+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
2123
if (media.addEventListener) {
2224
media.addEventListener('change', listener)
2325
}
2426

2527
return () => {
26-
media.removeEventListener && media.removeEventListener('change', listener)
28+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
29+
media.removeEventListener?.('change', listener)
2730
}
2831
}, [matches, query])
2932

src/util.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// eslint-disable-next-line @typescript-eslint/ban-types
21
export const isFunction = (obj) => typeof obj === 'function'

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// eslint-disable-next-line @typescript-eslint/ban-types
1+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
22
export const isFunction = (obj: unknown): obj is Function =>
33
typeof obj === 'function'

0 commit comments

Comments
 (0)