Skip to content

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Guo committed Apr 9, 2020
1 parent 060cf02 commit 67593b9
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 52 deletions.
75 changes: 40 additions & 35 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

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

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

; Ignore polyfills
.*/Libraries/polyfills/.*
; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

; Ignore metro
.*/node_modules/metro/.*
[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

Expand All @@ -31,42 +30,48 @@ emoji=true
esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

module.system=haste
module.system.haste.use_name_reducers=true
# get basename
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
# strip .js or .js.flow suffix
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
# strip .ios suffix
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
module.system.haste.paths.blacklist=.*/__tests__/.*
module.system.haste.paths.blacklist=.*/__mocks__/.*
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js

munge_underscores=true

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'

# Support the library import in examples
module.name_mapper='^\@react-native-community/async-storage$' -> '<PROJECT_ROOT>/lib/AsyncStorage.js'

module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
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'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

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

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
inexact-spread=warn
unnecessary-invariant=warn
signature-verification-failure=warn
deprecated-utility=error

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.92.0
^0.105.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"detox": "12.6.1",
"expo": "36.0.2",
"eslint": "5.1.0",
"flow-bin": "0.92.0",
"flow-bin": "0.105.2",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.54.1",
"react": "16.9.0",
Expand Down
4 changes: 2 additions & 2 deletions windows/ReactNativeAsyncStorage/DBStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ DBStorage::DBStorage() {
}

DBStorage::~DBStorage() {
decltype(m_action) action;
decltype(m_tasks) tasks;
{
// If there is an in-progress async task, cancel it and wait on the
// condition_variable for the async task to acknowledge cancellation by
// nulling out m_action. Once m_action is null, it is safe to proceed
// wth closing the DB connection
winrt::slim_lock_guard guard{ m_lock };
m_tasks.clear();
swap(tasks, m_tasks);
if (m_action) {
m_action.Cancel();
m_cv.wait(m_lock, [this]() { return m_action == nullptr; });
Expand Down
14 changes: 7 additions & 7 deletions windows/ReactNativeAsyncStorage/RNCAsyncStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ReactNativeAsyncStorage
REACT_METHOD(multiGet);
void multiGet(std::vector<JSValue>& keys, std::function<void(JSValueArray const& errors, JSValueArray const& results)>&& callback) noexcept {
dbStorage.AddTask(DBStorage::DBTask::Type::multiGet, std::move(keys),
[callback](std::vector<JSValue> const& callbackParams) {
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
if (callbackParams.size() > 0) {
auto& errors = callbackParams[0].AsArray();
if (callbackParams.size() > 1) {
Expand All @@ -33,7 +33,7 @@ namespace ReactNativeAsyncStorage
REACT_METHOD(multiSet);
void multiSet(std::vector<JSValue>& pairs, std::function<void(JSValueArray const&)>&& callback) noexcept {
dbStorage.AddTask(DBStorage::DBTask::Type::multiSet, std::move(pairs),
[callback](std::vector<JSValue> const& callbackParams) {
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
if (callbackParams.size() > 0) {
auto& errors = callbackParams[0].AsArray();
callback(errors);
Expand All @@ -50,7 +50,7 @@ namespace ReactNativeAsyncStorage
newValues.push_back(pair.AsArray()[1].AsString());
}

multiGet(std::move(keys), [newValues, callback, this](JSValueArray const& errors, JSValueArray const& results) {
multiGet(std::move(keys), [newValues{ std::move(newValues) }, callback{ std::move(callback) }, this](JSValueArray const& errors, JSValueArray const& results) {
if (errors.size() > 0) {
callback(errors);
return;
Expand Down Expand Up @@ -88,7 +88,7 @@ namespace ReactNativeAsyncStorage
}
}

multiSet(std::move(mergedResults), [callback](JSValueArray const& errors) {
multiSet(std::move(mergedResults), [callback{ std::move(callback) }](JSValueArray const& errors) {
callback(errors);
});
});
Expand All @@ -97,7 +97,7 @@ namespace ReactNativeAsyncStorage
REACT_METHOD(multiRemove);
void multiRemove(std::vector<JSValue>& keys, std::function<void(JSValueArray const&)>&& callback) noexcept {
dbStorage.AddTask(DBStorage::DBTask::Type::multiRemove, std::move(keys),
[callback](std::vector<JSValue> const& callbackParams) {
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
if (callbackParams.size() > 0) {
auto& errors = callbackParams[0].AsArray();
callback(errors);
Expand All @@ -108,7 +108,7 @@ namespace ReactNativeAsyncStorage
REACT_METHOD(getAllKeys);
void getAllKeys(std::function<void(JSValueArray const& errors, JSValueArray const& keys)>&& callback) noexcept {
dbStorage.AddTask(DBStorage::DBTask::Type::getAllKeys,
[callback](std::vector<JSValue> const& callbackParams) {
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
if (callbackParams.size() > 0) {
auto& errors = callbackParams[0].AsArray();
if (callbackParams.size() > 1) {
Expand All @@ -124,7 +124,7 @@ namespace ReactNativeAsyncStorage
REACT_METHOD(clear);
void clear(std::function<void(JSValueArray const&)>&& callback) noexcept {
dbStorage.AddTask(DBStorage::DBTask::Type::clear,
[callback](std::vector<JSValue> const& callbackParams) {
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
if (callbackParams.size() > 0) {
auto& errors = callbackParams[0].AsArray();
callback(errors);
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4051,10 +4051,10 @@ flat-cache@^1.2.1:
rimraf "~2.6.2"
write "^0.2.1"

flow-bin@0.92.0:
version "0.92.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.92.0.tgz#f5bf3e808b17b480e067ac673829ca715a168bea"
integrity sha512-3ErXSAXZZlLV5/QPlaUDCWlDUXop1SiH32ifXL3SEiBwsmGbudCLim+HFVZfkegrn1nB4TcNSkMWtW8SnMPyAQ==
flow-bin@0.105.2:
version "0.105.2"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.105.2.tgz#9d03d5ae3e1d011e311f309cb8786b3b3695fec2"
integrity sha512-VCHt0SCjFPviv/Ze/W7AgkcE0uH4TocypSFA8wR3ZH1P7BSjny4l3uhHyOjzU3Qo1i0jO4NyaU6q3Y5IaQ6xng==

fontfaceobserver@^2.1.0:
version "2.1.0"
Expand Down Expand Up @@ -6626,9 +6626,9 @@ p-limit@^2.0.0:
p-try "^2.0.0"

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

Expand Down

0 comments on commit 67593b9

Please sign in to comment.