Skip to content

Commit 11e6f9a

Browse files
committed
fix: resolve npm conflict
1 parent 1895a65 commit 11e6f9a

13 files changed

+1218
-1445
lines changed

template/eslint.config.mjs

+11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import eslintConfigPrettier from 'eslint-config-prettier';
22
import importPlugin from 'eslint-plugin-import';
3+
import jest from 'eslint-plugin-jest';
34
import perfectionist from 'eslint-plugin-perfectionist';
45
import react from 'eslint-plugin-react';
56
import reactHooks from 'eslint-plugin-react-hooks';
67
import reactRefresh from 'eslint-plugin-react-refresh';
8+
import testingLibrary from 'eslint-plugin-testing-library';
79
import unicorn from 'eslint-plugin-unicorn';
810

911
const ERROR = 2;
@@ -24,6 +26,7 @@ export default tseslint.config(
2426
react.configs.flat.all,
2527
react.configs.flat['jsx-runtime'],
2628
reactRefresh.configs.recommended,
29+
testingLibrary.configs['flat/react'],
2730
eslintConfigPrettier, // last
2831
{
2932
languageOptions: {
@@ -55,6 +58,7 @@ export default tseslint.config(
5558
'react-hooks': reactHooks,
5659
},
5760
rules: {
61+
...reactHooks.configs.recommended.rules,
5862
'@typescript-eslint/consistent-type-definitions': [ERROR, 'type'],
5963
'@typescript-eslint/dot-notation': [ERROR, { allowKeywords: true }],
6064
'@typescript-eslint/no-empty-function': OFF,
@@ -142,6 +146,13 @@ export default tseslint.config(
142146
'unicorn/prefer-module': OFF,
143147
},
144148
},
149+
{
150+
files: ['**/*.spec.{js,ts,jsx,tsx}', '**/*.test.{js,ts,jsx,tsx}'],
151+
...jest.configs['flat/recommended'],
152+
rules: {
153+
...jest.configs['flat/recommended'].rules,
154+
},
155+
},
145156
{
146157
ignores: ['plugins/**'],
147158
},

template/jest.setup.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import './__mocks__/libs';
2-
import './__mocks__/getAssetsContext';
1+
import './tests/__mocks__/libs';
2+
import './tests/__mocks__/getAssetsContext';

template/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"eslint-plugin-react-refresh": "^0.4.19",
6969
"eslint-plugin-testing-library": "^7.1.1",
7070
"eslint-plugin-unicorn": "^58.0.0",
71-
"eslint-plugin-unused-imports": "^4.1.4",
7271
"jest": "^29.7.0",
7372
"prettier": "^3.5.3",
7473
"react-native-svg-transformer": "^1.5.0",

template/src/components/atoms/Skeleton/Skeleton.test.tsx

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import TestAppWrapper from '@/../__mocks__/TestAppWrapper';
2-
import { render } from '@testing-library/react-native';
1+
import TestAppWrapper from '@/../tests/TestAppWrapper';
2+
import { render, screen } from '@testing-library/react-native';
33
import { Text } from 'react-native';
44

55
import SkeletonLoader from './Skeleton';
@@ -12,32 +12,31 @@ describe('SkeletonLoader', () => {
1212
});
1313

1414
it('renders children when not loading', () => {
15-
const { getByText } = render(
15+
render(
1616
<SkeletonLoader loading={false}>
1717
<Text>Loaded Content</Text>
1818
</SkeletonLoader>,
1919
{
2020
wrapper: TestAppWrapper,
2121
},
2222
);
23-
expect(getByText('Loaded Content')).toBeTruthy();
23+
expect(screen.getByText('Loaded Content')).toBeTruthy();
2424
});
2525

2626
it('renders skeleton when loading', () => {
27-
const { getByTestId } = render(<SkeletonLoader loading />, {
27+
render(<SkeletonLoader loading />, {
2828
wrapper: TestAppWrapper,
2929
});
30-
const skeleton = getByTestId('skeleton-loader');
30+
const skeleton = screen.getByTestId('skeleton-loader');
3131
jest.advanceTimersByTime(WAIT);
3232
expect(skeleton).toBeTruthy();
3333
});
3434

3535
it('applies correct height and width', () => {
36-
const { getByTestId } = render(
37-
<SkeletonLoader height={50} loading width={100} />,
38-
{ wrapper: TestAppWrapper },
39-
);
40-
const skeleton = getByTestId('skeleton-loader');
36+
render(<SkeletonLoader height={50} loading width={100} />, {
37+
wrapper: TestAppWrapper,
38+
});
39+
const skeleton = screen.getByTestId('skeleton-loader');
4140

4241
const animatedStyle: {
4342
value: { opacity: number };

template/src/reactotron.config.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,13 @@ import type { ReactotronReactNative } from 'reactotron-react-native';
22

33
import Reactotron from 'reactotron-react-native';
44
import mmkvPlugin from 'reactotron-react-native-mmkv';
5-
import {
6-
QueryClientManager,
7-
reactotronReactQuery,
8-
} from 'reactotron-react-query';
95

106
import config from '../app.json';
11-
import { queryClient, storage } from './App';
12-
13-
const queryClientManager = new QueryClientManager({
14-
queryClient,
15-
});
7+
import { storage } from './App';
168

179
Reactotron.configure({
1810
name: config.name,
19-
onDisconnect: () => {
20-
queryClientManager.unsubscribe();
21-
},
2211
})
2312
.useReactNative()
2413
.use(mmkvPlugin<ReactotronReactNative>({ storage }))
25-
.use(reactotronReactQuery(queryClientManager))
2614
.connect();

template/src/theme/ThemeProvider/ThemeProvider.test.tsx

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fireEvent, render } from '@testing-library/react-native';
1+
import { fireEvent, render, screen } from '@testing-library/react-native';
22
import { Button, Text, View } from 'react-native';
33
import { MMKV } from 'react-native-mmkv';
44

@@ -28,45 +28,40 @@ describe('ThemeProvider', () => {
2828
});
2929

3030
it('initializes with the default theme when no theme is defined in storage', () => {
31-
const { getByTestId } = render(
31+
render(
3232
<ThemeProvider storage={storage}>
3333
<TestChildComponent />
3434
</ThemeProvider>,
3535
);
36-
const themeContext = getByTestId('theme-variant');
37-
3836
// Assert that the theme context is initialized with 'default'
39-
expect(themeContext.children[0]).toBe('default');
37+
expect(screen.getByText('default')).toBeTruthy();
4038
});
4139

4240
it('loads the theme from storage if defined', () => {
4341
storage.set('theme', 'dark');
4442

45-
const { getByTestId } = render(
43+
render(
4644
<ThemeProvider storage={storage}>
4745
<TestChildComponent />
4846
</ThemeProvider>,
4947
);
50-
const themeContext = getByTestId('theme-variant');
5148

5249
// Assert that the theme context is initialized with 'dark'
53-
expect(themeContext.children[0]).toBe('dark');
50+
expect(screen.getByText('dark')).toBeTruthy();
5451
});
5552

5653
it('changes the theme when calling changeTheme', () => {
57-
const { getByTestId } = render(
54+
render(
5855
<ThemeProvider storage={storage}>
5956
<TestChildComponent />
6057
</ThemeProvider>,
6158
);
62-
const themeContext = getByTestId('theme-variant');
63-
64-
expect(themeContext.children[0]).toBe('default');
6559

66-
// Change the theme to 'light'
67-
fireEvent.press(getByTestId('change-btn'));
60+
// Assert that the theme context is initialized with 'default'
61+
expect(screen.getByText('default')).toBeTruthy();
62+
fireEvent.press(screen.getByTestId('change-btn'));
6863

6964
// Assert that the theme has changed to 'light'
70-
expect(themeContext.children[0]).toBe('dark');
65+
expect(screen.getByText('dark')).toBeTruthy();
7166
});
7267
});

template/tsconfig.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
"noUnusedLocals": true
99
},
1010
"include": [
11-
"__mocks__/**/*",
11+
"tests/**/*",
1212
"./src/**/*",
1313
"index.d.ts",
1414
"*.mjs",
1515
".*.mjs",
1616
"*.js",
1717
".*.js",
1818
"*.ts",
19-
".prettierrc.mjs"
20-
],
19+
".prettierrc.mjs"
20+
],
2121
"exclude": ["node_modules", "_", "android", "ios"]
2222
}

0 commit comments

Comments
 (0)