Skip to content

Commit

Permalink
adds flow
Browse files Browse the repository at this point in the history
  • Loading branch information
brigand committed Mar 27, 2017
1 parent 3c3b8e9 commit 3864af6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[libs]
./node_modules/fbjs/flow/lib

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

module.name_mapper='^\(.*\)\.css$' -> 'react-scripts/config/flow/css'
module.name_mapper='^\(.*\)\.\(jpg\|png\|gif\|eot\|svg\|ttf\|woff\|woff2\|mp4\|webm\)$' -> 'react-scripts/config/flow/file'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"react-dom": "15.4.2"
},
"devDependencies": {
"flow-bin": "^0.42.0",
"gh-pages": "^0.12.0",
"react-scripts": "0.9.1"
},
Expand All @@ -17,6 +18,7 @@
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"deploy": "gh-pages -d build",
"predeploy": "npm run build"
"predeploy": "npm run build",
"flow": "flow; test $? -eq 0 -o $? -eq 2"
}
}
11 changes: 8 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// @flow
import React, { Component } from 'react';
import Home from './sites/home/Home';
import BabelSite from './sites/babelrc/BabelSite';
import getCurrentSite from './utils/getCurrentSite';
import './App.css';

class App extends Component {
constructor(props) {
state: {
site: ?string,
};
constructor(props: {}) {
super(props);
this.state = {
site: getCurrentSite(),
Expand All @@ -19,7 +23,7 @@ class App extends Component {
render() {
return (
<div className="App">
{this.getTitle === 'Home' &&
{this.getTitle() === 'Home' &&
<h1 className="App__Header">
{`Config Wizard:`} <strong className="App__Header__Site">{this.getTitle()}</strong>
</h1>
Expand All @@ -34,7 +38,7 @@ class App extends Component {
);
}

getTitle() {
getTitle(): string {
const {site} = this.state;
if (site === null) {
return 'Home';
Expand All @@ -45,6 +49,7 @@ class App extends Component {
if (site === 'eslintrc') {
return '.eslintrc';
}
return '';
}

renderSite() {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/getCurrentSite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const getCurrentSite = () => {
// @flow
const getCurrentSite = (): ?string => {
const url = location.search.slice(1);
if (url.indexOf('babelrc') === 0) {
return 'babelrc';
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2160,6 +2160,10 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"

flow-bin@^0.42.0:
version "0.42.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.42.0.tgz#05dd754b6b052de7b150f9210e2160746961e3cf"

for-in@^0.1.5:
version "0.1.6"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.6.tgz#c9f96e89bfad18a545af5ec3ed352a1d9e5b4dc8"
Expand Down

0 comments on commit 3864af6

Please sign in to comment.