Add flow annotation
This commit is contained in:
parent
ba754dc271
commit
c840472d50
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended"
|
"eslint:recommended",
|
||||||
|
"plugin:flowtype/recommended",
|
||||||
|
"plugin:react/recommended"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"array-bracket-spacing": ["error", "always"],
|
"array-bracket-spacing": ["error", "always"],
|
||||||
@ -21,14 +23,51 @@
|
|||||||
"object-curly-spacing": ["error", "always"],
|
"object-curly-spacing": ["error", "always"],
|
||||||
"quotes": ["error", "single"],
|
"quotes": ["error", "single"],
|
||||||
"semi": ["error", "always" ],
|
"semi": ["error", "always" ],
|
||||||
"space-infix-ops": "error"
|
"space-infix-ops": "error",
|
||||||
|
|
||||||
|
"react/jsx-key": "error",
|
||||||
|
"react/jsx-no-bind": ["error", {
|
||||||
|
"ignoreRefs": true
|
||||||
|
}],
|
||||||
|
"react/no-unused-prop-types": "error",
|
||||||
|
"react/prefer-es6-class": "error",
|
||||||
|
"react/prop-types": [
|
||||||
|
"error", {
|
||||||
|
"ignore": [
|
||||||
|
"children",
|
||||||
|
"dispatch"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"react-native/no-inline-styles": "error",
|
||||||
|
"react-native/no-unused-styles": "error",
|
||||||
|
"react-native/split-platform-components": "warn"
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"es6": true,
|
"es6": true,
|
||||||
"node": true
|
"node": true
|
||||||
},
|
},
|
||||||
|
"parser": "babel-eslint",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 6,
|
"ecmaVersion": 8,
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
},
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
}
|
},
|
||||||
|
"settings": {
|
||||||
|
"flowtype": {
|
||||||
|
"onlyFilesWithFlowAnnotation": true
|
||||||
|
},
|
||||||
|
"react": {
|
||||||
|
"pragma": "React",
|
||||||
|
"version": "16.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"flowtype",
|
||||||
|
"react",
|
||||||
|
"react-native"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
31
.flowconfig
Normal file
31
.flowconfig
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
[ignore]
|
||||||
|
|
||||||
|
[include]
|
||||||
|
|
||||||
|
[libs]
|
||||||
|
node_modules/react-native/Libraries/react-native/react-native-interface.js
|
||||||
|
node_modules/react-native/flow
|
||||||
|
flow/
|
||||||
|
|
||||||
|
[options]
|
||||||
|
emoji=true
|
||||||
|
|
||||||
|
module.system=haste
|
||||||
|
|
||||||
|
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'
|
||||||
|
|
||||||
|
suppress_type=$FlowIssue
|
||||||
|
suppress_type=$FlowFixMe
|
||||||
|
suppress_type=$FixMe
|
||||||
|
|
||||||
|
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
|
||||||
|
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||||
|
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
||||||
|
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
|
||||||
|
|
||||||
|
unsafe.enable_getters_and_setters=true
|
||||||
|
|
||||||
|
[version]
|
||||||
|
^0.49.1
|
8
index.js
8
index.js
@ -1,3 +1,5 @@
|
|||||||
|
// @flow
|
||||||
|
|
||||||
import { NativeModules } from 'react-native';
|
import { NativeModules } from 'react-native';
|
||||||
const { AppMetrica } = NativeModules;
|
const { AppMetrica } = NativeModules;
|
||||||
|
|
||||||
@ -7,7 +9,7 @@ export default {
|
|||||||
* Starts the statistics collection process.
|
* Starts the statistics collection process.
|
||||||
* @param {string} apiKey
|
* @param {string} apiKey
|
||||||
*/
|
*/
|
||||||
activateWithApiKey(apiKey) {
|
activateWithApiKey(apiKey: string) {
|
||||||
AppMetrica.activateWithApiKey(apiKey);
|
AppMetrica.activateWithApiKey(apiKey);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -16,7 +18,7 @@ export default {
|
|||||||
* @param {string} message
|
* @param {string} message
|
||||||
* @param {object} [params=null]
|
* @param {object} [params=null]
|
||||||
*/
|
*/
|
||||||
reportEvent(message, params = null) {
|
reportEvent(message: string, params: ?Object = null) {
|
||||||
AppMetrica.reportEvent(message, params);
|
AppMetrica.reportEvent(message, params);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ export default {
|
|||||||
* @param {string} error
|
* @param {string} error
|
||||||
* @param {object} reason
|
* @param {object} reason
|
||||||
*/
|
*/
|
||||||
reportError(error, reason) {
|
reportError(error: string, reason: Object) {
|
||||||
AppMetrica.reportError(error, reason);
|
AppMetrica.reportError(error, reason);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -28,6 +28,11 @@
|
|||||||
"react-native": ">=0.45"
|
"react-native": ">=0.45"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^4.7.0"
|
"babel-eslint": "^8.0.1",
|
||||||
|
"eslint": "^4.7.0",
|
||||||
|
"eslint-plugin-flowtype": "^2.37.0",
|
||||||
|
"eslint-plugin-react": "^7.4.0",
|
||||||
|
"eslint-plugin-react-native": "^3.1.0",
|
||||||
|
"flow-bin": "0.49.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user