Skip to content

Commit b8ca73b

Browse files
update rn, fix eslint, ts errors (#1655)
* update react-native to 0.69.5, add eslint, autofix src/components * fix lint errors Co-authored-by: Artsiom Grintsevich <greenfrvr@gmail.com>
1 parent 962cfb0 commit b8ca73b

File tree

302 files changed

+12679
-8347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+12679
-8347
lines changed

.eslintrc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
plugins: [ '@typescript-eslint' ],
5+
overrides: [
6+
{
7+
files: [ '*.ts', '*.tsx' ],
8+
rules: {
9+
'@typescript-eslint/no-shadow': [ 'error' ],
10+
'no-shadow': 'off',
11+
'no-undef': 'off',
12+
'react-native/no-raw-text': 'off',
13+
},
14+
extends: [
15+
'akveo/react-native:recommended',
16+
],
17+
},
18+
],
19+
parserOptions: {
20+
project: [ './tsconfig.json' ],
21+
sourceType: 'module',
22+
},
23+
settings: {
24+
react: {
25+
version: '18.0.0',
26+
},
27+
},
28+
ignorePatterns: ["src/template-js", "src/template-ts"]
29+
};

package.json

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,50 +19,56 @@
1919
"demo": "yarn --cwd ../kittenTricks",
2020
"build": "gulp build",
2121
"clean": "rimraf ./dist",
22-
"lint": "tslint -c ./tslint.json ./src/**/*.{ts,tsx}",
22+
"lint": "eslint -c .eslintrc.js ./src",
2323
"test": "jest",
2424
"parse-docs": "gulp parse-docs",
2525
"bump-version": "gulp bump-version && conventional-changelog -i CHANGELOG.md -s",
2626
"publish-docs": "npm run parse-docs && gulp publish-docs",
2727
"publish-packages": "gulp publish-packages"
2828
},
29+
"dependencies": {
30+
"react": "18.0.0",
31+
"react-native": "0.69.5"
32+
},
2933
"devDependencies": {
30-
"@babel/core": "^7.6.2",
31-
"@babel/plugin-proposal-decorators": "^7.6.2",
34+
"@babel/core": "^7.12.9",
35+
"@babel/plugin-proposal-decorators": "^7.18.10",
36+
"@babel/runtime": "^7.12.5",
3237
"@eva-design/eva": "^2.1.1",
3338
"@eva-design/material": "^2.1.1",
39+
"@react-native-community/eslint-config": "^2.0.0",
40+
"@tsconfig/react-native": "^2.0.2",
3441
"@types/gulp": "ts3.8",
3542
"@types/gulp-replace": "ts3.8",
36-
"@types/jest": "ts3.8",
37-
"@types/lodash.merge": "ts3.8",
38-
"@types/react-native": "ts3.8",
39-
"@types/react-test-renderer": "ts3.8",
40-
"@types/rimraf": "ts3.8",
41-
"babel-jest": "^24.9.0",
42-
"change-case": "^3.1.0",
43+
"@types/jest": "^26.0.23",
44+
"@types/lodash.merge": "^4.6.7",
45+
"@types/react-native": "^0.69.5",
46+
"@types/react-test-renderer": "^18.0.0",
47+
"@types/rimraf": "^3.0.2",
48+
"@typescript-eslint/eslint-plugin": "^5.29.0",
49+
"@typescript-eslint/parser": "^5.29.0",
50+
"babel-jest": "^26.6.3",
51+
"change-case": "^4.1.2",
4352
"conventional-changelog-cli": "^2.0.21",
4453
"coveralls": "^3.0.2",
4554
"doc-prsr": "^2.2.4",
55+
"eslint": "^7.32.0",
56+
"eslint-config-akveo": "^1.0.1",
57+
"eslint-plugin-react-native": "^4.0.0",
4658
"gulp": "^4.0.2",
4759
"gulp-typedoc": "^2.2.3",
4860
"husky": "^1.1.2",
4961
"jest": "^24.9.0",
50-
"metro-react-native-babel-preset": "^0.56.0",
51-
"react": "~16.9.0",
52-
"react-native": "~0.61.4",
62+
"metro-react-native-babel-preset": "^0.70.3",
5363
"react-native-svg": "~9.13.6",
5464
"react-native-testing-library": "^1.12.0",
55-
"react-test-renderer": "16.9.0",
65+
"react-test-renderer": "18.0.0",
5666
"rimraf": "^2.6.2",
5767
"ts-node": "^3.2.2",
58-
"tscpaths": "0.0.9",
59-
"tslint": "^5.12.1",
6068
"typedoc": "^0.15.3",
61-
"typescript": "^3.8.2"
69+
"typescript": "4.4.4"
6270
},
6371
"resolutions": {
64-
"react": "~16.9.0",
65-
"react-native": "~0.61.5",
66-
"react-native-svg": "~9.13.3"
72+
"@types/react": "^18.0.17"
6773
}
68-
}
74+
}

scripts/create-doc-app-navigation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
3-
import { pascal } from 'change-case';
3+
import { pascalCase } from 'change-case';
44

55
interface ShowcaseMap {
66
[componentName: string]: ComponentShowcase;
@@ -63,7 +63,7 @@ const createComponentShowcase = (showcasePath: string, component: string): Compo
6363
const showcaseFiles: string[] = fs.readdirSync(path.resolve(showcasePath, component));
6464

6565
return showcaseFiles.reduce((showcaseAcc: ComponentShowcase, showcaseFile: string) => {
66-
const routeName: string = pascal(`${showcaseFile.split('.component.tsx')[0]}`);
66+
const routeName: string = pascalCase(`${showcaseFile.split('.component.tsx')[0]}`);
6767
const showcaseInfo: ShowcaseInfo = { name: `${routeName}Showcase`, routeName, path: showcaseFile };
6868
return { ...showcaseAcc, showcases: [...showcaseAcc.showcases, showcaseInfo] };
6969
}, { showcases: [] });

src/components/devsupport/components/falsyFC/falsyFC.component.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22

3-
export type RenderFCProp<Props = {}> = (props?: Props) => React.ReactElement;
3+
export type RenderFCProp<Props> = (props?: Props) => React.ReactElement;
44

5-
export type RenderProp<Props = {}> = RenderFCProp<Props> | React.ReactElement
5+
export type RenderProp<Props> = RenderFCProp<Props> | React.ReactElement;
66

7-
export type FalsyFCProps<Props = {}> = Props & {
7+
export type FalsyFCProps<Props> = Props & {
88
component?: RenderProp<Props>;
99
fallback?: React.ReactElement;
1010
};
@@ -36,7 +36,7 @@ export type FalsyFCProps<Props = {}> = Props & {
3636
* );
3737
* ```
3838
*/
39-
export class FalsyFC<Props = {}> extends React.Component<FalsyFCProps<Props>> {
39+
export class FalsyFC<Props> extends React.Component<FalsyFCProps<Props>> {
4040

4141
public render(): React.ReactElement {
4242
const { component, fallback, ...props } = this.props;

src/components/devsupport/components/falsyFC/falsyFC.spec.tsx

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,62 @@ import { Text } from 'react-native';
33
import { render } from 'react-native-testing-library';
44
import { FalsyFC } from './falsyFC.component';
55

6-
it('should render nothing', function () {
7-
const component = render(<FalsyFC/>);
6+
const styles = { color: 'red' };
7+
8+
it('should render nothing', () => {
9+
const component = render(<FalsyFC />);
810
expect(component.toJSON()).toEqual(null);
911
});
1012

1113
it('should render provided function component', () => {
1214
const component = render(
13-
<FalsyFC style={{ color: 'red' }} component={props => <Text {...props}>I love Babel</Text>}/>,
15+
<FalsyFC
16+
style={styles}
17+
component={props => (
18+
<Text {...props}>
19+
I love Babel
20+
</Text>
21+
)}
22+
/>,
1423
);
1524

1625
const textComponent = component.getByText('I love Babel');
1726

1827
expect(textComponent).toBeTruthy();
19-
expect(textComponent.props.style).toEqual({
20-
color: 'red',
21-
});
28+
expect(textComponent.props.style).toEqual(styles);
2229
});
2330

2431
it('should render provided function component with hooks', () => {
25-
const HookComponent = (props) => {
32+
const HookComponent = (props): React.ReactElement => {
2633
const state = React.useState(1);
2734
return (
28-
<Text {...props}>I love Babel {state}</Text>
35+
<Text {...props}>
36+
I love Babel
37+
{state}
38+
</Text>
2939
);
3040
};
3141

3242
const component = render(
33-
<FalsyFC style={{ color: 'red' }} component={props => <HookComponent {...props}/>}/>,
43+
<FalsyFC
44+
style={styles}
45+
component={props => <HookComponent {...props} />}
46+
/>,
3447
);
3548

3649
const textComponent = component.getByText('I love Babel 1');
3750
expect(textComponent).toBeTruthy();
3851
});
3952

40-
it('should render fallback component', function () {
53+
it('should render fallback component', () => {
4154
const component = render(
4255
<FalsyFC
4356
component={null}
44-
fallback={<Text>I love Babel</Text>}
57+
fallback={(
58+
<Text>
59+
I love Babel
60+
</Text>
61+
)}
4562
/>,
4663
);
4764

@@ -50,15 +67,19 @@ it('should render fallback component', function () {
5067
expect(textComponent).toBeTruthy();
5168
});
5269

53-
it('should be able to render components with hooks', function () {
54-
const ComponentWithHooks = () => {
55-
const [text, setText ] = React.useState('');
70+
it('should be able to render components with hooks', () => {
71+
const ComponentWithHooks = (): React.ReactElement => {
72+
const [text, setText] = React.useState('');
5673

5774
React.useEffect(() => {
5875
setText('I love Babel');
5976
}, []);
6077

61-
return <Text>{text}</Text>;
78+
return (
79+
<Text>
80+
{text}
81+
</Text>
82+
);
6283
};
6384

6485
const component = render(
@@ -72,21 +93,23 @@ it('should be able to render components with hooks', function () {
7293
expect(textComponent).toBeTruthy();
7394
});
7495

75-
it('should be able to render valid element', function () {
76-
const ComponentWithHooks = (props) => {
77-
return <Text {...props}>I love Babel</Text>;
96+
it('should be able to render valid element', () => {
97+
const ComponentWithHooks = (props): React.ReactElement => {
98+
return (
99+
<Text {...props}>
100+
I love Babel
101+
</Text>
102+
);
78103
};
79104

80105
const component = render(
81106
<FalsyFC
82-
style={{ color: 'red' }}
107+
style={styles}
83108
component={<ComponentWithHooks />}
84109
/>,
85110
);
86111

87112
const textComponent = component.getByText('I love Babel');
88113
expect(textComponent).toBeTruthy();
89-
expect(textComponent.props.style).toEqual({
90-
color: 'red',
91-
});
114+
expect(textComponent.props.style).toEqual(styles);
92115
});

0 commit comments

Comments
 (0)