Skip to content

Commit 41e3905

Browse files
lukasviceCopilot
andcommitted
make eslint automatic fixes
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b48afc9 commit 41e3905

10 files changed

Lines changed: 51 additions & 30 deletions

File tree

jest-setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import '@testing-library/jest-dom';
1+
import '@testing-library/jest-dom'

jest.config.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"testEnvironment": "jsdom",
3-
"transform": {
4-
"^.+\\.(t|j)sx?$": "ts-jest"
5-
},
6-
"testRegex": "(/__tests?__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
7-
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
8-
"setupFilesAfterEnv": ["<rootDir>/jest-setup.ts"]
2+
"testEnvironment": "jsdom",
3+
"transform": {
4+
"^.+\\.(t|j)sx?$": "ts-jest"
5+
},
6+
"testRegex": "(/__tests?__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
7+
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
8+
"setupFilesAfterEnv": ["<rootDir>/jest-setup.ts"]
99
}

src/async-data/__test__/AsyncView.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { RenderResult, render } from '@testing-library/react'
12
import React from 'react'
2-
import { render, RenderResult } from '@testing-library/react'
33
import { AsyncView } from '../AsyncView'
44

55
type Data = {

src/location-provider/LocationProvider.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1+
import { createContext, useEffect, useState } from 'react'
12
import { jsx as _jsx } from 'react/jsx-runtime'
2-
import { useEffect, useState } from 'react'
3-
import { createContext } from 'react'
43
import { useInterval } from '../index'
54
import { getCurrentLocation } from './getCurrentLocation'
65
export const LocationContext = createContext({
@@ -25,5 +24,5 @@ export const LocationProvider = ({ highAccuracy, delay, children }) => {
2524
useInterval(() => {
2625
updateLocation()
2726
}, delay)
28-
return _jsx(LocationContext.Provider, { value: location, children: children })
27+
return _jsx(LocationContext.Provider, { value: location, children })
2928
}

src/location-provider/LocationProvider.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React, { useEffect, useState } from 'react'
2-
import { createContext } from 'react'
1+
import React, { createContext, useEffect, useState } from 'react'
32
import { useInterval } from '../index'
43
import { getCurrentLocation } from './getCurrentLocation'
54

src/useInterval/useInterval.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import { useEffect, useRef } from 'react'
22
const useInterval = (callback, delay) => {
33
const savedCallback = useRef(null)
44
useEffect(() => {
5-
if (delay === null) return
5+
if (delay === null) {
6+
return
7+
}
68
savedCallback.current = callback
79
})
810
useEffect(() => {
9-
if (delay === null) return
11+
if (delay === null) {
12+
return
13+
}
1014
const tick = () => {
1115
if (savedCallback.current !== null) {
1216
savedCallback.current()

src/useInterval/useInterval.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,26 @@ const useInterval = (callback: Callback, delay: Delay): void => {
77
const savedCallback = useRef<Callback | null>(null)
88

99
useEffect(() => {
10-
if (delay === null) return
10+
if (delay === null) {
11+
return
12+
}
1113
savedCallback.current = callback
1214
})
1315

1416
useEffect(() => {
15-
if (delay === null) return
17+
if (delay === null) {
18+
return
19+
}
1620

1721
const tick = (): void => {
1822
if (savedCallback.current !== null) {
1923
savedCallback.current()
2024
}
2125
}
2226
const id = setInterval(tick, delay)
23-
return (): void => clearInterval(id)
27+
return (): void => {
28+
clearInterval(id)
29+
}
2430
}, [delay])
2531
}
2632

src/useMatchMediaQuery/__test__/useMatchMediaQuery.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from 'react'
1+
import { RenderResult, render } from '@testing-library/react'
22
import isMatching from 'css-mediaquery'
3-
import { render, RenderResult } from '@testing-library/react'
3+
import React from 'react'
44
import { useMatchMediaQuery } from '../useMatchMediaQuery'
55

66
beforeEach(() => {
@@ -18,7 +18,9 @@ beforeEach(() => {
1818

1919
const TestComponent = ({ query }: { query: string }) => {
2020
const isMatched = useMatchMediaQuery(query)
21-
if (isMatched) return <div>visible</div>
21+
if (isMatched) {
22+
return <div>visible</div>
23+
}
2224
return <div>hidden</div>
2325
}
2426

src/useMatchMediaQuery/useMatchMediaQuery.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { useState, useEffect } from 'react'
1+
import { useEffect, useState } from 'react'
22
function useMatchMediaQuery(query) {
3-
if (typeof window !== 'object' || !window.matchMedia) return
3+
if (typeof window !== 'object' || !window.matchMedia) {
4+
return
5+
}
46
const [matches, setMatches] = useState(window.matchMedia(query).matches)
57
useEffect(() => {
68
const media = window.matchMedia(query)
7-
if (media.matches !== matches) setMatches(media.matches)
9+
if (media.matches !== matches) {
10+
setMatches(media.matches)
11+
}
812
const listener = () => setMatches(media.matches)
913
if (media.addEventListener) {
1014
media.addEventListener('change', listener)

src/useMatchMediaQuery/useMatchMediaQuery.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
import { useState, useEffect } from 'react'
1+
import { useEffect, useState } from 'react'
22

33
function useMatchMediaQuery(query: string): boolean | undefined {
4-
if (typeof window !== 'object' || !window.matchMedia) return
4+
if (typeof window !== 'object' || !window.matchMedia) {
5+
return
6+
}
57

68
const [matches, setMatches] = useState(window.matchMedia(query).matches)
79

810
useEffect(() => {
911
const media = window.matchMedia(query)
1012

11-
if (media.matches !== matches) setMatches(media.matches)
13+
if (media.matches !== matches) {
14+
setMatches(media.matches)
15+
}
1216

13-
const listener = () => setMatches(media.matches)
17+
const listener = () => {
18+
setMatches(media.matches)
19+
}
1420

1521
if (media.addEventListener) {
1622
media.addEventListener('change', listener)
1723
}
1824

19-
return () =>
25+
return () => {
2026
media.removeEventListener && media.removeEventListener('change', listener)
27+
}
2128
}, [matches, query])
2229

2330
return matches

0 commit comments

Comments
 (0)