Skip to content

Commit a4e92bb

Browse files
chore: Add FlowType Check (#35)
* chore(deps-dev): bump jest from 25.2.4 to 25.2.7 Bumps [jest](https://github.com/facebook/jest) from 25.2.4 to 25.2.7. - [Release notes](https://github.com/facebook/jest/releases) - [Changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md) - [Commits](jestjs/jest@v25.2.4...v25.2.7) Signed-off-by: dependabot-preview[bot] <[email protected]> * chore(deps-dev): bump @types/react from 16.9.27 to 16.9.32 Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 16.9.27 to 16.9.32. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react) Signed-off-by: dependabot-preview[bot] <[email protected]> * chore(deps-dev): bump babel-jest from 25.1.0 to 25.2.6 Bumps [babel-jest](https://github.com/facebook/jest/tree/HEAD/packages/babel-jest) from 25.1.0 to 25.2.6. - [Release notes](https://github.com/facebook/jest/releases) - [Changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/facebook/jest/commits/v25.2.6/packages/babel-jest) Signed-off-by: dependabot-preview[bot] <[email protected]> * feat: add flow typecheck * Update js/RNCProgressBarAndroid.android.js Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
1 parent c36b520 commit a4e92bb

File tree

8 files changed

+427
-527
lines changed

8 files changed

+427
-527
lines changed

.circleci/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ aliases:
2525
name: Jest Unit Tests
2626
command: yarn test
2727

28+
- &flow
29+
name: Flow Type Check
30+
command: yarn flow
31+
32+
2833
# -------------------------
2934
# JOBS
3035
# -------------------------
@@ -73,6 +78,15 @@ jobs:
7378
- attach_workspace:
7479
at: .
7580
- run: *jest
81+
82+
flow:
83+
executor:
84+
name: rn/linux_js
85+
node_version: '10'
86+
steps:
87+
- attach_workspace:
88+
at: .
89+
- run: *flow
7690

7791
android-compile:
7892
executor: rn/linux_android
@@ -130,6 +144,9 @@ workflows:
130144
- jest:
131145
requires:
132146
- linux-checkout
147+
- flow:
148+
requires:
149+
- linux-checkout
133150
- android-compile:
134151
requires:
135152
- linux-checkout

.flowconfig

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
.*/Libraries/react-native/React.js
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
1514

16-
; Ignore polyfills
17-
.*/Libraries/polyfills/.*
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
17+
18+
; Ignore example folder
19+
.*/example/.*
1820

19-
; Ignore metro
20-
.*/node_modules/metro/.*
21+
22+
[untyped]
23+
.*/node_modules/@react-native-community/cli/.*/.*
2124

2225
[include]
2326

@@ -31,39 +34,46 @@ emoji=true
3134
esproposal.optional_chaining=enable
3235
esproposal.nullish_coalescing=enable
3336

34-
module.system=haste
35-
module.system.haste.use_name_reducers=true
36-
# get basename
37-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
38-
# strip .js or .js.flow suffix
39-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
40-
# strip .ios suffix
41-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
42-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
43-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
44-
module.system.haste.paths.blacklist=.*/__tests__/.*
45-
module.system.haste.paths.blacklist=.*/__mocks__/.*
46-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
47-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
37+
module.file_ext=.js
38+
module.file_ext=.json
39+
module.file_ext=.ios.js
4840

4941
munge_underscores=true
5042

51-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
52-
53-
module.file_ext=.js
54-
module.file_ext=.jsx
55-
module.file_ext=.json
56-
module.file_ext=.native.js
43+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
44+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
45+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
5746

5847
suppress_type=$FlowIssue
5948
suppress_type=$FlowFixMe
6049
suppress_type=$FlowFixMeProps
6150
suppress_type=$FlowFixMeState
6251

63-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
64-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
65-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
53+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
6654
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
6755

56+
[lints]
57+
sketchy-null-number=warn
58+
sketchy-null-mixed=warn
59+
sketchy-number=warn
60+
untyped-type-import=warn
61+
nonstrict-import=warn
62+
deprecated-type=warn
63+
unsafe-getters-setters=warn
64+
inexact-spread=warn
65+
unnecessary-invariant=warn
66+
signature-verification-failure=warn
67+
deprecated-utility=error
68+
69+
[strict]
70+
deprecated-type
71+
nonstrict-import
72+
sketchy-null
73+
unclear-type
74+
unsafe-getters-setters
75+
untyped-import
76+
untyped-type-import
77+
6878
[version]
69-
^0.92.0
79+
^0.105.0

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: ["module:metro-react-native-babel-preset"],
2+
presets: ['module:metro-react-native-babel-preset'],
33
};

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ export type ProgressBarAndroidProps = {
3131
*/
3232
animating?: boolean
3333
}
34-
export class ProgressBarAndroid extends React.Component<ProgressBarAndroidProps> {}
34+
export class ProgressBar extends React.Component<ProgressBarAndroidProps> {}

js/RNCProgressBarAndroid.android.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import React from 'react';
1313

1414
import ProgressBarAndroidNativeComponent from './RNCProgressBarAndroidNativeComponent';
1515

16-
import type {ViewProps} from 'react-native';
16+
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
1717

1818
export type ProgressBarAndroidProps = $ReadOnly<{|
1919
...ViewProps,
@@ -87,16 +87,10 @@ const ProgressBarAndroid = (
8787

8888
const ProgressBarAndroidToExport = React.forwardRef(ProgressBarAndroid);
8989

90-
/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an
91-
* error found when Flow v0.89 was deployed. To see the error, delete this
92-
* comment and run Flow. */
9390
ProgressBarAndroidToExport.defaultProps = {
9491
styleAttr: 'Normal',
9592
indeterminate: true,
9693
animating: true,
9794
};
9895

99-
/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an
100-
* error found when Flow v0.89 was deployed. To see the error, delete this
101-
* comment and run Flow. */
10296
export default (ProgressBarAndroidToExport: ProgressBarAndroidNativeComponent);

js/RNCProgressBarAndroidNativeComponent.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,27 @@
99

1010
'use strict';
1111

12-
import {requireNativeComponent} from 'react-native';
13-
14-
import type {ViewProps, NativeComponent} from 'react-native';
12+
import type {
13+
Double,
14+
WithDefault,
15+
} from 'react-native/Libraries/Types/CodegenTypes';
16+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
17+
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
18+
import type {NativeComponentType} from 'react-native/Libraries/Utilities/codegenNativeComponent';
1519

1620
type NativeProps = $ReadOnly<{|
1721
...ViewProps,
22+
23+
//Props
1824
styleAttr?: string,
1925
typeAttr?: string,
2026
indeterminate: boolean,
21-
progress?: number,
22-
animating?: ?boolean,
27+
progress?: WithDefault<Double, 0>,
28+
animating?: WithDefault<boolean, true>,
2329
color?: ?string,
2430
testID?: ?string,
2531
|}>;
2632

27-
type ProgressBarAndroidType = Class<NativeComponent<NativeProps>>;
28-
29-
module.exports = ((requireNativeComponent(
33+
export default (codegenNativeComponent<NativeProps>(
3034
'AndroidProgressBar',
31-
): any): ProgressBarAndroidType);
35+
): NativeComponentType<NativeProps>);

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"build:android": "cd example/android && ./gradlew clean assembleDebug",
1111
"test": "jest",
1212
"lint": "eslint 'js/**/*.js' 'example/**/*.js'",
13-
"type-check": "tsc --noEmit"
13+
"type-check": "tsc --noEmit",
14+
"flow": "flow"
1415
},
1516
"homepage": "https://github.com/react-native-community/react-native-progress-bar-android#readme",
1617
"repository": {
@@ -51,6 +52,7 @@
5152
"babel-jest": "^25.1.0",
5253
"babel-plugin-module-resolver": "^3.2.0",
5354
"eslint": "6.8.0",
55+
"flow-bin": "0.105.2",
5456
"jest": "^25.2.3",
5557
"metro-react-native-babel-preset": "^0.58.0",
5658
"react": "16.9.0",

0 commit comments

Comments
 (0)