Skip to content

Commit 574d12d

Browse files
committed
upgrade react-native 0.81.1
upgrade eslint 8 to 9
1 parent 5a81c8c commit 574d12d

File tree

13 files changed

+827
-493
lines changed

13 files changed

+827
-493
lines changed

.eslintignore

Lines changed: 0 additions & 11 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

.gitignore

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ coverage/
6060

6161
# Yarn
6262
example/.yarn/*
63-
.yarn/*
64-
!.yarn/patches
65-
!.yarn/plugins
66-
!.yarn/releases
67-
!.yarn/sdks
68-
!.yarn/versions
63+
.yarn/install-state.gz
64+
.yarn/patches
65+
.yarn/plugins
66+
.yarn/releases
67+
.yarn/sdks
68+
.yarn/versions
6969

7070
# Expo
7171
example/.expo/

.npmignore

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ npm-debug.log
1515
.npmignore
1616
.prettierignore
1717
.prettierrc.js
18-
.eslintignore
19-
.eslintrc.js
18+
eslint.config.mjs
2019
babel.config.js
2120
jest.config.js
2221
tsconfig.json
2322
.yarnrc.yml
2423

2524
# Yarn
26-
example/.yarn/*
27-
.yarn/*
28-
!.yarn/patches
29-
!.yarn/plugins
30-
!.yarn/releases
31-
!.yarn/sdks
32-
!.yarn/versions
25+
.yarn/install-state.gz
26+
.yarn/patches
27+
.yarn/plugins
28+
.yarn/releases
29+
.yarn/sdks
30+
.yarn/versions

.prettierignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
node_modules/
2-
example/
32
assets/
43
coverage/
54
.github/
65
yarn.lock
76
LICENSE
87
.gitignore
98
.npmignore
10-
.eslintignore
119
tsconfig.json
1210
.yarnrc.yml

.prettierrc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module.exports = {
22
arrowParens: 'avoid',
3-
bracketSameLine: true,
4-
bracketSpacing: false,
53
singleQuote: true,
64
trailingComma: 'all',
75
};

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@
3535

3636
```javascript
3737
import React from 'react';
38-
import {Animated} from 'react-native';
38+
import { Animated } from 'react-native';
3939
import ThumbnailSelector from 'react-native-thumbnail-selector';
4040

4141
const thumbnails = [
4242
{
4343
caption: 'react-native',
44-
imageSrc: {uri: 'https://reactnative.dev/img/pwa/manifest-icon-512.png'},
44+
imageSrc: { uri: 'https://reactnative.dev/img/pwa/manifest-icon-512.png' },
4545
},
4646
{
4747
caption: 'Dolore do magna ullamco nisi quis.',
48-
imageSrc: {uri: 'https://reactnative.dev/img/pwa/manifest-icon-512.png'},
48+
imageSrc: { uri: 'https://reactnative.dev/img/pwa/manifest-icon-512.png' },
4949
},
5050
];
5151

5252
function Example() {
5353
// use toggle to show and hide ThumbnailSelector
54-
let toggle = () => new Promise<Animated.EndResult>(res => res);
54+
let toggle = () => new Promise() < Animated.EndResult > (res => res);
5555

5656
return (
5757
<ThumbnailSelector

ThumbnailSelector.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useRef, useState} from 'react';
1+
import React from 'react';
22
import {
33
Text,
44
FlatList,
@@ -58,14 +58,14 @@ const ThumbnailSelector: React.FunctionComponent<ThumbnailSelectorProps> = ({
5858
activeColor = 'white',
5959
inactiveColor = 'black',
6060
imageProps = {
61-
style: {width: 136, height: 136, borderWidth: 1},
61+
style: { width: 136, height: 136, borderWidth: 1 },
6262
},
6363
textProps = {
64-
style: {fontSize: 16, textAlign: 'center', fontWeight: 'bold'},
64+
style: { fontSize: 16, textAlign: 'center', fontWeight: 'bold' },
6565
numberOfLines: 1,
6666
},
6767
touchableOpacityProps = {
68-
style: {padding: 8},
68+
style: { padding: 8 },
6969
},
7070
animatedViewStyle = {
7171
elevation: 1,
@@ -80,14 +80,14 @@ const ThumbnailSelector: React.FunctionComponent<ThumbnailSelectorProps> = ({
8080
friction: 9,
8181
useNativeDriver: false,
8282
},
83-
flatListViewStyle = {backgroundColor: 'grey', padding: 8},
83+
flatListViewStyle = { backgroundColor: 'grey', padding: 8 },
8484
animatedViewTestID = 'ThumbnailSelector',
8585
}) => {
8686
const window = useWindowDimensions();
87-
const [itemIndex, setItemIndex] = useState(initialIndex);
88-
const [animViewHeight, setAnimViewHeight] = useState(0);
89-
const animatedValue = useRef(new Animated.Value(0));
90-
const toValue = useRef(animationConfig.toValue);
87+
const [itemIndex, setItemIndex] = React.useState(initialIndex);
88+
const [animViewHeight, setAnimViewHeight] = React.useState(0);
89+
const animatedValue = React.useRef(new Animated.Value(0));
90+
const toValue = React.useRef(animationConfig.toValue);
9191

9292
function _toggle(): Promise<Animated.EndResult> {
9393
if (toValue.current) {
@@ -106,7 +106,7 @@ const ThumbnailSelector: React.FunctionComponent<ThumbnailSelectorProps> = ({
106106
}
107107

108108
function _renderItem(obj: ThumbnailItemIndex): React.JSX.Element {
109-
const {item, index} = obj;
109+
const { item, index } = obj;
110110
if (renderThumbnail) {
111111
return renderThumbnail(item, index, onSelect);
112112
}
@@ -127,14 +127,15 @@ const ThumbnailSelector: React.FunctionComponent<ThumbnailSelectorProps> = ({
127127
if (onSelect) {
128128
onSelect(item, index);
129129
}
130-
}}>
130+
}}
131+
>
131132
<Image
132133
{...imageProps}
133-
style={[{borderColor: color}, imageProps.style]}
134+
style={[{ borderColor: color }, imageProps.style]}
134135
source={item.imageSrc}
135136
/>
136137
{caption && (
137-
<Text {...textProps} style={[{color}, textProps.style]}>
138+
<Text {...textProps} style={[{ color }, textProps.style]}>
138139
{caption}
139140
</Text>
140141
)}
@@ -143,7 +144,7 @@ const ThumbnailSelector: React.FunctionComponent<ThumbnailSelectorProps> = ({
143144
}
144145

145146
function _onLayout(event: LayoutChangeEvent): void {
146-
const {height} = event.nativeEvent.layout;
147+
const { height } = event.nativeEvent.layout;
147148
if (animViewHeight !== height) {
148149
setAnimViewHeight(height);
149150
}
@@ -171,7 +172,8 @@ const ThumbnailSelector: React.FunctionComponent<ThumbnailSelectorProps> = ({
171172
<Animated.View
172173
testID={animatedViewTestID}
173174
style={_getAnimViewStyle()}
174-
onLayout={_onLayout}>
175+
onLayout={_onLayout}
176+
>
175177
<FlatList
176178
style={flatListViewStyle}
177179
data={thumbnails}

__tests__/ThumbnailSelector.test.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React, {act} from 'react';
2-
import {Text} from 'react-native';
1+
import React, { act } from 'react';
2+
import { Text } from 'react-native';
33
import {
44
render,
55
fireEvent,
66
screen,
77
cleanup,
88
} from '@testing-library/react-native';
9-
import ThumbnailSelector, {ThumbnailItem} from '../ThumbnailSelector';
9+
import ThumbnailSelector, { ThumbnailItem } from '../ThumbnailSelector';
1010

1111
describe('ThumbnailSelector', () => {
1212
afterEach(cleanup);
@@ -26,19 +26,19 @@ describe('ThumbnailSelector', () => {
2626
const thumbnails = [
2727
{
2828
caption: 'react-native',
29-
imageSrc: {uri: 'https://reactnative.dev/img/tiny_logo.png'},
29+
imageSrc: { uri: 'https://reactnative.dev/img/tiny_logo.png' },
3030
},
3131
{
3232
caption: 'New York City',
33-
imageSrc: {uri: 'https://reactnative.dev/img/tiny_logo.png'},
33+
imageSrc: { uri: 'https://reactnative.dev/img/tiny_logo.png' },
3434
},
3535
{
3636
caption:
3737
'Elit cupidatat qui ea deserunt reprehenderit sit velit eu aliqua incididunt sit elit reprehenderit.',
38-
imageSrc: {uri: 'https://reactnative.dev/img/tiny_logo.png'},
38+
imageSrc: { uri: 'https://reactnative.dev/img/tiny_logo.png' },
3939
},
4040
{
41-
imageSrc: {uri: 'https://reactnative.dev/img/tiny_logo.png'},
41+
imageSrc: { uri: 'https://reactnative.dev/img/tiny_logo.png' },
4242
},
4343
];
4444

@@ -56,7 +56,7 @@ describe('ThumbnailSelector', () => {
5656

5757
test('onSelect prop', async () => {
5858
let toggle = () => {};
59-
let onSelect = jest.fn();
59+
const onSelect = jest.fn();
6060
const component = render(
6161
<ThumbnailSelector
6262
thumbnails={thumbnails}
@@ -107,11 +107,11 @@ describe('ThumbnailSelector', () => {
107107
expect(selector).toBeDefined();
108108

109109
fireEvent(selector, 'layout', {
110-
nativeEvent: {layout: {height: 0}},
110+
nativeEvent: { layout: { height: 0 } },
111111
});
112112

113113
fireEvent(selector, 'layout', {
114-
nativeEvent: {layout: {height: 100}},
114+
nativeEvent: { layout: { height: 100 } },
115115
});
116116
});
117117

eslint.config.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import tseslint from 'typescript-eslint';
4+
import { defineConfig, globalIgnores } from 'eslint/config';
5+
6+
export default defineConfig([
7+
{
8+
files: ['**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
9+
plugins: { js },
10+
extends: ['js/recommended'],
11+
languageOptions: { globals: globals.browser },
12+
},
13+
tseslint.configs.recommended,
14+
globalIgnores([
15+
'node_modules/*',
16+
'assets/*',
17+
'coverage/*',
18+
'yarn.lock',
19+
'LICENSE',
20+
'.gitignore',
21+
'.npmignore',
22+
'.prettierrc.js',
23+
'yarnrc.yml',
24+
'jest.config.js',
25+
'babel.config.js',
26+
]),
27+
]);

0 commit comments

Comments
 (0)