#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-unknown-property": "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/sort-comp": ["off", {"order": ["lifecycle", "render", "everything-else"]}]
}

View File

@ -1,5 +1,6 @@
[ignore]
.*/node_modules/fbjs/lib/.*
.*/node_modules/react-motion/lib/.*
[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>
*/
export default class MeasureHeight extends PureComponent {
props: {
shouldMeasure: (prevState: any, newState: any) => bool,
onMeasure: (height: number) => void,
state: any
};
export default class MeasureHeight extends PureComponent<{
shouldMeasure: (prevState: any, newState: any) => bool,
onMeasure: (height: number) => void,
state: any
}> {
static defaultProps = {
shouldMeasure: (prevState: any, newState: any) => prevState !== newState,
onMeasure: (height) => {} // eslint-disable-line

View File

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

View File

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

View File

@ -14,7 +14,9 @@ import androidLogo from './images/android.svg';
import appleLogo from './images/apple.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: {
activeOs: null|'android'|'ios'|'windows'
} = {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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