diff --git a/.eslintrc.yaml b/.eslintrc.yaml index b9f09191e..da7ff7c76 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -23,6 +23,10 @@ env: browser: true commonjs: true es6: true +settings: + react: + version: detect + flowVersion: detect overrides: files: ['*.test.js', 'cypress/integration/**/*.js'] diff --git a/source/components/Feedback/PageFeedback.js b/source/components/Feedback/PageFeedback.js index 01edffc6a..32be69286 100644 --- a/source/components/Feedback/PageFeedback.js +++ b/source/components/Feedback/PageFeedback.js @@ -3,7 +3,7 @@ import withTracker from 'Components/utils/withTracker' import React, { Component } from 'react' import { Trans, withNamespaces } from 'react-i18next' -import { withRouter } from 'react-router-dom' +import { withRouter } from 'react-router' import { compose } from 'redux' import safeLocalStorage from '../../storage/safeLocalStorage' import './Feedback.css' @@ -12,13 +12,16 @@ import type { Tracker } from 'Components/utils/withTracker' import type { Location } from 'react-router-dom' import type { Node } from 'react' -type Props = { - location: Location, + +type OwnProps = { blacklist: Array, customMessage?: Node, - tracker: Tracker, customEventName?: string } +type Props = OwnProps & { + location: Location, + tracker: Tracker, +} type State = { showForm: boolean, showThanks: boolean @@ -150,9 +153,8 @@ class PageFeedback extends Component { const PageFeedbackWithRouter = ({ location, ...props }) => ( ) - -export default compose( +export default (compose( + withRouter, withNamespaces(), withTracker, - withRouter -)(PageFeedbackWithRouter) +)(PageFeedbackWithRouter): React$ComponentType) diff --git a/source/components/QuickLinks.js b/source/components/QuickLinks.js index a766ca263..661ef34fb 100644 --- a/source/components/QuickLinks.js +++ b/source/components/QuickLinks.js @@ -10,11 +10,13 @@ import { animated, Spring } from 'react-spring'; import { validInputEnteredSelector } from 'Selectors/analyseSelectors'; import type { Location } from 'react-router' -type Props = { +type OwnProps = { + quickLinks: {[string]: string}, +} +type Props = OwnProps & { startConversation: (?string) => void, location: Location, validInputEntered: boolean, - quickLinks: {[string]: string}, conversationStarted: boolean } @@ -59,7 +61,7 @@ const QuickLinks = ({ ) } -export default compose( +export default (compose( withLanguage, withRouter, connect( @@ -73,4 +75,4 @@ export default compose( startConversation } ) -)(QuickLinks) +)(QuickLinks): React$ComponentType) diff --git a/source/selectors/ficheDePaieSelectors.js b/source/selectors/ficheDePaieSelectors.js index 800bddbfa..b4d87755c 100644 --- a/source/selectors/ficheDePaieSelectors.js +++ b/source/selectors/ficheDePaieSelectors.js @@ -195,6 +195,7 @@ function analysisToFicheDePaie( ), salaireNet: règleAvecMontant('contrat salarié . salaire . net'), nombreHeuresTravaillées: Math.round( + // $FlowFixMe règleAvecValeur('contrat salarié . temps partiel . heures par semaine') .valeur * 4.33 ), @@ -204,7 +205,7 @@ function analysisToFicheDePaie( ) } } - +// $FlowFixMe export default createSelector( [ règleAvecMontantSelector, diff --git a/source/sites/mycompanyinfrance.fr/layout/Footer/Footer.js b/source/sites/mycompanyinfrance.fr/layout/Footer/Footer.js index cafb041b0..97683ab79 100644 --- a/source/sites/mycompanyinfrance.fr/layout/Footer/Footer.js +++ b/source/sites/mycompanyinfrance.fr/layout/Footer/Footer.js @@ -7,8 +7,6 @@ import urssafSvg from 'Images/urssaf.svg' import { compose } from 'ramda' import React from 'react' import Helmet from 'react-helmet' -import { Trans, withNamespaces } from 'react-i18next' -import { withRouter } from 'react-router' import i18n from '../../../../i18n' import { feedbackBlacklist } from '../../config' import { hrefLangLink } from '../../sitePaths' @@ -87,7 +85,5 @@ const Footer = ({ colours: { colour } }) => { ) } export default compose( - withRouter, withColours, - withNamespaces() )(Footer) diff --git a/source/sites/mycompanyinfrance.fr/layout/Navigation/NavOpener.js b/source/sites/mycompanyinfrance.fr/layout/Navigation/NavOpener.js index 75edb1b62..c0beb1f4e 100644 --- a/source/sites/mycompanyinfrance.fr/layout/Navigation/NavOpener.js +++ b/source/sites/mycompanyinfrance.fr/layout/Navigation/NavOpener.js @@ -4,17 +4,19 @@ import classnames from 'classnames' import withTracker from 'Components/utils/withTracker' import { compose } from 'ramda' import React, { Component } from 'react' -import { NavLink, withRouter } from 'react-router-dom' +import { withRouter } from "react-router"; +import { NavLink } from 'react-router-dom' import type { Tracker } from 'Components/utils/withTracker' import type { Location } from 'react-router-dom' import type { ChildrenArray, Node, Element } from 'react' -type Props = { - // to: string, +type OwnProps = { children: ChildrenArray>, - title: Node, - location: Location, to?: ?string, + title: Node, +} +type Props = OwnProps & { + location: Location, tracker: Tracker } type State = { @@ -116,7 +118,7 @@ class NavOpener extends Component { } } -export default compose( +export default (compose( withTracker, withRouter -)(NavOpener) +)(NavOpener): React$ComponentType) diff --git a/source/sites/mycompanyinfrance.fr/layout/Navigation/Navigation.js b/source/sites/mycompanyinfrance.fr/layout/Navigation/Navigation.js index 76298148f..39b4ac3c8 100644 --- a/source/sites/mycompanyinfrance.fr/layout/Navigation/Navigation.js +++ b/source/sites/mycompanyinfrance.fr/layout/Navigation/Navigation.js @@ -4,7 +4,8 @@ import withSitePaths from 'Components/utils/withSitePaths'; import { compose } from 'ramda'; import { withNamespaces } from 'react-i18next'; import { connect } from 'react-redux'; -import { NavLink, withRouter } from 'react-router-dom'; +import { NavLink, } from 'react-router-dom'; +import { withRouter } from "react-router"; import companySvg from '../../images/company.svg'; import estimateSvg from '../../images/estimate.svg'; import hiringSvg from '../../images/hiring.svg'; @@ -14,7 +15,8 @@ import SideBar from './SideBar'; import type { TFunction } from 'react-i18next' -type Props = { +type OwnProps = {}; +type Props = OwnProps & { companyProgress: number, estimationProgress: number, sitePaths: Object, @@ -257,7 +259,7 @@ const StepsHeader = ({ t, sitePaths, companyStatusChoice }: Props) => ( ) -export default compose( +export default (compose( withRouter, withNamespaces(), withSitePaths, @@ -267,4 +269,4 @@ export default compose( }), {} ) -)(StepsHeader) +)(StepsHeader): React$ComponentType) diff --git a/source/sites/mycompanyinfrance.fr/layout/Navigation/SideBar.js b/source/sites/mycompanyinfrance.fr/layout/Navigation/SideBar.js index 431e513a7..2e1f68844 100644 --- a/source/sites/mycompanyinfrance.fr/layout/Navigation/SideBar.js +++ b/source/sites/mycompanyinfrance.fr/layout/Navigation/SideBar.js @@ -9,21 +9,21 @@ import React from 'react' import { withRouter } from 'react-router' import './SideBar.css' import type { Tracker } from 'Components/utils/withTracker' -import type { Node } from 'react' import type { Location } from 'react-router-dom' +type OwnProps = {| + children: React$Node +|} + +type Props = OwnProps & { + tracker: Tracker, + location: Location, +} type State = { opened: boolean, sticky: boolean } -type Props = { - tracker: Tracker, - location: Location, - /* ownProps */ - children: Node -} - const bigScreen = window.matchMedia('(min-width: 1500px)') const isParent = (parentNode, children) => { if (children === parentNode) { @@ -95,7 +95,7 @@ class SideBar extends React.Component { } } -export default compose( +export default (compose( + withTracker, withRouter, - withTracker -)(SideBar) +)(SideBar): React$ComponentType) diff --git a/source/sites/mycompanyinfrance.fr/layout/ProgressHeader/ProgressHeader.js b/source/sites/mycompanyinfrance.fr/layout/ProgressHeader/ProgressHeader.js index a55c62643..254cc8ed1 100644 --- a/source/sites/mycompanyinfrance.fr/layout/ProgressHeader/ProgressHeader.js +++ b/source/sites/mycompanyinfrance.fr/layout/ProgressHeader/ProgressHeader.js @@ -6,7 +6,8 @@ import withTracker from 'Components/utils/withTracker' import { compose } from 'ramda' import { withNamespaces } from 'react-i18next' import { connect } from 'react-redux' -import { NavLink, withRouter } from 'react-router-dom' +import { NavLink } from 'react-router-dom' +import { withRouter } from "react-router"; import selectors from 'Selectors/progressSelectors' import companySvg from '../../images/company.svg' import estimateSvg from '../../images/estimate.svg' @@ -24,8 +25,10 @@ const Progress = ({ percent }) => ( }} /> + ) -type Props = { +type OwnProps = {} +type Props = OwnProps & { companyProgress: number, estimationProgress: number, hiringProgress: number, @@ -83,13 +86,13 @@ const StepsHeader = ({ ) -export default compose( - withRouter, +export default (compose( withTracker, connect( selectors, {} - ), + ), + withRouter, withNamespaces(), withSitePaths -)(StepsHeader) +)(StepsHeader): React$ComponentType) diff --git a/source/sites/mycompanyinfrance.fr/pages/Company/Find.js b/source/sites/mycompanyinfrance.fr/pages/Company/Find.js index 8e8f7c238..e58487a6c 100644 --- a/source/sites/mycompanyinfrance.fr/pages/Company/Find.js +++ b/source/sites/mycompanyinfrance.fr/pages/Company/Find.js @@ -11,6 +11,8 @@ import { Link } from 'react-router-dom' import ReactSelect from 'react-select' // $FlowFixMe import 'react-select/dist/react-select.css' +import type { SitePaths } from 'Components/utils/withSitePaths' +import type { TFunction } from 'react-i18next' import './Find.css' import { CompanyDetails as Company } from './YourCompany' import type { RouterHistory } from 'react-router' @@ -22,10 +24,11 @@ const goToNextStep = (history: RouterHistory, sitePaths: Object) => { type State = { input: ?{ [string]: string } } - +type OwnProps = {} type Props = { - //onCompanyDetailsConfirmation: ({ [string]: string }) => void, - history: RouterHistory + history: RouterHistory, + t: TFunction, + sitePaths: SitePaths, } class Search extends React.Component { @@ -111,9 +114,9 @@ class Search extends React.Component { } } -export default compose( - withRouter, +export default (compose( withSitePaths, + withRouter, connect( null, { @@ -121,4 +124,4 @@ export default compose( } ), withNamespaces() -)(Search) +)(Search): React$ComponentType) diff --git a/test/ficheDePaieSelector.test.js b/test/ficheDePaieSelector.test.js index 544911ed6..845e50e0e 100644 --- a/test/ficheDePaieSelector.test.js +++ b/test/ficheDePaieSelector.test.js @@ -27,6 +27,7 @@ let paySlip = null describe('pay slip selector', function() { beforeEach(() => { + // $FlowFixMe paySlip = FicheDePaieSelectors(state) expect(paySlip).not.to.eq(null)