Add flow to project

This commit is contained in:
Gregory Schier 2017-07-17 16:32:47 -07:00
parent f03e3c3bcc
commit 08438b6911
11 changed files with 99 additions and 41 deletions

View File

@ -1,6 +1,7 @@
{
"presets": [
"react"
"react",
"flow"
],
"plugins": [
"transform-object-rest-spread",

View File

@ -4,4 +4,5 @@ dist/**/*
coverage/**/*
node_modules/**/*
webpack/**/*
**/__fixtures__/prettify/*
**/__fixtures__/prettify/*
flow-typed/**/*

View File

@ -1,7 +1,7 @@
{
"parser": "babel-eslint",
"extends": ["semistandard"],
"plugins": ["react", "jest", "html", "json", "filenames"],
"plugins": ["flowtype", "react", "jest", "html", "json", "filenames"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
@ -19,5 +19,10 @@
"react/jsx-uses-vars": "error",
"react/prop-types": "error",
"filenames/match-exported": ["error", "kebab"]
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": false
}
}
}

14
.flowconfig Normal file
View File

@ -0,0 +1,14 @@
[ignore]
.*/node_modules/.*
.*/__fixtures__/.*
[include]
[libs]
flow-typed/.*
[options]
esproposal.decorators=ignore
[lints]

View File

@ -1,4 +1,5 @@
import React, {PropTypes, PureComponent} from 'react';
// @flow
import React, {PureComponent} from 'react';
import autobind from 'autobind-decorator';
import fs from 'fs';
import mime from 'mime-types';
@ -24,7 +25,33 @@ import Hotkey from './hotkey';
@autobind
class ResponsePane extends PureComponent {
_trackTab (name) {
props: {
// Functions
handleSetFilter: Function,
showCookiesModal: Function,
handleSetPreviewMode: Function,
handleSetActiveResponse: Function,
handleDeleteResponses: Function,
handleDeleteResponse: Function,
handleShowRequestSettings: Function,
// Required
previewMode: string,
filter: string,
filterHistory: Array<string>,
editorFontSize: number,
editorIndentSize: number,
editorKeyMap: string,
editorLineWrapping: boolean,
loadStartTime: number,
responses: Array<Object>,
// Other
request?: Object,
response?: Object
};
_trackTab (name: string) {
trackEvent('Response Pane', 'View', name);
}
@ -32,16 +59,6 @@ class ResponsePane extends PureComponent {
return models.response.getBodyBuffer(this.props.response);
}
async _getResponse (requestId, responseId) {
let response = responseId ? await models.response.getById(responseId) : null;
if (!response) {
response = await models.response.getLatestForRequest(requestId);
}
this.setState({response});
}
async _handleDownloadResponseBody () {
if (!this.props.response) {
// Should never happen
@ -314,30 +331,4 @@ class ResponsePane extends PureComponent {
}
}
ResponsePane.propTypes = {
// Functions
handleSetFilter: PropTypes.func.isRequired,
showCookiesModal: PropTypes.func.isRequired,
handleSetPreviewMode: PropTypes.func.isRequired,
handleSetActiveResponse: PropTypes.func.isRequired,
handleDeleteResponses: PropTypes.func.isRequired,
handleDeleteResponse: PropTypes.func.isRequired,
handleShowRequestSettings: PropTypes.func.isRequired,
// Required
previewMode: PropTypes.string.isRequired,
filter: PropTypes.string.isRequired,
filterHistory: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
editorFontSize: PropTypes.number.isRequired,
editorIndentSize: PropTypes.number.isRequired,
editorKeyMap: PropTypes.string.isRequired,
editorLineWrapping: PropTypes.bool.isRequired,
loadStartTime: PropTypes.number.isRequired,
responses: PropTypes.arrayOf(PropTypes.object),
// Other
request: PropTypes.object,
response: PropTypes.object
};
export default ResponsePane;

4
flow-typed/autobind-decorator.js vendored Normal file
View File

@ -0,0 +1,4 @@
// @flow
declare module 'autobind-decorator' {
declare module.exports: *
}

6
flow-typed/electron.js vendored Normal file
View File

@ -0,0 +1,6 @@
// @flow
declare module 'electron' {
declare module.exports: {
remote: *
}
}

4
flow-typed/mime-types.js vendored Normal file
View File

@ -0,0 +1,4 @@
// @flow
declare module 'mime-types' {
declare module.exports: *
}

10
flow-typed/react-tabs.js vendored Normal file
View File

@ -0,0 +1,10 @@
import type {Component} from 'react-flow-types';
declare module 'react-tabs' {
declare module.exports: {
Tab: Component,
TabList: Component,
TabPanel: Component,
Tabs: Component
}
}

18
package-lock.json generated
View File

@ -2365,6 +2365,12 @@
}
}
},
"eslint-plugin-flowtype": {
"version": "2.35.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.35.0.tgz",
"integrity": "sha512-zjXGjOsHds8b84C0Ad3VViKh+sUA9PeXKHwPRlSLwwSX0v1iUJf/6IX7wxc+w2T2tnDH8PT6B/YgtcEuNI3ssA==",
"dev": true
},
"eslint-plugin-html": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-2.0.1.tgz",
@ -2700,6 +2706,12 @@
"integrity": "sha1-2uRqnXj74lKSJYzB54CkHZXAN4I=",
"dev": true
},
"flow-bin": {
"version": "0.50.0",
"resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.50.0.tgz",
"integrity": "sha1-1M2yQw3uGjWZ8Otv5VEUbjAnJWo=",
"dev": true
},
"for-in": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
@ -6182,6 +6194,12 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-15.4.2.tgz",
"integrity": "sha1-AVNj8FsKH9Uq6e/dOgBg2QaVII8="
},
"react-flow-types": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/react-flow-types/-/react-flow-types-0.1.1.tgz",
"integrity": "sha1-56L3eE1cI09z3RFzs1TxyGviMXk=",
"dev": true
},
"react-hot-loader": {
"version": "3.0.0-beta.6",
"resolved": "https://registry.npmjs.org/react-hot-loader/-/react-hot-loader-3.0.0-beta.6.tgz",

View File

@ -163,6 +163,7 @@
"babel-plugin-transform-runtime": "^6.15.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.23.0",
"babel-preset-react-hmre": "^1.1.1",
"concurrently": "^2.0.0",
@ -175,6 +176,7 @@
"eslint-config-semistandard": "^7.0.0",
"eslint-config-standard": "^7.0.0",
"eslint-plugin-filenames": "^1.1.0",
"eslint-plugin-flowtype": "^2.35.0",
"eslint-plugin-html": "^2.0.1",
"eslint-plugin-jest": "^19.0.1",
"eslint-plugin-json": "^1.2.0",
@ -182,9 +184,11 @@
"eslint-plugin-react": "^6.10.0",
"eslint-plugin-standard": "^2.1.1",
"file-loader": "^0.10.1",
"flow-bin": "^0.50.0",
"jest": "^19.0.2",
"less": "^2.7.2",
"less-loader": "^2.2.3",
"react-flow-types": "^0.1.1",
"react-hot-loader": "^3.0.0-beta.6",
"redux-mock-store": "^1.0.2",
"style-loader": "^0.13.2",