#305: migrate to flowtype 0.5.3

This commit is contained in:
SleepWalker 2017-08-22 23:31:41 +03:00
parent b6f5326fae
commit e21f6c397d
18 changed files with 215 additions and 98 deletions

View File

@ -217,7 +217,7 @@
"react/no-string-refs": "warn", "react/no-string-refs": "warn",
"react/no-unknown-property": "warn", "react/no-unknown-property": "warn",
"react/prefer-es6-class": "warn", "react/prefer-es6-class": "warn",
"react/prop-types": "warn", "react/prop-types": "off", // using flowtype for this task
"react/self-closing-comp": "warn", "react/self-closing-comp": "warn",
"react/sort-comp": ["off", {"order": ["lifecycle", "render", "everything-else"]}] "react/sort-comp": ["off", {"order": ["lifecycle", "render", "everything-else"]}]
} }

View File

@ -1,5 +1,6 @@
[ignore] [ignore]
.*/node_modules/fbjs/lib/.* .*/node_modules/fbjs/lib/.*
.*/node_modules/react-motion/lib/.*
[include] [include]

123
flow-typed/npm/react-motion_vx.x.x.js vendored Normal file
View File

@ -0,0 +1,123 @@
// flow-typed signature: f7ed1ad96a453a021e6d98c1d144ef43
// flow-typed version: <<STUB>>/react-motion_v0.5.x/flow_v0.53.1
/**
* This is an autogenerated libdef stub for:
*
* 'react-motion'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'react-motion' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'react-motion/build/react-motion' {
declare module.exports: any;
}
declare module 'react-motion/lib/mapToZero' {
declare module.exports: any;
}
declare module 'react-motion/lib/mergeDiff' {
declare module.exports: any;
}
declare module 'react-motion/lib/Motion' {
declare module.exports: any;
}
declare module 'react-motion/lib/presets' {
declare module.exports: any;
}
declare module 'react-motion/lib/react-motion' {
declare module.exports: any;
}
declare module 'react-motion/lib/reorderKeys' {
declare module.exports: any;
}
declare module 'react-motion/lib/shouldStopAnimation' {
declare module.exports: any;
}
declare module 'react-motion/lib/spring' {
declare module.exports: any;
}
declare module 'react-motion/lib/StaggeredMotion' {
declare module.exports: any;
}
declare module 'react-motion/lib/stepper' {
declare module.exports: any;
}
declare module 'react-motion/lib/stripStyle' {
declare module.exports: any;
}
declare module 'react-motion/lib/TransitionMotion' {
declare module.exports: any;
}
declare module 'react-motion/lib/Types' {
declare module.exports: any;
}
// Filename aliases
declare module 'react-motion/build/react-motion.js' {
declare module.exports: $Exports<'react-motion/build/react-motion'>;
}
declare module 'react-motion/lib/mapToZero.js' {
declare module.exports: $Exports<'react-motion/lib/mapToZero'>;
}
declare module 'react-motion/lib/mergeDiff.js' {
declare module.exports: $Exports<'react-motion/lib/mergeDiff'>;
}
declare module 'react-motion/lib/Motion.js' {
declare module.exports: $Exports<'react-motion/lib/Motion'>;
}
declare module 'react-motion/lib/presets.js' {
declare module.exports: $Exports<'react-motion/lib/presets'>;
}
declare module 'react-motion/lib/react-motion.js' {
declare module.exports: $Exports<'react-motion/lib/react-motion'>;
}
declare module 'react-motion/lib/reorderKeys.js' {
declare module.exports: $Exports<'react-motion/lib/reorderKeys'>;
}
declare module 'react-motion/lib/shouldStopAnimation.js' {
declare module.exports: $Exports<'react-motion/lib/shouldStopAnimation'>;
}
declare module 'react-motion/lib/spring.js' {
declare module.exports: $Exports<'react-motion/lib/spring'>;
}
declare module 'react-motion/lib/StaggeredMotion.js' {
declare module.exports: $Exports<'react-motion/lib/StaggeredMotion'>;
}
declare module 'react-motion/lib/stepper.js' {
declare module.exports: $Exports<'react-motion/lib/stepper'>;
}
declare module 'react-motion/lib/stripStyle.js' {
declare module.exports: $Exports<'react-motion/lib/stripStyle'>;
}
declare module 'react-motion/lib/TransitionMotion.js' {
declare module.exports: $Exports<'react-motion/lib/TransitionMotion'>;
}
declare module 'react-motion/lib/Types.js' {
declare module.exports: $Exports<'react-motion/lib/Types'>;
}

View File

@ -23,13 +23,11 @@ import { omit, rAF, debounce } from 'functions';
* </MeasureHeight> * </MeasureHeight>
*/ */
export default class MeasureHeight extends PureComponent { export default class MeasureHeight extends PureComponent<{
props: { shouldMeasure: (prevState: any, newState: any) => bool,
shouldMeasure: (prevState: any, newState: any) => bool, onMeasure: (height: number) => void,
onMeasure: (height: number) => void, state: any
state: any }> {
};
static defaultProps = { static defaultProps = {
shouldMeasure: (prevState: any, newState: any) => prevState !== newState, shouldMeasure: (prevState: any, newState: any) => prevState !== newState,
onMeasure: (height) => {} // eslint-disable-line onMeasure: (height) => {} // eslint-disable-line

View File

@ -9,13 +9,11 @@ import { FooterMenu } from 'components/footerMenu';
import styles from './appInfo.scss'; import styles from './appInfo.scss';
import messages from './AppInfo.intl.json'; import messages from './AppInfo.intl.json';
export default class AppInfo extends Component { export default class AppInfo extends Component<{
props: { name?: string,
name?: string, description?: string,
description?: string, onGoToAuth: () => void
onGoToAuth: () => void }> {
};
render() { render() {
const { name, description, onGoToAuth } = this.props; const { name, description, onGoToAuth } = this.props;

View File

@ -32,9 +32,12 @@ type Props = {
step: MfaStep step: MfaStep
}; };
export default class MultiFactorAuth extends Component { export default class MultiFactorAuth extends Component<Props, {
props: Props; isLoading: bool,
activeStep: MfaStep,
secret: string,
qrCodeSrc: string
}> {
static defaultProps = { static defaultProps = {
confirmationForm: new FormModel(), confirmationForm: new FormModel(),
step: 0 step: 0

View File

@ -14,7 +14,9 @@ import androidLogo from './images/android.svg';
import appleLogo from './images/apple.svg'; import appleLogo from './images/apple.svg';
import windowsLogo from './images/windows.svg'; import windowsLogo from './images/windows.svg';
export default class Instructions extends Component { export default class Instructions extends Component<{}, {
activeOs: null|'android'|'ios'|'windows'
}> {
state: { state: {
activeOs: null|'android'|'ios'|'windows' activeOs: null|'android'|'ios'|'windows'
} = { } = {

View File

@ -71,13 +71,13 @@ export function PanelFooter(props: {
); );
} }
export class PanelBodyHeader extends Component { export class PanelBodyHeader extends Component<{
props: { type: 'default'|'error',
type: 'default'|'error', onClose: Function,
onClose: Function, children: *
children: * }, {
}; isClosed: bool
}> {
state: { state: {
isClosed: bool isClosed: bool
} = { } = {

View File

@ -17,11 +17,13 @@ type Props = {
onInvalid: (errors: {[errorKey: string]: string}) => void, onInvalid: (errors: {[errorKey: string]: string}) => void,
children: * children: *
}; };
type State = {
isTouched: bool,
isLoading: bool
};
type InputElement = HTMLInputElement|HTMLTextAreaElement; type InputElement = HTMLInputElement|HTMLTextAreaElement;
export default class Form extends Component { export default class Form extends Component<Props, State> {
props: Props;
static defaultProps = { static defaultProps = {
id: 'default', id: 'default',
isLoading: false, isLoading: false,

View File

@ -6,12 +6,12 @@ import MeasureHeight from 'components/MeasureHeight';
import styles from './scroll-motion.scss'; import styles from './scroll-motion.scss';
export default class ScrollMotion extends Component { export default class ScrollMotion extends Component<{
props: { activeStep: number,
activeStep: number, children: *
children: ?React.Children }, {
}; version: number
}> {
state: { state: {
version: number version: number
} = { } = {

View File

@ -9,11 +9,11 @@ import styles from './loggedInPanel.scss';
import type { User } from 'components/user'; import type { User } from 'components/user';
export default class LoggedInPanel extends Component { export default class LoggedInPanel extends Component<{
props: { user: User
user: User }, {
}; isAccountSwitcherActive: bool
}> {
state = { state = {
isAccountSwitcherActive: false isAccountSwitcherActive: false
}; };

View File

@ -9,9 +9,9 @@ type ComponentProps = {
routerProps: Object routerProps: Object
}; };
export default class AuthFlowRouteContents extends Component { export default class AuthFlowRouteContents extends Component<ComponentProps, {
props: ComponentProps; component: any
}> {
state: { state: {
component: any component: any
} = { } = {

View File

@ -21,15 +21,15 @@ import Finish from 'components/auth/finish/Finish';
import styles from './auth.scss'; import styles from './auth.scss';
class AuthPage extends Component { class AuthPage extends Component<{
props: { client: {
client: { id: string,
id: string, name: string,
name: string, description: string
description: string }
} }, {
}; isSidebarHidden: bool
}> {
state = { state = {
isSidebarHidden: false isSidebarHidden: false
}; };

View File

@ -13,13 +13,11 @@ import messages from './SuccessOauthPage.intl.json';
import type { Query } from 'services/request'; import type { Query } from 'services/request';
export default class SuccessOauthPage extends Component { export default class SuccessOauthPage extends Component<{
props: { location: {
location: { query: Query<'appName'>
query: Query<'appName'> }
} }> {
};
componentDidMount() { componentDidMount() {
this.onPageUpdate(); this.onPageUpdate();

View File

@ -6,18 +6,16 @@ import MultiFactorAuth, { MfaStep } from 'components/profile/multiFactorAuth';
import type { FormModel } from 'components/ui/form'; import type { FormModel } from 'components/ui/form';
class MultiFactorAuthPage extends Component { class MultiFactorAuthPage extends Component<{
props: { history: {
history: { push: (string) => void
push: (string) => void },
}, match: {
match: { params: {
params: { step?: '1'|'2'|'3'
step?: '1'|'2'|'3'
}
} }
}; }
}> {
static contextTypes = { static contextTypes = {
onSubmit: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired,
goToProfile: PropTypes.func.isRequired goToProfile: PropTypes.func.isRequired

View File

@ -17,12 +17,10 @@ import styles from './profile.scss';
import type { FormModel } from 'components/ui/form'; import type { FormModel } from 'components/ui/form';
class ProfilePage extends Component { class ProfilePage extends Component<{
props: { onSubmit: ({form: FormModel, sendData: () => Promise<*>}) => void,
onSubmit: ({form: FormModel, sendData: () => Promise<*>}) => void, fetchUserData: () => Promise<*>
fetchUserData: () => Promise<*> }> {
};
static childContextTypes = { static childContextTypes = {
onSubmit: PropTypes.func, onSubmit: PropTypes.func,
goToProfile: PropTypes.func goToProfile: PropTypes.func

View File

@ -30,16 +30,14 @@ if (process.env.NODE_ENV === 'production') {
DevTools = require('containers/DevTools').default; DevTools = require('containers/DevTools').default;
} }
class RootPage extends Component { class RootPage extends Component<{
props: { user: User,
user: User, isPopupActive: boolean,
isPopupActive: boolean, onLogoClick: Function,
onLogoClick: Function, location: {
location: { pathname: string
pathname: string }
} }> {
};
componentDidMount() { componentDidMount() {
this.onPageUpdate(); this.onPageUpdate();
} }

View File

@ -59,19 +59,17 @@ const rules = [
} }
]; ];
export default class RulesPage extends Component { export default class RulesPage extends Component<{
props: { location: {
location: { pathname: string,
pathname: string, search: string,
search: string, hash: string
hash: string },
},
history: {
replace: Function
}
};
history: {
replace: Function
}
}> {
render() { render() {
let {hash} = this.props.location; let {hash} = this.props.location;