Skip to content

Commit 909ca79

Browse files
author
Damián Finkelstein
committed
added new linter packages, updated eslintrc and fixed parenthesis errors
1 parent ee934de commit 909ca79

File tree

18 files changed

+489
-725
lines changed

18 files changed

+489
-725
lines changed

cookbook-react/.eslintrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": [
3+
"@wolox/eslint-config",
4+
"@wolox/eslint-config-react",
5+
"@wolox/eslint-config-typescript"
6+
],
7+
"settings": {
8+
"react": {
9+
"version": "detect"
10+
}
11+
}
12+
}

cookbook-react/.eslintrc.js

-8
This file was deleted.

cookbook-react/package-lock.json

+359-612
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cookbook-react/package.json

+16-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"react": "^17.0.1",
1919
"react-dom": "^17.0.1",
2020
"react-hook-form": "^6.14.2",
21-
"react-paginate": "^7.0.0",
21+
"react-paginate": "^7.1.0",
2222
"react-router": "^5.2.0",
2323
"react-router-dom": "^5.2.0",
2424
"react-scripts": "^4.0.1",
@@ -54,7 +54,7 @@
5454
]
5555
},
5656
"devDependencies": {
57-
"@rescripts/cli": "0.0.14",
57+
"@rescripts/cli": "0.0.16",
5858
"@testing-library/react-hooks": "^3.7.0",
5959
"@types/classnames": "^2.2.11",
6060
"@types/react-paginate": "^6.2.1",
@@ -63,25 +63,29 @@
6363
"@types/react-spinkit": "^3.0.6",
6464
"@types/seamless-immutable": "^7.1.15",
6565
"@types/webpack-env": "^1.16.0",
66-
"@typescript-eslint/parser": "^4.14.1",
67-
"@wolox/eslint-config-typescript": "^1.1.3",
66+
"@typescript-eslint/parser": "4.14.2",
67+
"@wolox/eslint-config-typescript": "^2.0.0",
6868
"aws-deploy-script-fe": "^1.0.8",
6969
"env-cmd": "^10.1.0",
70-
"eslint-config-wolox": "^3.0.2",
71-
"eslint-config-wolox-react": "^2.1.2",
70+
"@wolox/eslint-config": "^1.0.0",
71+
"@wolox/eslint-config-react": "^1.0.0",
72+
"eslint": "7.19.0",
7273
"eslint-import-resolver-typescript": "^2.3.0",
73-
"eslint-plugin-babel": "^5.3.0",
74+
"eslint-plugin-babel": "^5.3.1",
7475
"eslint-plugin-import": "^2.22.1",
75-
"eslint-plugin-jsx-a11y": "^6.2.3",
76-
"eslint-plugin-prettier": "^3.1.0",
77-
"eslint-plugin-react": "^7.14.3",
76+
"eslint-plugin-jsx-a11y": "^6.4.1",
77+
"eslint-plugin-prettier": "^3.3.1",
78+
"eslint-plugin-react": "^7.22.0",
79+
"eslint-plugin-testing-library": "^3.10.1",
80+
"eslint-plugin-react-hooks": "4.2.0",
81+
"@typescript-eslint/eslint-plugin": "4.14.2",
7882
"husky": "^4.3.8",
7983
"minimist": "^1.2.0",
8084
"mutationobserver-shim": "^0.3.7",
8185
"postcss-html": "^0.36.0",
8286
"postcss-syntax": "^0.36.2",
83-
"prettier": "^1.19.1",
84-
"prettier-eslint": "^8.8.2",
87+
"prettier": "^2.2.1",
88+
"prettier-eslint": "^12.0.0",
8589
"prettier-eslint-cli": "^5.0.0",
8690
"prettier-stylelint": "^0.4.2",
8791
"react-test-renderer": "^17.0.1",

cookbook-react/src/app/contexts/UserContext/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useSelector, useDispatch, Context } from '.';
88

99
describe('When wrapping a component with the context', () => {
1010
test('useSelector returns the state', () => {
11-
const { result } = renderHook(() => useSelector(state => state));
11+
const { result } = renderHook(() => useSelector((state) => state));
1212
expect(result.current).toEqual(INITIAL_STATE);
1313
});
1414

cookbook-react/src/app/hooks/useRequest.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface AsyncRequestHookParams<P, D, E, T> {
1515
request: Request<P, D, E>;
1616
withPostSuccess?: Success<T>;
1717
withPostFailure?: Failure<E>;
18-
initialState?: T | null;
18+
initialState?: Nullable<T>;
1919
withPostFetch?: PostFetch<T, E>;
2020
transformResponse?: (response: D | E) => T;
2121
}
@@ -55,7 +55,7 @@ export const useLazyRequest = <P, D, E, T = D>({
5555
withPostFailure,
5656
initialState = null,
5757
withPostFetch,
58-
transformResponse = response => (response as unknown) as T
58+
transformResponse = (response) => (response as unknown) as T
5959
}: AsyncRequestHookParams<P, D, E, T>): [Nullable<T>, boolean, Nullable<Error<E>>, (params: P) => void] => {
6060
const [state, setState] = useState<Nullable<T>>(initialState);
6161
const [loading, setLoading] = useState(false);
@@ -71,21 +71,21 @@ export const useLazyRequest = <P, D, E, T = D>({
7171
setState(initialState);
7272
setError(null);
7373
},
74-
onSuccess: data => {
74+
onSuccess: (data) => {
7575
if (isMounted.current) {
7676
const successData = data as D;
7777
const transformedResponse = successData ? transformResponse(successData) : undefined;
7878
setState(transformedResponse || null);
7979
withPostSuccess?.(transformedResponse);
8080
}
8181
},
82-
onError: errorInfo => {
82+
onError: (errorInfo) => {
8383
if (isMounted.current) {
8484
setError(() => errorInfo);
8585
withPostFailure?.(errorInfo);
8686
}
8787
},
88-
onPostFetch: response => {
88+
onPostFetch: (response) => {
8989
if (isMounted.current) {
9090
setLoading(false);
9191
if (response.data) {
@@ -110,7 +110,7 @@ export const useRequest = <P, D, E, T = D>(
110110
withPostFailure,
111111
initialState = null,
112112
withPostFetch,
113-
transformResponse = response => (response as unknown) as T
113+
transformResponse = (response) => (response as unknown) as T
114114
}: AsyncRequestHookParamsWithPayload<P, D, E, T>,
115115
dependencies: any[]
116116
): [Nullable<T>, boolean, Nullable<Error<E>>, (params: P) => void] => {

cookbook-react/src/config/context.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const INITIAL_STATE = { foo: { bar: 2 } };
88

99
test('useSelector returns the state', () => {
1010
const { useSelector } = contextFactory(INITIAL_STATE);
11-
const { result } = renderHook(() => useSelector(state => state));
11+
const { result } = renderHook(() => useSelector((state) => state));
1212
expect(result.current).toEqual(INITIAL_STATE);
1313
});
1414

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`renders correctly 1`] = `
4+
<div
5+
class="sk-fade-in-half-second sk-spinner sk-three-bounce"
6+
color="#000"
7+
style="color: rgb(0, 0, 0);"
8+
>
9+
<div />
10+
<div />
11+
<div />
12+
</div>
13+
`;

cookbook-react/src/recipes/inputs/barcelona/index.test.tsx

+18-18
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ describe('Barcelona Input', () => {
1919
expect(instance.toJSON()!).toMatchSnapshot();
2020
});
2121

22-
it('does not show the error message', async () => {
22+
it('does not show the error message', () => {
2323
const { getByRole } = render(component);
24-
const errorElement = await getByRole('alert');
24+
const errorElement = getByRole('alert');
2525
expect(errorElement).not.toHaveClass('show');
2626
});
2727

28-
it('shows the valid icon', async () => {
28+
it('shows the valid icon', () => {
2929
const { getByRole } = render(component);
30-
const validStatusElement = await getByRole('status', { name: 'Input:valid' });
30+
const validStatusElement = getByRole('status', { name: 'Input:valid' });
3131
expect(validStatusElement).not.toBeNull();
3232
});
3333

34-
it('shows the input as valid', async () => {
34+
it('shows the input as valid', () => {
3535
const { getByRole } = render(component);
36-
const inputElement = await getByRole('textbox');
36+
const inputElement = getByRole('textbox');
3737
expect(inputElement).toHaveClass('confirmed');
3838
expect(inputElement).not.toHaveClass('inputError');
3939
});
@@ -47,21 +47,21 @@ describe('Barcelona Input', () => {
4747
expect(instance.toJSON()!).toMatchSnapshot();
4848
});
4949

50-
it('shows the error message', async () => {
50+
it('shows the error message', () => {
5151
const { getByRole } = render(component);
52-
const errorElement = await getByRole('alert');
52+
const errorElement = getByRole('alert');
5353
expect(errorElement).toHaveClass('show');
5454
});
5555

56-
it('shows the invalid icon', async () => {
56+
it('shows the invalid icon', () => {
5757
const { getByRole } = render(component);
58-
const validStatusElement = await getByRole('status', { name: 'Input:invalid' });
58+
const validStatusElement = getByRole('status', { name: 'Input:invalid' });
5959
expect(validStatusElement).not.toBeNull();
6060
});
6161

62-
it('shows the input as invalid', async () => {
62+
it('shows the input as invalid', () => {
6363
const { getByRole } = render(component);
64-
const errorElement = await getByRole('textbox');
64+
const errorElement = getByRole('textbox');
6565
expect(errorElement).not.toHaveClass('confirmed');
6666
expect(errorElement).toHaveClass('inputError');
6767
});
@@ -75,9 +75,9 @@ describe('Barcelona Input', () => {
7575
expect(instance.toJSON()!).toMatchSnapshot();
7676
});
7777

78-
it('does not show the error message', async () => {
78+
it('does not show the error message', () => {
7979
const { getByRole } = render(component);
80-
const errorElement = await getByRole('alert');
80+
const errorElement = getByRole('alert');
8181
expect(errorElement).not.toHaveClass('show');
8282
});
8383
});
@@ -90,15 +90,15 @@ describe('Barcelona Input', () => {
9090
expect(instance.toJSON()).toMatchSnapshot();
9191
});
9292

93-
it('shows the error message', async () => {
93+
it('shows the error message', () => {
9494
const { getByRole } = render(component);
95-
const errorElement = await getByRole('alert');
95+
const errorElement = getByRole('alert');
9696
expect(errorElement).toHaveClass('show');
9797
});
9898

99-
it('shows the invalid icon', async () => {
99+
it('shows the invalid icon', () => {
100100
const { getByRole } = render(component);
101-
const validStatusElement = await getByRole('status', { name: 'Input:invalid' });
101+
const validStatusElement = getByRole('status', { name: 'Input:invalid' });
102102
expect(validStatusElement).not.toBeNull();
103103
});
104104
});

cookbook-react/src/recipes/inputs/barcelona/index.tsx

+4-8
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ interface Props {
1919

2020
function Input({
2121
name,
22-
label,
22+
// TODO: Remove this default value in a real app
23+
label = 'Label',
2324
disabled,
2425
error,
2526
onChange,
2627
confirmable = true,
27-
placeholder,
28+
// TODO: Remove this default value in a real app
29+
placeholder = 'example@',
2830
type = 'text'
2931
}: Props) {
3032
return (
@@ -72,10 +74,4 @@ function Input({
7274
);
7375
}
7476

75-
// For example purposes, in a real app remove this.
76-
Input.defaultProps = {
77-
label: 'Label',
78-
placeholder: 'example@'
79-
};
80-
8177
export default Input;

cookbook-react/src/recipes/lists/paginated/screens/ListExample/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ function ListExample() {
1919
i18next.t('ListExample:error')
2020
) : (
2121
<>
22-
{list?.page?.map(item => (
22+
{list?.page?.map((item) => (
2323
<div key={item} className={styles.item}>
2424
{item}
2525
</div>
2626
))}
2727
<Paginator
2828
pageCount={list?.totalPages}
29-
onPageChange={currentPage => getPage({ page: currentPage.selected + 1 })}
29+
onPageChange={(currentPage) => getPage({ page: currentPage.selected + 1 })}
3030
/>
3131
</>
3232
)}

cookbook-react/src/recipes/screens/login/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jest.mock('app/contexts/UserContext/reducer', () => ({
1919

2020
jest.mock('services/AuthServices', () => ({
2121
login: () =>
22-
new Promise(resolve =>
22+
new Promise((resolve) =>
2323
resolve({
2424
ok: true,
2525
data: { sessionToken: 'token', id: 1234 },

cookbook-react/src/recipes/screens/login/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function LoginContainer() {
3232

3333
const [, loading, loginError, loginRequest] = useLazyRequest({
3434
request: (credentials: Credentials) => login(credentials),
35-
withPostSuccess: response => {
35+
withPostSuccess: (response) => {
3636
const userResponse = response as User;
3737
dispatch(actionCreators.setUser(userResponse));
3838
setCurrentUser(userResponse);

0 commit comments

Comments
 (0)