Add flow annotation

This commit is contained in:
Aleksei Androsov 2017-09-30 15:41:58 +03:00
parent ba754dc271
commit c840472d50
4 changed files with 85 additions and 8 deletions

View File

@ -1,6 +1,8 @@
{
"extends": [
"eslint:recommended"
"eslint:recommended",
"plugin:flowtype/recommended",
"plugin:react/recommended"
],
"rules": {
"array-bracket-spacing": ["error", "always"],
@ -21,14 +23,51 @@
"object-curly-spacing": ["error", "always"],
"quotes": ["error", "single"],
"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": {
"es6": true,
"node": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 8,
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
}
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": true
},
"react": {
"pragma": "React",
"version": "16.0.0"
}
},
"plugins": [
"flowtype",
"react",
"react-native"
]
}

31
.flowconfig Normal file
View 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

View File

@ -1,3 +1,5 @@
// @flow
import { NativeModules } from 'react-native';
const { AppMetrica } = NativeModules;
@ -7,7 +9,7 @@ export default {
* Starts the statistics collection process.
* @param {string} apiKey
*/
activateWithApiKey(apiKey) {
activateWithApiKey(apiKey: string) {
AppMetrica.activateWithApiKey(apiKey);
},
@ -16,7 +18,7 @@ export default {
* @param {string} message
* @param {object} [params=null]
*/
reportEvent(message, params = null) {
reportEvent(message: string, params: ?Object = null) {
AppMetrica.reportEvent(message, params);
},
@ -25,7 +27,7 @@ export default {
* @param {string} error
* @param {object} reason
*/
reportError(error, reason) {
reportError(error: string, reason: Object) {
AppMetrica.reportError(error, reason);
},
};

View File

@ -28,6 +28,11 @@
"react-native": ">=0.45"
},
"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"
}
}