Skip to content

Commit 41c9450

Browse files
committed
Lint files
1 parent bb2337a commit 41c9450

File tree

8 files changed

+426
-377
lines changed

8 files changed

+426
-377
lines changed

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "none",
4+
"singleQuote": true,
5+
"jsxSingleQuote": true,
6+
"printWidth": 80
7+
}

src/hooks/useItem.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('useItem', () => {
1212
fetch
1313
.mockResponseOnce(JSON.stringify({ id: 'abc', links: [] }))
1414
.mockResponseOnce(JSON.stringify({ id: 'abc' }));
15-
15+
1616
const { result, waitForNextUpdate } = renderHook(
1717
() => useItem('https://fake-stac-api.net/items/abc'),
1818
{ wrapper }
@@ -25,7 +25,10 @@ describe('useItem', () => {
2525
it('handles error with JSON response', async () => {
2626
fetch
2727
.mockResponseOnce(JSON.stringify({ id: 'abc', links: [] }))
28-
.mockResponseOnce(JSON.stringify({ error: 'Wrong query' }), { status: 400, statusText: 'Bad Request' });
28+
.mockResponseOnce(JSON.stringify({ error: 'Wrong query' }), {
29+
status: 400,
30+
statusText: 'Bad Request'
31+
});
2932

3033
const { result, waitForNextUpdate } = renderHook(
3134
() => useItem('https://fake-stac-api.net/items/abc'),
@@ -43,7 +46,10 @@ describe('useItem', () => {
4346
it('handles error with non-JSON response', async () => {
4447
fetch
4548
.mockResponseOnce(JSON.stringify({ id: 'abc', links: [] }))
46-
.mockResponseOnce('Wrong query', { status: 400, statusText: 'Bad Request' });
49+
.mockResponseOnce('Wrong query', {
50+
status: 400,
51+
statusText: 'Bad Request'
52+
});
4753

4854
const { result, waitForNextUpdate } = renderHook(
4955
() => useItem('https://fake-stac-api.net/items/abc'),
@@ -63,7 +69,7 @@ describe('useItem', () => {
6369
.mockResponseOnce(JSON.stringify({ id: 'abc', links: [] }))
6470
.mockResponseOnce(JSON.stringify({ id: 'abc' }))
6571
.mockResponseOnce(JSON.stringify({ id: 'abc', description: 'Updated' }));
66-
72+
6773
const { result, waitForNextUpdate } = renderHook(
6874
() => useItem('https://fake-stac-api.net/items/abc'),
6975
{ wrapper }

src/hooks/useItem.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect, useCallback} from 'react';
1+
import { useState, useEffect, useCallback } from 'react';
22
import { Item } from '../types/stac';
33
import { ApiError, LoadingState } from '../types';
44
import { useStacApiContext } from '../context';
@@ -8,13 +8,13 @@ type ItemHook = {
88
state: LoadingState;
99
error?: ApiError;
1010
reload: () => void;
11-
}
11+
};
1212

1313
function useItem(url: string): ItemHook {
1414
const { stacApi, getItem, addItem, deleteItem } = useStacApiContext();
15-
const [ state, setState ] = useState<LoadingState>('IDLE');
16-
const [ item, setItem ] = useState<Item>();
17-
const [ error, setError ] = useState<ApiError>();
15+
const [state, setState] = useState<LoadingState>('IDLE');
16+
const [item, setItem] = useState<Item>();
17+
const [error, setError] = useState<ApiError>();
1818

1919
useEffect(() => {
2020
if (!stacApi) return;
@@ -25,9 +25,10 @@ function useItem(url: string): ItemHook {
2525
if (i) {
2626
resolve(i);
2727
} else {
28-
stacApi.fetch(url)
29-
.then(r => r.json())
30-
.then(r => {
28+
stacApi
29+
.fetch(url)
30+
.then((r) => r.json())
31+
.then((r) => {
3132
addItem(url, r);
3233
resolve(r);
3334
})
@@ -48,9 +49,10 @@ function useItem(url: string): ItemHook {
4849
if (i) {
4950
resolve(i);
5051
} else {
51-
stacApi.fetch(url)
52-
.then(r => r.json())
53-
.then(r => {
52+
stacApi
53+
.fetch(url)
54+
.then((r) => r.json())
55+
.then((r) => {
5456
addItem(url, r);
5557
resolve(r);
5658
})
@@ -67,7 +69,7 @@ function useItem(url: string): ItemHook {
6769
fetchItem();
6870
}, [deleteItem, fetchItem, url]);
6971

70-
return {
72+
return {
7173
item,
7274
state,
7375
error,

0 commit comments

Comments
 (0)