Skip to content

Commit cc01e03

Browse files
author
Kai Guo
committed
CR feedback
1 parent 060cf02 commit cc01e03

File tree

5 files changed

+53
-50
lines changed

5 files changed

+53
-50
lines changed

.flowconfig

+40-37
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
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
1817

19-
; Ignore metro
20-
.*/node_modules/metro/.*
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
2120

2221
[include]
2322

@@ -31,42 +30,46 @@ emoji=true
3130
esproposal.optional_chaining=enable
3231
esproposal.nullish_coalescing=enable
3332

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/.*
33+
module.file_ext=.js
34+
module.file_ext=.json
35+
module.file_ext=.ios.js
4836

4937
munge_underscores=true
5038

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-
# Support the library import in examples
54-
module.name_mapper='^\@react-native-community/async-storage$' -> '<PROJECT_ROOT>/lib/AsyncStorage.js'
55-
56-
module.file_ext=.js
57-
module.file_ext=.jsx
58-
module.file_ext=.json
59-
module.file_ext=.native.js
39+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
40+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
41+
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'
6042

6143
suppress_type=$FlowIssue
6244
suppress_type=$FlowFixMe
6345
suppress_type=$FlowFixMeProps
6446
suppress_type=$FlowFixMeState
6547

66-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
67-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
68-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
6950
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
7051

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

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"detox": "12.6.1",
5555
"expo": "36.0.2",
5656
"eslint": "5.1.0",
57-
"flow-bin": "0.92.0",
57+
"flow-bin": "0.105.0",
5858
"jest": "24.8.0",
5959
"metro-react-native-babel-preset": "0.54.1",
6060
"react": "16.9.0",

windows/ReactNativeAsyncStorage/DBStorage.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ DBStorage::DBStorage() {
230230
}
231231

232232
DBStorage::~DBStorage() {
233-
decltype(m_action) action;
233+
decltype(m_tasks) tasks;
234234
{
235235
// If there is an in-progress async task, cancel it and wait on the
236236
// condition_variable for the async task to acknowledge cancellation by
237237
// nulling out m_action. Once m_action is null, it is safe to proceed
238238
// wth closing the DB connection
239239
winrt::slim_lock_guard guard{ m_lock };
240-
m_tasks.clear();
240+
swap(tasks, m_tasks);
241241
if (m_action) {
242242
m_action.Cancel();
243243
m_cv.wait(m_lock, [this]() { return m_action == nullptr; });

windows/ReactNativeAsyncStorage/RNCAsyncStorage.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace ReactNativeAsyncStorage
1717
REACT_METHOD(multiGet);
1818
void multiGet(std::vector<JSValue>& keys, std::function<void(JSValueArray const& errors, JSValueArray const& results)>&& callback) noexcept {
1919
dbStorage.AddTask(DBStorage::DBTask::Type::multiGet, std::move(keys),
20-
[callback](std::vector<JSValue> const& callbackParams) {
20+
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
2121
if (callbackParams.size() > 0) {
2222
auto& errors = callbackParams[0].AsArray();
2323
if (callbackParams.size() > 1) {
@@ -33,7 +33,7 @@ namespace ReactNativeAsyncStorage
3333
REACT_METHOD(multiSet);
3434
void multiSet(std::vector<JSValue>& pairs, std::function<void(JSValueArray const&)>&& callback) noexcept {
3535
dbStorage.AddTask(DBStorage::DBTask::Type::multiSet, std::move(pairs),
36-
[callback](std::vector<JSValue> const& callbackParams) {
36+
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
3737
if (callbackParams.size() > 0) {
3838
auto& errors = callbackParams[0].AsArray();
3939
callback(errors);
@@ -50,7 +50,7 @@ namespace ReactNativeAsyncStorage
5050
newValues.push_back(pair.AsArray()[1].AsString());
5151
}
5252

53-
multiGet(std::move(keys), [newValues, callback, this](JSValueArray const& errors, JSValueArray const& results) {
53+
multiGet(std::move(keys), [newValues{ std::move(newValues) }, callback{ std::move(callback) }, this](JSValueArray const& errors, JSValueArray const& results) {
5454
if (errors.size() > 0) {
5555
callback(errors);
5656
return;
@@ -88,7 +88,7 @@ namespace ReactNativeAsyncStorage
8888
}
8989
}
9090

91-
multiSet(std::move(mergedResults), [callback](JSValueArray const& errors) {
91+
multiSet(std::move(mergedResults), [callback{ std::move(callback) }](JSValueArray const& errors) {
9292
callback(errors);
9393
});
9494
});
@@ -97,7 +97,7 @@ namespace ReactNativeAsyncStorage
9797
REACT_METHOD(multiRemove);
9898
void multiRemove(std::vector<JSValue>& keys, std::function<void(JSValueArray const&)>&& callback) noexcept {
9999
dbStorage.AddTask(DBStorage::DBTask::Type::multiRemove, std::move(keys),
100-
[callback](std::vector<JSValue> const& callbackParams) {
100+
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
101101
if (callbackParams.size() > 0) {
102102
auto& errors = callbackParams[0].AsArray();
103103
callback(errors);
@@ -108,7 +108,7 @@ namespace ReactNativeAsyncStorage
108108
REACT_METHOD(getAllKeys);
109109
void getAllKeys(std::function<void(JSValueArray const& errors, JSValueArray const& keys)>&& callback) noexcept {
110110
dbStorage.AddTask(DBStorage::DBTask::Type::getAllKeys,
111-
[callback](std::vector<JSValue> const& callbackParams) {
111+
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
112112
if (callbackParams.size() > 0) {
113113
auto& errors = callbackParams[0].AsArray();
114114
if (callbackParams.size() > 1) {
@@ -124,7 +124,7 @@ namespace ReactNativeAsyncStorage
124124
REACT_METHOD(clear);
125125
void clear(std::function<void(JSValueArray const&)>&& callback) noexcept {
126126
dbStorage.AddTask(DBStorage::DBTask::Type::clear,
127-
[callback](std::vector<JSValue> const& callbackParams) {
127+
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
128128
if (callbackParams.size() > 0) {
129129
auto& errors = callbackParams[0].AsArray();
130130
callback(errors);

yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -6626,9 +6626,9 @@ p-limit@^2.0.0:
66266626
p-try "^2.0.0"
66276627

66286628
p-limit@^2.2.0:
6629-
version "2.2.2"
6630-
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.2.tgz#61279b67721f5287aa1c13a9a7fbbc48c9291b1e"
6631-
integrity sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==
6629+
version "2.3.0"
6630+
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
6631+
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
66326632
dependencies:
66336633
p-try "^2.0.0"
66346634

0 commit comments

Comments
 (0)