From 8dab2922cfc8b299bae3c7b011ab2077091708ac Mon Sep 17 00:00:00 2001 From: Ivan Jager Date: Sat, 31 Mar 2018 04:04:15 -0500 Subject: [PATCH] Convert week_number.jsx to flow (as a simple example) (#1307) * Convert week_number.jsx to flow (as a simple example) Workaround for react-docgen#125 * Run flow from lint script --- .flowconfig | 11 +++++++++++ package.json | 4 +++- src/week_number.jsx | 8 ++++++-- yarn.lock | 4 ++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .flowconfig diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 000000000..1fed44533 --- /dev/null +++ b/.flowconfig @@ -0,0 +1,11 @@ +[ignore] + +[include] + +[libs] + +[lints] + +[options] + +[strict] diff --git a/package.json b/package.json index 8216893b5..f5cf621de 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "eslint-plugin-react": "^7.4.0", "express": "^4.16.2", "extract-text-webpack-plugin": "^1.0.1", + "flow-bin": "^0.68.0", "highlight.js": "^9.12.0", "husky": "^0.14.3", "isparta-loader": "^2.0.0", @@ -95,10 +96,11 @@ }, "scripts": { "eslint": "eslint {src,test,docs-site/src}/**/*.{js,jsx} *.js", + "flow": "flow", "precommit": "lint-staged", "sass-lint": "sass-lint --config .sass-lint.yml 'src/stylesheets/*.scss, docs-site/src/*.scss' -i 'docs-site/src/higlight.scss, docs-site/src/reset.scss'", - "lint": "run-p eslint sass-lint", + "lint": "run-p eslint flow sass-lint", "start": "cross-env MODULES=false node server.js", "test": "cross-env NODE_ENV=test karma start karma.conf.js --single-run", "prepublish": "test $(npm -v | tr . '\\n' | head -n 1) -ge '4' || exit 1", diff --git a/src/week_number.jsx b/src/week_number.jsx index 6003509e6..440272d5b 100644 --- a/src/week_number.jsx +++ b/src/week_number.jsx @@ -1,14 +1,18 @@ +// @flow import React from "react"; import PropTypes from "prop-types"; import classnames from "classnames"; -export default class WeekNumber extends React.Component { +export default class WeekNumber extends React.Component<{ + weekNumber: number, + onClick?: Function +}> { static propTypes = { weekNumber: PropTypes.number.isRequired, onClick: PropTypes.func }; - handleClick = event => { + handleClick = (event: any) => { if (this.props.onClick) { this.props.onClick(event); } diff --git a/yarn.lock b/yarn.lock index ca9914b51..12d6d83f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2841,6 +2841,10 @@ flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" +flow-bin@^0.68.0: + version "0.68.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.68.0.tgz#86c2d14857d306eb2e85e274f2eebf543564f623" + for-in@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"